Merge "FM: Disable speaker option when A2DP connected"
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index 6cebdb3..02dd4ad 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -189,8 +189,6 @@
            "codeaurora.intent.action.FM.Recording.Status";
    private BroadcastReceiver mFmRecordingStatus  = null;
    private Thread mRecordServiceCheckThread = null;
-   private boolean mUnMuteOnFocusLoss = false;
-   private boolean mSpeakerOnFocusLoss = false;
    private MediaSession mSession;
    private boolean mIsSSRInProgress = false;
    private boolean mIsSSRInProgressFromActivity = false;
@@ -1062,8 +1060,6 @@
        }
        startRecordSink();
        mPlaybackInProgress = true;
-       mUnMuteOnFocusLoss = false;
-       mSpeakerOnFocusLoss = false;
    }
 
    private void stopFM(){
@@ -1147,6 +1143,12 @@
              mRecorder.setAudioSource(MediaRecorder.AudioSource.RADIO_TUNER);
              mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
              mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
+             final int samplingRate = 44100;
+             mRecorder.setAudioSamplingRate(samplingRate);
+             final int bitRate = 128000;
+             mRecorder.setAudioEncodingBitRate(bitRate);
+             final int audiochannels = 2;
+             mRecorder.setAudioChannels(audiochannels);
         } catch (RuntimeException exception) {
              mRecorder.reset();
              mRecorder.release();
@@ -1364,14 +1366,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()) {
@@ -1504,23 +1499,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");