From 1308453b16c2ca85a456bd4bb7f3c71c916bd83e Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Mon, 3 May 2010 23:05:06 -0700 Subject: b/2652059 Fixed the broken BT connects/disconnects after unpair The unpair command was stuck in the queue. Change-Id: I803cb10adcfaedbe6fd202e0db463593880e4280 --- .../settings/bluetooth/CachedBluetoothDevice.java | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src') diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java index acc8551..c724c33 100644 --- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java +++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java @@ -749,7 +749,33 @@ public class CachedBluetoothDevice implements Comparable public void onBondingStateChanged(int bondState) { if (bondState == BluetoothDevice.BOND_NONE) { mProfiles.clear(); + + BluetoothJob job = workQueue.peek(); + if (job == null) { + return; + } + + // Remove the first item and process the next one + if (job.command == BluetoothCommand.REMOVE_BOND + && job.cachedDevice.mDevice.equals(mDevice)) { + workQueue.poll(); // dequeue + } else { + // Unexpected job + if (D) { + Log.d(TAG, "job.command = " + job.command); + Log.d(TAG, "mDevice:" + mDevice + " != head:" + job.toString()); + } + + // Check to see if we need to remove the stale items from the queue + if (!pruneQueue(null)) { + // nothing in the queue was modify. Just ignore the notification and return. + return; + } + } + + processCommands(); } + refresh(); } -- cgit v1.1