summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Chan <mchan@android.com>2010-04-23 10:51:54 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-04-23 10:51:54 -0700
commit84a4b9e4f3b45698f45f0d254cdacebb9489bfa5 (patch)
tree019c9032dcf6609d578d5f3893a3fa8a64039dba /src
parent937dc855eb59ef3defca16bb5e546c37fabdf721 (diff)
parent0bca1653cb78693e2c892efb48b944ddad98b66d (diff)
downloadpackages_apps_Settings-84a4b9e4f3b45698f45f0d254cdacebb9489bfa5.zip
packages_apps_Settings-84a4b9e4f3b45698f45f0d254cdacebb9489bfa5.tar.gz
packages_apps_Settings-84a4b9e4f3b45698f45f0d254cdacebb9489bfa5.tar.bz2
am 0bca1653: am 6368b25c: Merge "b/2608693 Fix the problem where BT was automatically reconnecting ... after the user unpaired while docked." into froyo
Merge commit '0bca1653cb78693e2c892efb48b944ddad98b66d' into kraken * commit '0bca1653cb78693e2c892efb48b944ddad98b66d': b/2608693 Fix the problem where BT was automatically reconnecting
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/bluetooth/CachedBluetoothDevice.java42
1 files changed, 17 insertions, 25 deletions
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
index 57bffa9..acc8551 100644
--- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
+++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
@@ -95,7 +95,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
private static final long MAX_WAIT_TIME_FOR_FRAMEWORK = 25 * 1000;
private enum BluetoothCommand {
- CONNECT, DISCONNECT,
+ CONNECT, DISCONNECT, REMOVE_BOND,
}
static class BluetoothJob {
@@ -118,7 +118,9 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
StringBuilder sb = new StringBuilder();
sb.append(command.name());
sb.append(" Address:").append(cachedDevice.mDevice);
- sb.append(" Profile:").append(profile.name());
+ if (profile != null) {
+ sb.append(" Profile:").append(profile.name());
+ }
sb.append(" TimeSent:");
if (timeSent == 0) {
sb.append("not yet");
@@ -210,6 +212,12 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
case DISCONNECT:
successful = disconnectInt(job.cachedDevice, job.profile);
break;
+ case REMOVE_BOND:
+ BluetoothDevice dev = job.cachedDevice.getDevice();
+ if (dev != null) {
+ successful = dev.removeBond();
+ }
+ break;
}
if (successful) {
@@ -510,32 +518,16 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
}
public void unpair() {
- synchronized (workQueue) {
- // Remove any pending commands for this device
- boolean processNow = false;
- Iterator<BluetoothJob> it = workQueue.iterator();
- while (it.hasNext()) {
- BluetoothJob job = it.next();
- if (job.cachedDevice.mDevice.equals(this.mDevice)) {
- it.remove();
- if (job.timeSent != 0) {
- processNow = true;
- }
- }
- }
- if (processNow) {
- processCommands();
- }
- }
+ disconnect();
- switch (getBondState()) {
- case BluetoothDevice.BOND_BONDED:
- mDevice.removeBond();
- break;
+ int state = getBondState();
- case BluetoothDevice.BOND_BONDING:
+ if (state == BluetoothDevice.BOND_BONDING) {
mDevice.cancelBondProcess();
- break;
+ }
+
+ if (state != BluetoothDevice.BOND_NONE) {
+ queueCommand(new BluetoothJob(BluetoothCommand.REMOVE_BOND, this, null));
}
}