diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2014-02-26 06:54:43 -0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2014-02-26 06:54:43 -0800 |
commit | 8aebd33674634f2f1caa994a95ff95c9f592091e (patch) | |
tree | ee6adfdc58a0fe53f61e6e36a1316534bbd7e6db /src | |
parent | 52ec6f322029a7c765bcfa1576f230c748ae5aad (diff) | |
parent | 0f8a7b75e46cde7d224f3f50336852fac65bf885 (diff) | |
download | android_packages_apps_BluetoothExt-8aebd33674634f2f1caa994a95ff95c9f592091e.tar.gz android_packages_apps_BluetoothExt-8aebd33674634f2f1caa994a95ff95c9f592091e.tar.bz2 android_packages_apps_BluetoothExt-8aebd33674634f2f1caa994a95ff95c9f592091e.zip |
Merge "Bluetooth: Avoids device added to whitelist if bonding fails."
Diffstat (limited to 'src')
-rw-r--r-- | src/org/codeaurora/bluetooth/pxpservice/DeviceProperties.java | 6 | ||||
-rw-r--r-- | src/org/codeaurora/bluetooth/pxpservice/PxpMonitorService.java | 29 |
2 files changed, 27 insertions, 8 deletions
diff --git a/src/org/codeaurora/bluetooth/pxpservice/DeviceProperties.java b/src/org/codeaurora/bluetooth/pxpservice/DeviceProperties.java index 5df9025..902852b 100644 --- a/src/org/codeaurora/bluetooth/pxpservice/DeviceProperties.java +++ b/src/org/codeaurora/bluetooth/pxpservice/DeviceProperties.java @@ -63,6 +63,10 @@ public class DeviceProperties { public boolean isAlerting = false; + public boolean isPairing = false; + + public boolean PairingFail = false; + public boolean connectionState = false; public boolean AddedToWhitelist = false; @@ -92,6 +96,8 @@ public class DeviceProperties { txPowerLevel = 0; isReading = false; isAlerting = false; + isPairing = false; + PairingFail = false; connectionState = false; AddedToWhitelist = false; hasIasService = false; diff --git a/src/org/codeaurora/bluetooth/pxpservice/PxpMonitorService.java b/src/org/codeaurora/bluetooth/pxpservice/PxpMonitorService.java index 780a9b7..72a4130 100644 --- a/src/org/codeaurora/bluetooth/pxpservice/PxpMonitorService.java +++ b/src/org/codeaurora/bluetooth/pxpservice/PxpMonitorService.java @@ -171,11 +171,19 @@ public class PxpMonitorService extends Service { if (deviceProp.deviceAddress != null && address.equals(deviceProp.deviceAddress) && deviceProp.gatt != null) { + Log.e(TAG, "Trying to use an existing mBluetoothGatt for connection."); if(deviceProp.AddedToWhitelist == false) { - boolean ret_val = deviceProp.gatt.connect(); - deviceProp.connectionState = true; - deviceProp.AddedToWhitelist = true; + Log.v(TAG, "PairingFail = " + deviceProp.PairingFail); + if((deviceProp.isPairing && !deviceProp.PairingFail) || !deviceProp.isPairing ) { + boolean ret_val = deviceProp.gatt.connect(); + deviceProp.connectionState = true; + deviceProp.AddedToWhitelist = true; + } + else { + deviceProp.PairingFail = false; + deviceProp.isPairing = false; + } } broadcastUpdate(LINKLOSS_ALERT, leDevice); } @@ -403,13 +411,18 @@ public class PxpMonitorService extends Service { Log.d(TAG, "Device address " + device.getAddress() + " Previous bond state = " + prevBondState + " bond state = " + bondState); + DeviceProperties deviceProp = mHashMapDevice.get(device); + if (deviceProp == null) { + return; + } + if(bondState == BluetoothDevice.BOND_BONDING) { + deviceProp.isPairing = true; + } + if ((bondState == BluetoothDevice.BOND_NONE) && (prevBondState == BluetoothDevice.BOND_BONDING)) { + deviceProp.PairingFail = true; + } if (bondState == BluetoothDevice.BOND_BONDED) { - DeviceProperties deviceProp = mHashMapDevice.get(device); - - if (deviceProp == null) { - return; - } if (!deviceProp.startDiscoverServices) { Log.v(TAG, "bondState = BluetoothDevice.BOND_BONDED"); |