diff options
author | Jake Hamby <jhamby@google.com> | 2010-09-23 19:16:28 -0700 |
---|---|---|
committer | Jake Hamby <jhamby@google.com> | 2010-09-24 14:23:26 -0700 |
commit | dd79a33ba53fec530094f4d2fe37f0538530d9f8 (patch) | |
tree | 6bb1bfbb83d08bb12701f0fd53c8bbd353688147 /src/com/android/settings/bluetooth/CachedBluetoothDevice.java | |
parent | b2fa8719a483a3ab36a8d919641714551c470bb8 (diff) | |
download | packages_apps_settings-dd79a33ba53fec530094f4d2fe37f0538530d9f8.zip packages_apps_settings-dd79a33ba53fec530094f4d2fe37f0538530d9f8.tar.gz packages_apps_settings-dd79a33ba53fec530094f4d2fe37f0538530d9f8.tar.bz2 |
Auto-connect Bluetooth device only when user initiates pairing.
Fix bug 2271901: do not auto-connect to services on a BT device
when pairing was initiated by the device (e.g. for OPP file transfer).
Also corrected some typos and removed an unneeded lock object in
LocalBluetoothManager (synchronize on .class object instead, like
android.bluetooth.BluetoothDevice.getService() does).
Change-Id: I121105c6eee2658129f6094786754bbc7932d324
Diffstat (limited to 'src/com/android/settings/bluetooth/CachedBluetoothDevice.java')
-rw-r--r-- | src/com/android/settings/bluetooth/CachedBluetoothDevice.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java index 9b16005..32f7ff3 100644 --- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java +++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java @@ -86,6 +86,8 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> // See mConnectAttempted private static final long MAX_UUID_DELAY_FOR_AUTO_CONNECT = 5000; + /** Auto-connect after pairing only if locally initiated. */ + private boolean mConnectAfterPairing; /** * Describes the current device and profile for logging. @@ -343,7 +345,10 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> if (!mDevice.createBond()) { mLocalManager.showError(mDevice, R.string.bluetooth_error_title, R.string.bluetooth_pairing_error_message); + return; } + + mConnectAfterPairing = true; // auto-connect after pairing } public void unpair() { @@ -589,9 +594,19 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> public void onBondingStateChanged(int bondState) { if (bondState == BluetoothDevice.BOND_NONE) { mProfiles.clear(); + mConnectAfterPairing = false; // cancel auto-connect } refresh(); + + if (bondState == BluetoothDevice.BOND_BONDED) { + if (mDevice.isBluetoothDock()) { + onBondingDockConnect(); + } else if (mConnectAfterPairing) { + connect(); + } + mConnectAfterPairing = false; + } } public void setBtClass(BluetoothClass btClass) { |