From eead6724ffb7f01e5e58bfe60e8d585f1d661c1a Mon Sep 17 00:00:00 2001 From: Satish kumar sugasi <ssugas@codeaurora.org> Date: Tue, 18 Oct 2016 14:47:46 -0700 Subject: [PATCH] Modify sequence of turning OFF FM recording and FM audio Disable FM audio playback first and then FM recording in case of FM turnoff due to audio focus loss to avoid overlapping of Fmaudio and Music app audio. CRs-Fixed: 1074809 Change-Id: Id498e436dac0e6fe0c9ef823490b1c7588e98ecb --- .../src/com/caf/fmradio/FMRadioService.java | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java index 2b9fb83..43e91a6 100644 --- a/fmapp2/src/com/caf/fmradio/FMRadioService.java +++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2015, The Linux Foundation. All rights reserved. + * Copyright (c) 2009-2016, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -1604,8 +1604,6 @@ public class FMRadioService extends Service case AudioManager.AUDIOFOCUS_LOSS: Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS"); //intentional fall through. - if (true == isFmRecordingOn()) - stopRecording(); if (mSpeakerPhoneOn) { mSpeakerDisableHandler.removeCallbacks(mSpeakerDisableTask); mSpeakerDisableHandler.postDelayed(mSpeakerDisableTask, 0); @@ -1613,6 +1611,9 @@ public class FMRadioService extends Service if (true == mPlaybackInProgress) { stopFM(); } + if (true == isFmRecordingOn()) + stopRecording(); + if (mSpeakerPhoneOn) { if (isAnalogModeSupported()) setAudioPath(false); @@ -2247,6 +2248,17 @@ public class FMRadioService extends Service * Turn OFF FM Operations: This disables all the current FM operations . */ private void fmOperationsOff() { + // disable audio path + AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); + if(audioManager != null) + { + Log.d(LOGTAG, "audioManager.setFmRadioOn = false \n" ); + stopFM(); + unMute(); + audioManager.abandonAudioFocus(mAudioFocusListener); + //audioManager.setParameters("FMRadioOn=false"); + Log.d(LOGTAG, "audioManager.setFmRadioOn false done \n" ); + } // stop recording if (isFmRecordingOn()) { @@ -2258,17 +2270,6 @@ public class FMRadioService extends Service return; } } - // disable audio path - AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); - if(audioManager != null) - { - 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 resetAudioRoute(); @@ -2281,6 +2282,7 @@ public class FMRadioService extends Service } } + /* * Reset (OFF) FM Operations: This resets all the current FM operations . */ -- GitLab