play tones as music when silent only on android 12+

This commit is contained in:
Daniel Gultsch 2023-08-08 09:04:26 +02:00
parent febaea0131
commit 7a9f18f223
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2

View file

@ -3,6 +3,7 @@ package eu.siacs.conversations.xmpp.jingle;
import android.content.Context; import android.content.Context;
import android.media.AudioManager; import android.media.AudioManager;
import android.media.ToneGenerator; import android.media.ToneGenerator;
import android.os.Build;
import android.util.Log; import android.util.Log;
import java.util.Arrays; import java.util.Arrays;
@ -189,7 +190,8 @@ class ToneManager {
private static ToneGenerator getToneGenerator(final boolean ringerModeNormal) { private static ToneGenerator getToneGenerator(final boolean ringerModeNormal) {
try { 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); return new ToneGenerator(AudioManager.STREAM_VOICE_CALL,60);
} else { } else {
return new ToneGenerator(AudioManager.STREAM_MUSIC,100); return new ToneGenerator(AudioManager.STREAM_MUSIC,100);