diff options
-rw-r--r-- | include/media/AudioSystem.h | 3 | ||||
-rw-r--r-- | media/java/android/media/AudioService.java | 23 | ||||
-rw-r--r-- | media/java/android/media/AudioSystem.java | 3 |
3 files changed, 24 insertions, 5 deletions
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h index 29aaa3f..c87007c 100644 --- a/include/media/AudioSystem.h +++ b/include/media/AudioSystem.h @@ -282,7 +282,8 @@ public: FORCE_BT_SCO, FORCE_BT_A2DP, FORCE_WIRED_ACCESSORY, - FORCE_BT_DOCK, + FORCE_BT_CAR_DOCK, + FORCE_BT_DESK_DOCK, NUM_FORCE_CONFIG, FORCE_DEFAULT = FORCE_NONE }; diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index b41f3e2..4a1c2a5 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -112,7 +112,7 @@ public class AudioService extends IAudioService.Stub { private boolean mMediaServerOk; /** cached value of the BT dock address to recognize undocking events */ - private static String sBtDockAddress; + private static String sBtDockAddress = ""; private SoundPool mSoundPool; private Object mSoundEffectsLock = new Object(); @@ -231,6 +231,7 @@ public class AudioService extends IAudioService.Stub { // Forced device usage for communications private int mForcedUseForComm; + /////////////////////////////////////////////////////////////////////////// // Construction /////////////////////////////////////////////////////////////////////////// @@ -1414,9 +1415,25 @@ public class AudioService extends IAudioService.Stub { (state == BluetoothA2dp.STATE_CONNECTED || state == BluetoothA2dp.STATE_PLAYING)) { if (btDevice.isBluetoothDock()) { - Log.v(TAG, "Recognized docking to BT dock"); + Log.v(TAG, "Recognized connection to BT dock"); sBtDockAddress = address; - AudioSystem.setForceUse(AudioSystem.FOR_DOCK, AudioSystem.FORCE_BT_DOCK); + 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, diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java index 9e9b259..137b919 100644 --- a/media/java/android/media/AudioSystem.java +++ b/media/java/android/media/AudioSystem.java @@ -271,7 +271,8 @@ public class AudioSystem public static final int FORCE_BT_SCO = 3; public static final int FORCE_BT_A2DP = 4; public static final int FORCE_WIRED_ACCESSORY = 5; - public static final int FORCE_BT_DOCK = 6; + public static final int FORCE_BT_CAR_DOCK = 6; + public static final int FORCE_BT_DESK_DOCK = 7; public static final int FORCE_DEFAULT = FORCE_NONE; // usage for serForceUse |