From 8fcff25c4fc2c76a64edb9efc285f8eae1b4c270 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowski Date: Thu, 28 Jul 2016 05:21:36 -0700 Subject: [PATCH 1/3] Add LE Secure Connection data parsing (1/4) Bug: 30460956 Change-Id: I8d6e721b3b04f5ca9e3e02f7f2b90487482e1b37 (cherry picked from commit 747711ce9b8d12d2454cbe3369741b8ab2979aa1) --- core/java/android/bluetooth/OobData.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/core/java/android/bluetooth/OobData.java b/core/java/android/bluetooth/OobData.java index 8e659e04d7053..f53ca94a1d5c5 100644 --- a/core/java/android/bluetooth/OobData.java +++ b/core/java/android/bluetooth/OobData.java @@ -31,6 +31,8 @@ import android.util.Log; */ public class OobData implements Parcelable { private byte[] securityManagerTk; + private byte[] leSecureConnectionsConfirmation; + private byte[] leSecureConnectionsRandom; public byte[] getSecurityManagerTk() { return securityManagerTk; @@ -45,10 +47,28 @@ public class OobData implements Parcelable { this.securityManagerTk = securityManagerTk; } + public byte[] getLeSecureConnectionsConfirmation() { + return leSecureConnectionsConfirmation; + } + + public void setLeSecureConnectionsConfirmation(byte[] leSecureConnectionsConfirmation) { + this.leSecureConnectionsConfirmation = leSecureConnectionsConfirmation; + } + + public byte[] getLeSecureConnectionsRandom() { + return leSecureConnectionsRandom; + } + + public void setLeSecureConnectionsRandom(byte[] leSecureConnectionsRandom) { + this.leSecureConnectionsRandom = leSecureConnectionsRandom; + } + public OobData() { } private OobData(Parcel in) { securityManagerTk = in.createByteArray(); + leSecureConnectionsConfirmation = in.createByteArray(); + leSecureConnectionsRandom = in.createByteArray(); } public int describeContents() { @@ -58,6 +78,8 @@ public class OobData implements Parcelable { @Override public void writeToParcel(Parcel out, int flags) { out.writeByteArray(securityManagerTk); + out.writeByteArray(leSecureConnectionsConfirmation); + out.writeByteArray(leSecureConnectionsRandom); } public static final Parcelable.Creator CREATOR From 2d0ebcf3a0cf99d3a4294caff1a5d08f73bb7933 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowski Date: Mon, 18 Jul 2016 09:18:09 -0700 Subject: [PATCH 2/3] Fix Bluetooth OOB pairing not working for unseen devices When Out Of Band info is provided, first time we learn about device is when it's state is changed to "Bonding". This currently cause this event to be discarded and pairing fails. Instead, we should add CachedDevice object for newly added device. Bug: 30188629 Change-Id: I4046bfe30e8bf32b888f608ac06d5041e2999dc9 (cherry picked from commit 3eb490f903513da26b69cf50398a711829614bff) --- .../bluetooth/BluetoothEventManager.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java index 4bcbea76f134c..a332332131012 100755 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java @@ -268,16 +268,16 @@ public final class BluetoothEventManager { if (cachedDevice == null) { Log.w(TAG, "CachedBluetoothDevice for device " + device + " not found, calling readPairedDevices()."); - if (!readPairedDevices()) { - Log.e(TAG, "Got bonding state changed for " + device + - ", but we have no record of that device."); - return; + if (readPairedDevices()) { + cachedDevice = mDeviceManager.findDevice(device); } - cachedDevice = mDeviceManager.findDevice(device); + if (cachedDevice == null) { - Log.e(TAG, "Got bonding state changed for " + device + - ", but device not added in cache."); - return; + Log.w(TAG, "Got bonding state changed for " + device + + ", but we have no record of that device."); + + cachedDevice = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, device); + dispatchDeviceAdded(cachedDevice); } } From 3e73713590f4a5868467e2b566217683f596a33c Mon Sep 17 00:00:00 2001 From: Jakub Pawlowski Date: Wed, 9 Nov 2016 16:51:09 -0800 Subject: [PATCH 3/3] BLE OOB Pairing - parse address type (5/5) When address type is not parsed, creating bond to devices not using random address is impossible. Bug: 32780409 Test: try pairing with nRF52DK using random address Change-Id: Ie6cc1f8c008d43b2acd021b47f9bbfb1f63472e8 (cherry picked from commit f465823f6d0969dc8ea2c6666b227d02d6dea25e) --- core/java/android/bluetooth/OobData.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/java/android/bluetooth/OobData.java b/core/java/android/bluetooth/OobData.java index f53ca94a1d5c5..9e87230c686e4 100644 --- a/core/java/android/bluetooth/OobData.java +++ b/core/java/android/bluetooth/OobData.java @@ -30,10 +30,24 @@ import android.util.Log; * @hide */ public class OobData implements Parcelable { + private byte[] leBluetoothDeviceAddress; private byte[] securityManagerTk; private byte[] leSecureConnectionsConfirmation; private byte[] leSecureConnectionsRandom; + public byte[] getLeBluetoothDeviceAddress() { + return leBluetoothDeviceAddress; + } + + /** + * Sets the LE Bluetooth Device Address value to be used during LE pairing. + * The value shall be 7 bytes. Please see Bluetooth CSSv6, Part A 1.16 for + * a detailed description. + */ + public void setLeBluetoothDeviceAddress(byte[] leBluetoothDeviceAddress) { + this.leBluetoothDeviceAddress = leBluetoothDeviceAddress; + } + public byte[] getSecurityManagerTk() { return securityManagerTk; } @@ -66,6 +80,7 @@ public class OobData implements Parcelable { public OobData() { } private OobData(Parcel in) { + leBluetoothDeviceAddress = in.createByteArray(); securityManagerTk = in.createByteArray(); leSecureConnectionsConfirmation = in.createByteArray(); leSecureConnectionsRandom = in.createByteArray(); @@ -77,6 +92,7 @@ public class OobData implements Parcelable { @Override public void writeToParcel(Parcel out, int flags) { + out.writeByteArray(leBluetoothDeviceAddress); out.writeByteArray(securityManagerTk); out.writeByteArray(leSecureConnectionsConfirmation); out.writeByteArray(leSecureConnectionsRandom);