Skip to content
Snippets Groups Projects
Commit 1520eea1 authored by Linux Build Service Account's avatar Linux Build Service Account
Browse files

Merge d1e63c2e on remote branch

Change-Id: I6fd8388cb1fb2c9f7c121856a8d5980e39b6d8fa
parents fabeca79 d1e63c2e
No related branches found
No related tags found
No related merge requests found
...@@ -229,6 +229,7 @@ public class FMRadioService extends Service ...@@ -229,6 +229,7 @@ public class FMRadioService extends Service
private static final int ENABLE_SLIMBUS_DATA_PORT = 1; private static final int ENABLE_SLIMBUS_DATA_PORT = 1;
private static final int DISABLE_SOFT_MUTE = 0; private static final int DISABLE_SOFT_MUTE = 0;
private static final int ENABLE_SOFT_MUTE = 1; private static final int ENABLE_SOFT_MUTE = 1;
private static final int DEFAULT_VOLUME_INDEX = 6;
private static Object mNotchFilterLock = new Object(); private static Object mNotchFilterLock = new Object();
private static Object mNotificationLock = new Object(); private static Object mNotificationLock = new Object();
...@@ -1587,28 +1588,32 @@ public class FMRadioService extends Service ...@@ -1587,28 +1588,32 @@ public class FMRadioService extends Service
return; return;
} }
switch (msg.arg1) { switch (msg.arg1) {
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS_TRANSIENT");
if (true == isFmRecordingOn())
stopRecording();
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK: case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK"); Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK");
if ((mReceiver != null) && mReceiver.isCherokeeChip() && (mPref.getBoolean("SLIMBUS_SEQ", true))) { mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
enableSlimbus(DISABLE_SLIMBUS_DATA_PORT); int mCurrentVolumeIndex =
} mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
mStoppedOnFocusLoss = true; Log.d(LOGTAG, "Current Volume Index = "+ mCurrentVolumeIndex);
/* lower fm volume only if fm audio playing above default volume index */
if (true == mPlaybackInProgress) { if (mCurrentVolumeIndex > DEFAULT_VOLUME_INDEX) {
stopFM(); setFMVolume(DEFAULT_VOLUME_INDEX);
} }
break; break;
case AudioManager.AUDIOFOCUS_LOSS: case AudioManager.AUDIOFOCUS_LOSS:
Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS mspeakerphone= " + Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS mspeakerphone= " +
mSpeakerPhoneOn); mSpeakerPhoneOn);
if (mSpeakerPhoneOn) {
if (isAnalogModeSupported())
setAudioPath(false);
}
if (mSession.isActive()) {
mSession.setActive(false);
}
//intentional fall through. //intentional fall through.
if (mReceiver.isCherokeeChip() && (mPref.getBoolean("SLIMBUS_SEQ", true))) { case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS_TRANSIENT");
if (mReceiver != null && mReceiver.isCherokeeChip() &&
(mPref.getBoolean("SLIMBUS_SEQ", true))) {
enableSlimbus(DISABLE_SLIMBUS_DATA_PORT); enableSlimbus(DISABLE_SLIMBUS_DATA_PORT);
} }
if (true == mPlaybackInProgress) { if (true == mPlaybackInProgress) {
...@@ -1618,12 +1623,7 @@ public class FMRadioService extends Service ...@@ -1618,12 +1623,7 @@ public class FMRadioService extends Service
if (true == isFmRecordingOn()) if (true == isFmRecordingOn())
stopRecording(); stopRecording();
if (mSpeakerPhoneOn) {
if (isAnalogModeSupported())
setAudioPath(false);
}
mStoppedOnFocusLoss = true; mStoppedOnFocusLoss = true;
mSession.setActive(false);
break; break;
case AudioManager.AUDIOFOCUS_GAIN: case AudioManager.AUDIOFOCUS_GAIN:
Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_GAIN mPlaybackinprogress =" + Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_GAIN mPlaybackinprogress =" +
...@@ -1637,12 +1637,20 @@ public class FMRadioService extends Service ...@@ -1637,12 +1637,20 @@ public class FMRadioService extends Service
if(false == mPlaybackInProgress) { if(false == mPlaybackInProgress) {
startFM(); startFM();
if (mReceiver.isCherokeeChip() && if (mReceiver != null && mReceiver.isCherokeeChip() &&
(mPref.getBoolean("SLIMBUS_SEQ", true))) { (mPref.getBoolean("SLIMBUS_SEQ", true))) {
enableSlimbus(ENABLE_SLIMBUS_DATA_PORT); enableSlimbus(ENABLE_SLIMBUS_DATA_PORT);
} }
} else {
/* This case usually happens, when FM volume is lowered down and Playback
* In Progress on AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK recived. Need
* to restore volume level back when AUDIOFOCUS_GAIN received
*/
setCurrentFMVolume();
} }
if (!mSession.isActive()) {
mSession.setActive(true); mSession.setActive(true);
}
break; break;
default: default:
Log.e(LOGTAG, "Unknown audio focus change code"+msg.arg1); Log.e(LOGTAG, "Unknown audio focus change code"+msg.arg1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment