am 68c6188b: am dd79a33b: Auto-connect Bluetooth device only when user initiates pairing.

Merge commit '68c6188b91ca4034caeff7527487513c8cb012f8'

* commit '68c6188b91ca4034caeff7527487513c8cb012f8':
  Auto-connect Bluetooth device only when user initiates pairing.
This commit is contained in:
Jake Hamby
2010-09-24 17:19:24 -07:00
committed by Android Git Automerger
6 changed files with 20 additions and 15 deletions

View File

@@ -91,6 +91,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.
@@ -365,7 +367,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() {
@@ -617,9 +622,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) {