FM: Fix the issue with AUDIOFOCUS_LOSS_TRANSIENT

Stop the FM audio and retain the mute status and speaker status.

Change-Id: Iefcde4df34b484da6d48798703d66a1bb42c9b51
CRs-Fixed: 901852
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index b35b3f4..4066b9d 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -191,8 +191,6 @@
    static final int RECORD_START = 1;
    static final int RECORD_STOP = 0;
    private Thread mRecordServiceCheckThread = null;
-   private boolean mUnMuteOnFocusLoss = false;
-   private boolean mSpeakerOnFocusLoss = false;
    private MediaSession mSession;
    private boolean mIsSSRInProgress = false;
    private boolean mIsSSRInProgressFromActivity = false;
@@ -1075,8 +1073,6 @@
        }
        startRecordSink();
        mPlaybackInProgress = true;
-       mUnMuteOnFocusLoss = false;
-       mSpeakerOnFocusLoss = false;
    }
 
    private void stopFM(){
@@ -1367,14 +1363,7 @@
 
        if((TelephonyManager.CALL_STATE_OFFHOOK == state)||
           (TelephonyManager.CALL_STATE_RINGING == state)) {
-           boolean bTempSpeaker = (mSpeakerPhoneOn | mSpeakerOnFocusLoss) ; //need to restore SpeakerPhone
-           if (mUnMuteOnFocusLoss) {
-               if (audioManager != null) {
-                   Log.d(LOGTAG, "Mute");
-                   mMuted = true;
-                   audioManager.setStreamMute(AudioManager.STREAM_MUSIC,true);
-               }
-           }
+           boolean bTempSpeaker = mSpeakerPhoneOn ; //need to restore SpeakerPhone
            boolean bTempMute = mMuted;// need to restore Mute status
            int bTempCall = mCallStatus;//need to restore call status
            if (isFmOn() && fmOff()) {
@@ -1507,23 +1496,10 @@
                       Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK");
                   case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
                       Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS_TRANSIENT");
-                      if (mSpeakerPhoneOn) {
-                         mSpeakerDisableHandler.removeCallbacks(mSpeakerDisableTask);
-                         mSpeakerDisableHandler.postDelayed(mSpeakerDisableTask, 0);
-                         mSpeakerOnFocusLoss = true;
-                      }
                       if (true == mPlaybackInProgress) {
-                          if(mMuted) {
-                             unMute();
-                             mUnMuteOnFocusLoss = true;
-                          }
                           stopFM();
+                          mStoppedOnFocusLoss = true;
                       }
-                      if (mSpeakerPhoneOn) {
-                          if (isAnalogModeSupported())
-                              setAudioPath(false);
-                      }
-                      mStoppedOnFocusLoss = true;
                       break;
                   case AudioManager.AUDIOFOCUS_LOSS:
                       Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS");