From 64ee669728572b843b0ec433e2a91baf0281c23d Mon Sep 17 00:00:00 2001 From: brumsel Date: Tue, 17 Nov 2015 00:06:09 +0100 Subject: [PATCH] Reset audio mode on incoming ringer stop Don't request audio focus in IncomingRinger either. Fixes #4548 Closes #4567 // FREEBIE --- .../thoughtcrime/redphone/audio/IncomingRinger.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/org/thoughtcrime/redphone/audio/IncomingRinger.java b/src/org/thoughtcrime/redphone/audio/IncomingRinger.java index b74b5d2eba..b3d33edc42 100644 --- a/src/org/thoughtcrime/redphone/audio/IncomingRinger.java +++ b/src/org/thoughtcrime/redphone/audio/IncomingRinger.java @@ -29,6 +29,8 @@ import android.os.Vibrator; import android.provider.Settings; import android.util.Log; +import org.thoughtcrime.securesms.util.ServiceUtil; + import java.io.IOException; /** @@ -74,13 +76,7 @@ public class IncomingRinger { } public void start() { - AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); - audioManager.requestAudioFocus(new AudioManager.OnAudioFocusChangeListener() { - @Override - public void onAudioFocusChange(int focusChange) {} - }, - AudioManager.STREAM_MUSIC, - AudioManager.AUDIOFOCUS_GAIN); + AudioManager audioManager = ServiceUtil.getAudioManager(context); if(player == null) { //retry player creation to pick up changed ringtones or audio server restarts @@ -120,6 +116,9 @@ public class IncomingRinger { } Log.d(TAG, "Cancelling vibrator"); vibrator.cancel(); + + AudioManager audioManager = ServiceUtil.getAudioManager(context); + audioManager.setMode(AudioManager.MODE_NORMAL); } private boolean shouldVibrate() {