summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/audioflinger/AudioPolicyManagerBase.cpp5
-rw-r--r--media/java/android/media/AudioService.java47
2 files changed, 23 insertions, 29 deletions
diff --git a/libs/audioflinger/AudioPolicyManagerBase.cpp b/libs/audioflinger/AudioPolicyManagerBase.cpp
index cfcc3ea9e2ee..2b0a6c8c55f1 100644
--- a/libs/audioflinger/AudioPolicyManagerBase.cpp
+++ b/libs/audioflinger/AudioPolicyManagerBase.cpp
@@ -344,6 +344,7 @@ void AudioPolicyManagerBase::setForceUse(AudioSystem::force_use usage, AudioSyst
{
LOGV("setForceUse() usage %d, config %d, mPhoneState %d", usage, config, mPhoneState);
+ bool forceVolumeReeval = false;
switch(usage) {
case AudioSystem::FOR_COMMUNICATION:
if (config != AudioSystem::FORCE_SPEAKER && config != AudioSystem::FORCE_BT_SCO &&
@@ -374,6 +375,7 @@ void AudioPolicyManagerBase::setForceUse(AudioSystem::force_use usage, AudioSyst
config != AudioSystem::FORCE_BT_DESK_DOCK && config != AudioSystem::FORCE_WIRED_ACCESSORY) {
LOGW("setForceUse() invalid config %d for FOR_DOCK", config);
}
+ forceVolumeReeval = true;
mForceUse[usage] = config;
break;
default:
@@ -388,6 +390,9 @@ void AudioPolicyManagerBase::setForceUse(AudioSystem::force_use usage, AudioSyst
#endif
updateDeviceForStrategy();
setOutputDevice(mHardwareOutput, newDevice);
+ if (forceVolumeReeval) {
+ applyStreamVolumes(mHardwareOutput, newDevice);
+ }
}
AudioSystem::forced_config AudioPolicyManagerBase::getForceUse(AudioSystem::force_use usage)
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index e586869d68dc..618f239653c3 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -113,9 +113,6 @@ public class AudioService extends IAudioService.Stub {
private Object mSettingsLock = new Object();
private boolean mMediaServerOk;
- /** cached value of the BT dock address to recognize undocking events */
- private static String sBtDockAddress = "";
-
private SoundPool mSoundPool;
private Object mSoundEffectsLock = new Object();
private static final int NUM_SOUNDPOOL_CHANNELS = 4;
@@ -269,6 +266,7 @@ public class AudioService extends IAudioService.Stub {
new IntentFilter(Intent.ACTION_HEADSET_PLUG);
intentFilter.addAction(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
intentFilter.addAction(BluetoothHeadset.ACTION_STATE_CHANGED);
+ intentFilter.addAction(Intent.ACTION_DOCK_EVENT);
context.registerReceiver(mReceiver, intentFilter);
}
@@ -1498,7 +1496,23 @@ public class AudioService extends IAudioService.Stub {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
- if (action.equals(BluetoothA2dp.ACTION_SINK_STATE_CHANGED)) {
+ if (action.equals(Intent.ACTION_DOCK_EVENT)) {
+ int dockState = intent.getIntExtra(Intent.EXTRA_DOCK_STATE,
+ Intent.EXTRA_DOCK_STATE_UNDOCKED);
+ int config;
+ switch (dockState) {
+ case Intent.EXTRA_DOCK_STATE_DESK:
+ config = AudioSystem.FORCE_BT_DESK_DOCK;
+ break;
+ case Intent.EXTRA_DOCK_STATE_CAR:
+ config = AudioSystem.FORCE_BT_CAR_DOCK;
+ break;
+ case Intent.EXTRA_DOCK_STATE_UNDOCKED:
+ default:
+ config = AudioSystem.FORCE_NONE;
+ }
+ AudioSystem.setForceUse(AudioSystem.FOR_DOCK, config);
+ } else if (action.equals(BluetoothA2dp.ACTION_SINK_STATE_CHANGED)) {
int state = intent.getIntExtra(BluetoothA2dp.EXTRA_SINK_STATE,
BluetoothA2dp.STATE_DISCONNECTED);
BluetoothDevice btDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
@@ -1508,10 +1522,6 @@ public class AudioService extends IAudioService.Stub {
if (isConnected &&
state != BluetoothA2dp.STATE_CONNECTED && state != BluetoothA2dp.STATE_PLAYING) {
- if (address.equals(sBtDockAddress)) {
- Log.v(TAG, "Recognized undocking from BT dock");
- AudioSystem.setForceUse(AudioSystem.FOR_DOCK, AudioSystem.FORCE_NONE);
- }
AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,
AudioSystem.DEVICE_STATE_UNAVAILABLE,
address);
@@ -1519,27 +1529,6 @@ public class AudioService extends IAudioService.Stub {
} else if (!isConnected &&
(state == BluetoothA2dp.STATE_CONNECTED ||
state == BluetoothA2dp.STATE_PLAYING)) {
- if (btDevice.isBluetoothDock()) {
- Log.v(TAG, "Recognized connection to BT dock");
- sBtDockAddress = address;
- Intent i = context.registerReceiver(null, new IntentFilter(Intent.ACTION_DOCK_EVENT));
- if (i != null) {
- int dockState = i.getIntExtra(Intent.EXTRA_DOCK_STATE, Intent.EXTRA_DOCK_STATE_UNDOCKED);
- int config;
- switch (dockState) {
- case Intent.EXTRA_DOCK_STATE_DESK:
- config = AudioSystem.FORCE_BT_DESK_DOCK;
- break;
- case Intent.EXTRA_DOCK_STATE_CAR:
- config = AudioSystem.FORCE_BT_CAR_DOCK;
- break;
- case Intent.EXTRA_DOCK_STATE_UNDOCKED:
- default:
- config = AudioSystem.FORCE_NONE;
- }
- AudioSystem.setForceUse(AudioSystem.FOR_DOCK, config);
- }
- }
AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,
AudioSystem.DEVICE_STATE_AVAILABLE,
address);