From 7a9f18f22332d6ad8c4a520f0b75869d0cdbba29 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 8 Aug 2023 09:04:26 +0200 Subject: [PATCH] play tones as music when silent only on android 12+ --- .../java/eu/siacs/conversations/xmpp/jingle/ToneManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/ToneManager.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/ToneManager.java index 2ee307082..da5b9ab2b 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/ToneManager.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/ToneManager.java @@ -3,6 +3,7 @@ package eu.siacs.conversations.xmpp.jingle; import android.content.Context; import android.media.AudioManager; import android.media.ToneGenerator; +import android.os.Build; import android.util.Log; import java.util.Arrays; @@ -189,7 +190,8 @@ class ToneManager { private static ToneGenerator getToneGenerator(final boolean ringerModeNormal) { try { - if (ringerModeNormal) { + // when silent and on Android 12+ use STREAM_MUSIC + if (ringerModeNormal || Build.VERSION.SDK_INT < Build.VERSION_CODES.S) { return new ToneGenerator(AudioManager.STREAM_VOICE_CALL,60); } else { return new ToneGenerator(AudioManager.STREAM_MUSIC,100);