Partially fix bug 2111240 Detect docking / undocking event by reporting

to the AudioPolicyManager a new forced usage AudioSystem::FOR_DOCK
which can take the FORCE_NONE, FORCE_BT_DOCK or FORCE_WIRED_ACCESSORY
values. This CL is complemented by an update of the APM to take into
account the FOR_DOCK usage.
This commit is contained in:
Jean-Michel Trivi
2009-12-07 18:40:56 -08:00
parent 6d42d80653
commit 6154412ee8
3 changed files with 16 additions and 0 deletions

View File

@ -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
};

View File

@ -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);

View File

@ -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);