Fix handling of SINK_STATE_CHANGE while suspend / resuming.
Update state only for the device which is connected.
We will hit this issue more often with car docks.
Bug:2133530
Dr No:Eastham
diff --git a/src/com/android/phone/BluetoothHandsfree.java b/src/com/android/phone/BluetoothHandsfree.java
index 9a89984..f0c6dc6 100644
--- a/src/com/android/phone/BluetoothHandsfree.java
+++ b/src/com/android/phone/BluetoothHandsfree.java
@@ -552,9 +552,18 @@
BluetoothA2dp.STATE_DISCONNECTED);
BluetoothDevice device =
intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+
+ // We are only concerned about Connected sinks to suspend and resume
+ // them. We can safely ignore SINK_STATE_CHANGE for other devices.
+ if (mA2dpDevice != null && !device.equals(mA2dpDevice)) return;
+
synchronized (BluetoothHandsfree.this) {
mA2dpState = state;
- mA2dpDevice = device;
+ if (state == BluetoothA2dp.STATE_DISCONNECTED) {
+ mA2dpDevice = null;
+ } else {
+ mA2dpDevice = device;
+ }
if (oldState == BluetoothA2dp.STATE_PLAYING &&
mA2dpState == BluetoothA2dp.STATE_CONNECTED) {
if (mA2dpSuspended) {