diff options
author | Jaikumar Ganesh <jaikumar@google.com> | 2009-09-20 12:56:21 -0700 |
---|---|---|
committer | Jaikumar Ganesh <jaikumar@google.com> | 2009-09-20 16:16:08 -0700 |
commit | 2092361d586a20190c9137fb3cc9434cdc9ec99f (patch) | |
tree | 92ceea0c02c100435a95d9a01fad0f34ba4f4824 /core/java/android/server/BluetoothService.java | |
parent | cc7f40a88d64cbb4e664e231668ae4e2862036c6 (diff) | |
download | frameworks_base-2092361d586a20190c9137fb3cc9434cdc9ec99f.zip frameworks_base-2092361d586a20190c9137fb3cc9434cdc9ec99f.tar.gz frameworks_base-2092361d586a20190c9137fb3cc9434cdc9ec99f.tar.bz2 |
Maintain pending outgoing bonding address.
This helps us to distinguish between incoming and outgoing Bonding requests.
Change-Id: I69e6a269b7dd6aad60e6f5711cad812291a7d313
Diffstat (limited to 'core/java/android/server/BluetoothService.java')
-rw-r--r-- | core/java/android/server/BluetoothService.java | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java index ce62f07..7df9141 100644 --- a/core/java/android/server/BluetoothService.java +++ b/core/java/android/server/BluetoothService.java @@ -427,6 +427,18 @@ public class BluetoothService extends IBluetooth.Stub { new ArrayList<String>(Arrays.asList( "Motorola IHF1000", "i.TechBlueBAND", "X5 Stereo v1.3")); + // If this is an outgoing connection, store the address. + // There can be only 1 pending outgoing connection at a time, + private String mPendingOutgoingBonding; + + private synchronized void setPendingOutgoingBonding(String address) { + mPendingOutgoingBonding = address; + } + + public synchronized String getPendingOutgoingBonding() { + return mPendingOutgoingBonding; + } + public synchronized void loadBondState() { if (mBluetoothState != BluetoothAdapter.STATE_TURNING_ON) { return; @@ -457,6 +469,15 @@ public class BluetoothService extends IBluetooth.Stub { if (oldState == state) { return; } + + // Check if this was an pending outgoing bonding. + // If yes, reset the state. + if (oldState == BluetoothDevice.BOND_BONDING) { + if (address.equals(mPendingOutgoingBonding)) { + mPendingOutgoingBonding = null; + } + } + if (DBG) log(address + " bond state " + oldState + " -> " + state + " (" + reason + ")"); Intent intent = new Intent(BluetoothDevice.ACTION_BOND_STATE_CHANGED); @@ -779,8 +800,7 @@ public class BluetoothService extends IBluetooth.Stub { } address = address.toUpperCase(); - String[] bonding = mBondState.listInState(BluetoothDevice.BOND_BONDING); - if (bonding.length > 0 && !bonding[0].equals(address)) { + if (mBondState.getPendingOutgoingBonding() != null) { log("Ignoring createBond(): another device is bonding"); // a different device is currently bonding, fail return false; @@ -798,7 +818,9 @@ public class BluetoothService extends IBluetooth.Stub { return false; } + mBondState.setPendingOutgoingBonding(address); mBondState.setBondState(address, BluetoothDevice.BOND_BONDING); + return true; } |