summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Stanley Tng <stng@google.com> 2018-02-06 01:02:33 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2018-02-06 01:02:33 +0000
commit383a7d432fa0bd8b638700e424b26b9f30a5d4b3 (patch)
tree4f6631c5dc1d48cf14d0ecb1819a31f4e1ed1b5c
parentde65acb9159c5c98940e7f01e27f8a49bc0536ce (diff)
parent918c5241c00ea937ec2ed1681bc190c4a0e53f3c (diff)
Merge "Add function to change LE Tx Data Length"
-rw-r--r--core/java/android/bluetooth/BluetoothSocket.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/core/java/android/bluetooth/BluetoothSocket.java b/core/java/android/bluetooth/BluetoothSocket.java
index 09f96840f918..09a5b593e521 100644
--- a/core/java/android/bluetooth/BluetoothSocket.java
+++ b/core/java/android/bluetooth/BluetoothSocket.java
@@ -676,6 +676,35 @@ public final class BluetoothSocket implements Closeable {
mExcludeSdp = excludeSdp;
}
+ /**
+ * Set the LE Transmit Data Length to be the maximum that the BT Controller is capable of. This
+ * parameter is used by the BT Controller to set the maximum transmission packet size on this
+ * connection. This function is currently used for testing only.
+ * @hide
+ */
+ public void requestMaximumTxDataLength() throws IOException {
+ if (mDevice == null) {
+ throw new IOException("requestMaximumTxDataLength is called on null device");
+ }
+
+ try {
+ if (mSocketState == SocketState.CLOSED) {
+ throw new IOException("socket closed");
+ }
+ IBluetooth bluetoothProxy =
+ BluetoothAdapter.getDefaultAdapter().getBluetoothService(null);
+ if (bluetoothProxy == null) {
+ throw new IOException("Bluetooth is off");
+ }
+
+ if (DBG) Log.d(TAG, "requestMaximumTxDataLength");
+ bluetoothProxy.getSocketManager().requestMaximumTxDataLength(mDevice);
+ } catch (RemoteException e) {
+ Log.e(TAG, Log.getStackTraceString(new Throwable()));
+ throw new IOException("unable to send RPC: " + e.getMessage());
+ }
+ }
+
private String convertAddr(final byte[] addr) {
return String.format(Locale.US, "%02X:%02X:%02X:%02X:%02X:%02X",
addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);