diff options
author | Rupesh Tatiya <rtatiya@codeaurora.org> | 2016-01-25 16:54:27 +0530 |
---|---|---|
committer | Arne Coucheron <arco68@gmail.com> | 2016-03-22 00:14:27 +0100 |
commit | ef247c45282a19c0f9f3042f2c0a503ed84d39b1 (patch) | |
tree | b0f69de6b66a0a71d5d5b47de0b4762a3e5ba39d | |
parent | 8f2d9e0c5e283e2736606ffb6536ef0be5303930 (diff) | |
download | android_hardware_qcom_fm-ef247c45282a19c0f9f3042f2c0a503ed84d39b1.tar.gz android_hardware_qcom_fm-ef247c45282a19c0f9f3042f2c0a503ed84d39b1.tar.bz2 android_hardware_qcom_fm-ef247c45282a19c0f9f3042f2c0a503ed84d39b1.zip |
Request for audio focus on activity resume
FM might lose audio focus and go in the pause state. Hence request audio
focus during resume. Otherwise, activity displayed might be FM but audio
source might be something else like music.
CRs-Fixed: 966644
Change-Id: I681b51f3a54abbc04223c60496aa3049b6769a1f
-rw-r--r-- | fmapp2/src/com/caf/fmradio/FMRadio.java | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/fmapp2/src/com/caf/fmradio/FMRadio.java b/fmapp2/src/com/caf/fmradio/FMRadio.java index 5a9920a..e331aef 100644 --- a/fmapp2/src/com/caf/fmradio/FMRadio.java +++ b/fmapp2/src/com/caf/fmradio/FMRadio.java @@ -528,43 +528,56 @@ public class FMRadio extends Activity @Override public void onResume() { + Log.d(LOGTAG, "FMRadio: onResume"); + super.onResume(); + if (null == mService) { + Log.e(LOGTAG, "FM Service is not running, returning"); + return; + } + syncScanState(); + + // TODO: We should return on exception or continue? try { - if(mService != null) { - mService.registerCallbacks(mServiceCallbacks); - } - }catch (RemoteException e) { - e.printStackTrace(); + mService.registerCallbacks(mServiceCallbacks); + } catch (RemoteException e) { + e.printStackTrace(); } - if(isSleepTimerActive()) { + + if (isSleepTimerActive()) { Log.d(LOGTAG, "isSleepTimerActive is true"); try { - if(null != mService) { - mService.cancelDelayedStop(FMRadioService.STOP_SERVICE); - } + mService.cancelDelayedStop(FMRadioService.STOP_SERVICE); if(null != mSleepUpdateHandlerThread) { mSleepUpdateHandlerThread.interrupt(); } - }catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } initiateSleepThread(); } - if(isRecording()) { + + if (isRecording()) { Log.d(LOGTAG,"isRecordTimerActive is true"); try { - if (null != mService) { - mService.cancelDelayedStop(FMRadioService.STOP_RECORD); - } - }catch (Exception e) { - e.printStackTrace(); + mService.cancelDelayedStop(FMRadioService.STOP_RECORD); + } catch (Exception e) { + e.printStackTrace(); } if(isRecording()) { initiateRecordThread(); } } - Log.d(LOGTAG, "FMRadio: onResume"); + + // we might lose audio focus between pause and restart, + // hence request it again + try { + mService.requestFocus(); + } catch (Exception e) { + e.printStackTrace(); + } + mStereo = FmSharedPreferences.getLastAudioMode(); mHandler.post(mUpdateProgramService); mHandler.post(mUpdateRadioText); |