From f2f0070e8e75ecd7b921819981c137246d06d983 Mon Sep 17 00:00:00 2001 From: Kamal Negi <kamaln@codeaurora.org> Date: Tue, 31 May 2016 15:46:35 +0530 Subject: [PATCH] fm: stop FM operations after FM stops Stop FM operations (disable audio, update UI etc) after FM has been stopped. When FM is muted and FM stops, short audio has been redirected to audio device before FM stops, that shouldn't be redirected. Change-Id: Id9cf5bedd753b79992b6f42e7a5668ad2561c6d1 --- fmapp2/src/com/caf/fmradio/FMRadioService.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java index b05b08c..f4f4be2 100644 --- a/fmapp2/src/com/caf/fmradio/FMRadioService.java +++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java @@ -2217,6 +2217,9 @@ public class FMRadioService extends Service { Log.d(LOGTAG, "audioManager.setFmRadioOn = false \n" ); stopFM(); + unMute(); + audioManager.abandonAudioFocus(mAudioFocusListener); + //audioManager.setParameters("FMRadioOn=false"); Log.d(LOGTAG, "audioManager.setFmRadioOn false done \n" ); } // reset FM audio settings @@ -2268,14 +2271,13 @@ public class FMRadioService extends Service private boolean fmOff() { boolean bStatus=false; - fmOperationsOff(); - // This will disable the FM radio device if (mReceiver != null) { bStatus = mReceiver.disable(); mReceiver = null; } + fmOperationsOff(); stop(); return(bStatus); } @@ -2285,11 +2287,6 @@ public class FMRadioService extends Service if (off_from == FM_OFF_FROM_APPLICATION || off_from == FM_OFF_FROM_ANTENNA) { Log.d(LOGTAG, "FM application close button pressed or antenna removed"); mSession.setActive(false); - AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); - if (audioManager != null) - audioManager.abandonAudioFocus(mAudioFocusListener); - else - Log.d(LOGTAG, "Failed to get Audio Service"); } return fmOff(); } -- GitLab