Mark tm-qpr-dev-plus-aosp-without-vendor@9129937 as merged am: 3c64a02b63
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/sl4a/+/20132260
Change-Id: I513c240cf1a201df7fd5bc35c200f6f98a1af6ad
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothConnectionFacade.java b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothConnectionFacade.java
index 4bdd943..f69ec8f 100644
--- a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothConnectionFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothConnectionFacade.java
@@ -635,27 +635,34 @@
}
/**
- * Bond to a device using Out of Band Data.
+ * Bond to a device using Out of Band Data over LE transport.
*
* @param address String representation of address like "00:11:22:33:44:55"
* @param transport String "1", "2", "3" to match TRANSPORT_*
* @param c Hex String of the 16 octet confirmation
* @param r Hex String of the 16 octet randomizer
+ * @param addressType type of address provided to match BluetoothDevice#ADDRESS_TYPE_*
*/
- @Rpc(description = "Creates and Out of Band bond.")
- public void bluetoothCreateBondOutOfBand(@RpcParameter(name = "address") String address,
- @RpcParameter(name = "transport") String transport,
- @RpcParameter(name = "c") String c, @RpcParameter(name = "r") String r) {
- Log.d("bluetoothCreateBondOutOfBand(" + address + ", " + transport + "," + c + ", "
+ @Rpc(description = "Creates and Out of Band LE bond.")
+ public void bluetoothCreateLeBondOutOfBand(@RpcParameter(name = "address") String address,
+ @RpcParameter(name = "c") String c, @RpcParameter(name = "r") String r,
+ @RpcParameter(name = "addressType") @RpcDefault("1") Integer addressType) {
+ Log.d("bluetoothCreateLeBondOutOfBand(" + address + ", " + addressType + "," + c + ", "
+ r + ")");
- BluetoothDevice remoteDevice = mBluetoothAdapter.getRemoteDevice(address);
+ BluetoothDevice remoteDevice = mBluetoothAdapter.getRemoteLeDevice(address, addressType);
byte[] addressBytes = new byte[7];
int i = 0;
for (String s : address.split(":")) {
addressBytes[i] = hexStringToByteArray(s)[0];
i++;
}
- addressBytes[i] = 0x01;
+
+ // Inserts the address type if one is provided
+ if (addressType == BluetoothDevice.ADDRESS_TYPE_PUBLIC
+ || addressType == BluetoothDevice.ADDRESS_TYPE_RANDOM) {
+ addressBytes[i] = addressType.byteValue();
+ }
+
OobData p192 = null;
OobData p256 = new OobData.LeBuilder(hexStringToByteArray(c),
addressBytes, OobData.LE_DEVICE_ROLE_BOTH_PREFER_CENTRAL)
@@ -663,7 +670,7 @@
.build();
mContext.registerReceiver(new BondBroadcastReceiver(),
new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED));
- remoteDevice.createBondOutOfBand(Integer.parseInt(transport), p192, p256);
+ remoteDevice.createBondOutOfBand(BluetoothDevice.TRANSPORT_LE, p192, p256);
}
private class BondBroadcastReceiver extends BroadcastReceiver {