Merge tag 'android-13.0.0_r52' into int/13/fp3
Android 13.0.0 Release 52 (TQ3A.230605.012)
* tag 'android-13.0.0_r52':
Make createBondOutOfBand pass its return value
Adds an sl4a event on socket connection state and allows for specifying a BluetoothDevice object address when bonding OOB
Change-Id: Ie7d5dbf7edc3b4bbdd6c31155a82748722b917a0
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 8e54d81..33a667e 100644
--- a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothConnectionFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothConnectionFacade.java
@@ -635,32 +635,39 @@
}
/**
- * Bond to a device using Out of Band Data over LE transport.
+ * Bond to a device using Out of Band Data over LE transport. Note that there is a distinction
+ * between the address with type supplied in the oob data and the address and type of the
+ * BluetoothDevice object.
*
- * @param address String representation of address like "00:11:22:33:44:55"
+ * @param oobDataAddress is the MAC address to be used in the oob data
+ * @param oobDataAddressType is the BluetoothDevice.AddressType for the oob data MAC address
* @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_*
+ * @param address String representation of MAC address for the BluetoothDevice object
+ * @param addressType the BluetoothDevice.AddressType for the BluetoothDevice object
*/
@Rpc(description = "Creates and Out of Band LE bond.")
- public void bluetoothCreateLeBondOutOfBand(@RpcParameter(name = "address") String address,
+ public boolean bluetoothCreateLeBondOutOfBand(
+ @RpcParameter(name = "oobDataAddress") String oobDataAddress,
+ @RpcParameter(name = "oobDataAddressType") Integer oobDataAddressType,
@RpcParameter(name = "c") String c, @RpcParameter(name = "r") String r,
+ @RpcParameter(name = "address") String address,
@RpcParameter(name = "addressType") @RpcDefault("1") Integer addressType) {
Log.d("bluetoothCreateLeBondOutOfBand(" + address + ", " + addressType + "," + c + ", "
+ r + ")");
BluetoothDevice remoteDevice = mBluetoothAdapter.getRemoteLeDevice(address, addressType);
byte[] addressBytes = new byte[7];
int i = 0;
- for (String s : address.split(":")) {
+ for (String s : oobDataAddress.split(":")) {
addressBytes[i] = hexStringToByteArray(s)[0];
i++;
}
- // Inserts the address type if one is provided
- if (addressType == BluetoothDevice.ADDRESS_TYPE_PUBLIC
- || addressType == BluetoothDevice.ADDRESS_TYPE_RANDOM) {
- addressBytes[i] = addressType.byteValue();
+ // Inserts the oob address type if one is provided
+ if (oobDataAddressType == BluetoothDevice.ADDRESS_TYPE_PUBLIC
+ || oobDataAddressType == BluetoothDevice.ADDRESS_TYPE_RANDOM) {
+ addressBytes[i] = oobDataAddressType.byteValue();
}
OobData p192 = null;
@@ -670,7 +677,7 @@
.build();
mContext.registerReceiver(new BondBroadcastReceiver(),
new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED));
- remoteDevice.createBondOutOfBand(BluetoothDevice.TRANSPORT_LE, p192, p256);
+ return remoteDevice.createBondOutOfBand(BluetoothDevice.TRANSPORT_LE, p192, p256);
}
private class BondBroadcastReceiver extends BroadcastReceiver {
diff --git a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothSocketConnFacade.java b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothSocketConnFacade.java
index 18ca858..49efe6c 100644
--- a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothSocketConnFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothSocketConnFacade.java
@@ -21,6 +21,7 @@
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;
+import android.os.Bundle;
import com.googlecode.android_scripting.Log;
import com.googlecode.android_scripting.facade.EventFacade;
@@ -55,6 +56,9 @@
private AcceptThread mAcceptThread;
private byte mTxPktIndex = 0;
+ private final Bundle mGoodNews;
+ private final Bundle mBadNews;
+
private static final String DEFAULT_PSM = "161"; //=0x00A1
// UUID for SL4A.
@@ -68,6 +72,11 @@
mEventFacade = manager.getReceiver(EventFacade.class);
mService = manager.getService();
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+
+ mGoodNews = new Bundle();
+ mGoodNews.putBoolean("Status", true);
+ mBadNews = new Bundle();
+ mBadNews.putBoolean("Status", false);
}
private BluetoothConnection getConnection(String connID) throws IOException {
@@ -731,9 +740,15 @@
mConnUuid = addConnection(conn);
Log.d("ConnectThread:run: isConnected=" + mSocket.isConnected() + ", address="
+ mSocket.getRemoteDevice().getAddress() + ", uuid=" + mConnUuid);
+ if (mSocket.isConnected()) {
+ mEventFacade.postEvent("BluetoothSocketConnectSuccess", mGoodNews);
+ } else {
+ mEventFacade.postEvent("BluetoothSocketConnectError", mBadNews);
+ }
} catch (IOException connectException) {
Log.e("ConnectThread::run(): Error: Connection Unsuccessful");
cancel();
+ mEventFacade.postEvent("BluetoothSocketConnectError", mBadNews);
return;
}
}