summaryrefslogtreecommitdiffstats
path: root/media/java/android
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2010-03-09 09:26:08 -0800
committerJean-Michel Trivi <jmtrivi@google.com>2010-03-09 12:45:55 -0800
commit758559e6b7e310cf46cc269437f44decd58d68d6 (patch)
tree33b262fca683199cfcf6da3ab44c5d738731dced /media/java/android
parenta9fb0a2497e563c2066e10a816ff1f7baaf8aa9b (diff)
downloadframeworks_base-758559e6b7e310cf46cc269437f44decd58d68d6.zip
frameworks_base-758559e6b7e310cf46cc269437f44decd58d68d6.tar.gz
frameworks_base-758559e6b7e310cf46cc269437f44decd58d68d6.tar.bz2
Fix bug 2329540
Part 1 of the fix: when the user doesn't elect to use the car dock for music and media, the APM was not aware of the device being docked. This is fixed by dissociating the notification for the APM of the docking to the dock from the sink state change of the A2DP device. Also missing was forcing the volumes to be reevaluated whenever the device is docked or undocked, as volumes for docks may differ, even when the same output device is being used. Change-Id: If5314e27821a71adbd6df6fdf887c45208241d96
Diffstat (limited to 'media/java/android')
-rw-r--r--media/java/android/media/AudioService.java47
1 files changed, 18 insertions, 29 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index e586869..618f239 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);