OSDN Git Service

Move A2dp State to Disconnected when BT is Turned OFF
authorAnubhav Gupta <anubhavg@codeaurora.org>
Thu, 5 Sep 2013 13:50:25 +0000 (19:20 +0530)
committertturney <tturney@google.com>
Thu, 4 Jun 2015 23:57:16 +0000 (16:57 -0700)
A2dp State gets Stuck in Connecting state If User tries to connect to
other paired device when device is already connected to one, and before
connection swap succeeds, power-cycles BT.
This change allows the state to move properly to disconnected for the
device pending connect when BT is turned off.

Change-Id: I17bc620551bf735f39327eff59102c14551bcf26

(cherry picked from commit 0ce6816d43761b838b65adbf1e636630e1047fcf)
(cherry picked from commit 51c4d0f1df682f3874915f99ef49ec5c3d9e74ed)
(cherry picked from commit 6583fca29318b3c8bc0b16d588fc939ffdde6142)

src/com/android/bluetooth/a2dp/A2dpStateMachine.java

index 19d4ebd..154a81f 100755 (executable)
@@ -144,6 +144,12 @@ final class A2dpStateMachine extends StateMachine {
     }
 
     public void doQuit() {
+        if ((mTargetDevice != null) &&
+            (getConnectionState(mTargetDevice) == BluetoothProfile.STATE_CONNECTING)) {
+            log("doQuit()- Move A2DP State to DISCONNECTED");
+            broadcastConnectionState(mTargetDevice, BluetoothProfile.STATE_DISCONNECTED,
+                                     BluetoothProfile.STATE_CONNECTING);
+        }
         quitNow();
     }