Merge "Restore default wired headset on FM power off" into fm.lnx.1.0-dev.1.0
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index e5471c9..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() {
@@ -1530,8 +1528,6 @@
mSpeakerDisableHandler.postDelayed(mSpeakerDisableTask, 0);
}
if (true == mPlaybackInProgress) {
- if(mMuted)
- unMute();
stopFM();
}
if (mSpeakerPhoneOn) {
@@ -2145,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" );
@@ -2396,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;
}
@@ -2416,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.