Merge "FM: Fix the FM recording stopped when AUDIOFOCUS_LOSS_TRANSIENT received"
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index 1f2f60f..5dd1e7b 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -1180,11 +1180,26 @@
               switch (msg.arg1) {
                   case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
                       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);
+                      }
+                      if (true == mPlaybackInProgress) {
+                          if(mMuted)
+                             unMute();
+                          stopFM();
+                      }
+                      if (mSpeakerPhoneOn) {
+                          if (isAnalogModeSupported())
+                              setAudioPath(false);
+                      }
+                      mStoppedOnFocusLoss = true;
+                      break;
                   case AudioManager.AUDIOFOCUS_LOSS:
                       Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS");
                       //intentional fall through.
-                  case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
-                      Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS_TRANSIENT");
                       if (true == isFmRecordingOn())
                           stopRecording();
                       if (mSpeakerPhoneOn) {