From fbb1fe1efa8459f932aed161fbcc0b5e4d52c2d5 Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Wed, 8 Oct 2014 14:12:38 -0700 Subject: [PATCH] Moving STATE_DISCONNECTED broadcast. In Telecom we were seeing a bug where we received an ACTION_CONNECTION_STATE_CHANGEDSTATE intent indicating the disconnection of a bluetooth headset. The BluetoothManager in Telecom would then query the Bluetooth service to see if there are any devices. Despite being informed that the device in use was disconnected, it still showed up as connected. To fix this, I moved the state broadcast AFTER the disconnected device is removed from the headset state machine. Looking through all other disconnect broadcasts in that file, the disconnection happens AFTER in all other cases as well. Bug: 17899941 Change-Id: Ice4b2a5b1093e04ffe4c3241a3379aba56898792 --- src/com/android/bluetooth/hfp/HeadsetStateMachine.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java index abae8f0d..3754632e 100755 --- a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +++ b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java @@ -990,8 +990,6 @@ final class HeadsetStateMachine extends StateMachine { switch (state) { case HeadsetHalConstants.CONNECTION_STATE_DISCONNECTED: if (mConnectedDevicesList.contains(device)) { - broadcastConnectionState(device, BluetoothProfile.STATE_DISCONNECTED, - BluetoothProfile.STATE_CONNECTED); processWBSEvent(0, device); /* disable WBS audio parameters */ synchronized (HeadsetStateMachine.this) { mConnectedDevicesList.remove(device); @@ -1008,6 +1006,8 @@ final class HeadsetStateMachine extends StateMachine { processMultiHFConnected(device); } } + broadcastConnectionState(device, BluetoothProfile.STATE_DISCONNECTED, + BluetoothProfile.STATE_CONNECTED); } else { Log.e(TAG, "Disconnected from unknown device: " + device); } -- 2.11.0