Promotion of fm.lnx.1.0-00014.
CRs Change ID Subject
--------------------------------------------------------------------------------------------------------------
966690 I242c63c3edd988ed4b85e631b857d0696935cb76 Update mute API usage to fix pops and consistency
967670 Ied04bd305fee393668c72b4f46f6bfaf0be49088 Do not disable FM receiver on Music Service commands
972557 I7a87f897c29b033c46e9dc3b4d9d99a0eb46e7e4 Need to update UI in onResume though fmservice not bound
Change-Id: I322574865a37750657f467f39dfcd77465d38148
CRs-Fixed: 967670, 966690, 972557
diff --git a/fmapp2/src/com/caf/fmradio/FMRadio.java b/fmapp2/src/com/caf/fmradio/FMRadio.java
index 76b961c..e7f1c51 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadio.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadio.java
@@ -496,14 +496,11 @@
Log.d(LOGTAG, "FMRadio: onResume");
super.onResume();
- if (null == mService) {
- Log.e(LOGTAG, "FM Service is not running, returning");
- return;
- }
// TODO: We should return on exception or continue?
try {
- mService.registerCallbacks(mServiceCallbacks);
+ if (mService != null)
+ mService.registerCallbacks(mServiceCallbacks);
} catch (RemoteException e) {
e.printStackTrace();
}
@@ -511,7 +508,8 @@
if (isSleepTimerActive()) {
Log.d(LOGTAG, "isSleepTimerActive is true");
try {
- mService.cancelDelayedStop(FMRadioService.STOP_SERVICE);
+ if (mService != null)
+ mService.cancelDelayedStop(FMRadioService.STOP_SERVICE);
if(null != mSleepUpdateHandlerThread) {
mSleepUpdateHandlerThread.interrupt();
}
@@ -524,7 +522,8 @@
if (isRecording()) {
Log.d(LOGTAG,"isRecordTimerActive is true");
try {
- mService.cancelDelayedStop(FMRadioService.STOP_RECORD);
+ if (mService != null)
+ mService.cancelDelayedStop(FMRadioService.STOP_RECORD);
} catch (Exception e) {
e.printStackTrace();
}
@@ -536,7 +535,8 @@
// we might lose audio focus between pause and restart,
// hence request it again
try {
- mService.requestFocus();
+ if (mService != null)
+ mService.requestFocus();
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index 6f6f257..188a068 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -283,10 +283,6 @@
cancelAlarms();
//release the audio focus listener
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
- if (isMuted()) {
- mMuted = false;
- audioManager.setStreamMute(AudioManager.STREAM_MUSIC,false);
- }
audioManager.abandonAudioFocus(mAudioFocusListener);
/* Remove the Screen On/off listener */
if (mScreenOnOffReceiver != null) {
@@ -356,6 +352,8 @@
AUDIO_SAMPLE_RATE, AUDIO_CHANNEL_CONFIG,
AUDIO_ENCODING_FORMAT, FM_RECORD_BUF_SIZE,
AudioTrack.MODE_STREAM);
+ if (mMuted)
+ mAudioTrack.setVolume(0.0f);
}
private synchronized void startRecordSink() {
@@ -722,6 +720,7 @@
}
}
+ // TODO: Check if this is needed with latest Android versions?
public void registerMusicServiceCommandReceiver() {
if (mMusicCommandListener == null) {
mMusicCommandListener = new BroadcastReceiver() {
@@ -738,21 +737,11 @@
mA2dpDisconnected = false;
return;
}
- if(isFmOn()){
- fmOff();
+ if (isFmOn()) {
+ fmOperationsOff();
if (isOrderedBroadcast()) {
abortBroadcast();
}
- try {
- /* Notify the UI/Activity, only if the service is "bound"
- by an activity and if Callbacks are registered
- */
- if((mServiceInUse) && (mCallbacks != null) ){
- mCallbacks.onDisabled();
- }
- } catch (RemoteException e) {
- e.printStackTrace();
- }
}
}
}
@@ -1539,8 +1528,6 @@
mSpeakerDisableHandler.postDelayed(mSpeakerDisableTask, 0);
}
if (true == mPlaybackInProgress) {
- if(mMuted)
- unMute();
stopFM();
}
if (mSpeakerPhoneOn) {
@@ -2154,7 +2141,6 @@
if(audioManager != null)
{
Log.d(LOGTAG, "audioManager.setFmRadioOn = false \n" );
- unMute();
stopFM();
//audioManager.setParameters("FMRadioOn=false");
Log.d(LOGTAG, "audioManager.setFmRadioOn false done \n" );
@@ -2405,7 +2391,9 @@
if (audioManager != null)
{
mMuted = true;
- audioManager.setStreamMute(AudioManager.STREAM_MUSIC,true);
+ audioManager.setParameters("fm_mute=1");
+ if (mAudioTrack != null)
+ mAudioTrack.setVolume(0.0f);
}
return bCommandSent;
}
@@ -2425,7 +2413,9 @@
if (audioManager != null)
{
mMuted = false;
- audioManager.setStreamMute(AudioManager.STREAM_MUSIC,false);
+ audioManager.setParameters("fm_mute=0");
+ if (mAudioTrack != null)
+ mAudioTrack.setVolume(1.0f);
if (mResumeAfterCall)
{
//We are unmuting FM in a voice call. Need to enable FM audio routing.