diff options
-rw-r--r-- | include/media/AudioSystem.h | 2 | ||||
-rw-r--r-- | media/java/android/media/AudioService.java | 12 | ||||
-rw-r--r-- | media/java/android/media/AudioSystem.java | 2 |
3 files changed, 16 insertions, 0 deletions
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h index bc3dd36..29aaa3f 100644 --- a/include/media/AudioSystem.h +++ b/include/media/AudioSystem.h @@ -282,6 +282,7 @@ public: FORCE_BT_SCO, FORCE_BT_A2DP, FORCE_WIRED_ACCESSORY, + FORCE_BT_DOCK, NUM_FORCE_CONFIG, FORCE_DEFAULT = FORCE_NONE }; @@ -291,6 +292,7 @@ public: FOR_COMMUNICATION, FOR_MEDIA, FOR_RECORD, + FOR_DOCK, NUM_FORCE_USE }; diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index 3b40612..b41f3e2 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -111,6 +111,9 @@ 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; @@ -1399,6 +1402,10 @@ 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); @@ -1406,6 +1413,11 @@ public class AudioService extends IAudioService.Stub { } else if (!isConnected && (state == BluetoothA2dp.STATE_CONNECTED || state == BluetoothA2dp.STATE_PLAYING)) { + if (btDevice.isBluetoothDock()) { + Log.v(TAG, "Recognized docking to BT dock"); + sBtDockAddress = address; + AudioSystem.setForceUse(AudioSystem.FOR_DOCK, AudioSystem.FORCE_BT_DOCK); + } AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, AudioSystem.DEVICE_STATE_AVAILABLE, address); diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java index 9fe5328..9e9b259 100644 --- a/media/java/android/media/AudioSystem.java +++ b/media/java/android/media/AudioSystem.java @@ -271,12 +271,14 @@ 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_DEFAULT = FORCE_NONE; // usage for serForceUse public static final int FOR_COMMUNICATION = 0; public static final int FOR_MEDIA = 1; public static final int FOR_RECORD = 2; + public static final int FOR_DOCK = 3; public static native int setDeviceConnectionState(int device, int state, String device_address); public static native int getDeviceConnectionState(int device, String device_address); |