Merge "FM: Fix the issue of FM show Chinese string"
diff --git a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java b/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
index 4ca4645..fc0fc21 100644
--- a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
+++ b/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
@@ -93,6 +93,7 @@
     private int clientPid = -1;
     private String clientProcessName = "";
     private BroadcastReceiver mSdcardUnmountReceiver = null;
+    private String mAudioType = "audio/*";
 
     public void onCreate() {
 
@@ -271,6 +272,7 @@
              mRecorder.setAudioSource(MediaRecorder.AudioSource.FM_RX);
              mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
              mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
+             mAudioType = "audio/3gpp";
         } catch (RuntimeException exception) {
              Log.d(TAG, "RuntimeException while settings");
              mRecorder.reset();
@@ -404,7 +406,7 @@
         cv.put(MediaStore.Audio.Media.DATA, file.getAbsolutePath());
         cv.put(MediaStore.Audio.Media.DATE_ADDED, (int) (current / 1000));
         cv.put(MediaStore.Audio.Media.DATE_MODIFIED, (int) (modDate / 1000));
-        cv.put(MediaStore.Audio.Media.MIME_TYPE, "AUDIO_AAC_MP4");
+        cv.put(MediaStore.Audio.Media.MIME_TYPE, mAudioType);
         cv.put(MediaStore.Audio.Media.ARTIST,
                 res.getString(R.string.audio_db_artist_name));
         cv.put(MediaStore.Audio.Media.ALBUM,
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index ddb556a..b23aac1 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -359,6 +359,7 @@
                             Log.d(LOGTAG, "A2DP device is dis-connected!");
                             mA2dpDisconnected = true;
                         } else {
+                            Log.d(LOGTAG, "A2DP device is connected!");
                             mA2dpDisconnected = false;
                         }
                         if (isAnalogModeEnabled()) {
@@ -371,8 +372,8 @@
                        // will take care of audio routing
                        if( (isFmOn()) &&
                            (true == ((bA2dpConnected)^(mOverA2DP))) &&
-                           (false == mStoppedOnFocusLoss) &&
-                           (!isSpeakerEnabled())) {
+                           (false == mStoppedOnFocusLoss)) {
+                           Log.d(LOGTAG, "stopping and starting FM\n");
                            stopFM();
                            startFM();
                        }
@@ -759,7 +760,7 @@
        mStoppedOnFocusLoss = false;
 
        if (!mA2dpDeviceSupportInHal &&  (true == mA2dpDeviceState.isDeviceAvailable()) &&
-            (!isSpeakerEnabled()) && !isAnalogModeEnabled()
+           !isAnalogModeEnabled()
             && (true == startA2dpPlayback())) {
             mOverA2DP=true;
        } else {
@@ -1071,7 +1072,13 @@
                          mSpeakerDisableHandler.postDelayed(mSpeakerDisableTask, 0);
                       }
                       if (true == mPlaybackInProgress) {
-                          fmOff();
+                          if(mMuted)
+                             unMute();
+                          stopFM();
+                      }
+                      if (mSpeakerPhoneOn) {
+                          if (isAnalogModeSupported())
+                              setAudioPath(false);
                       }
                       mStoppedOnFocusLoss = true;
                       break;