diff options
author | Stanley Tng <stng@google.com> | 2018-01-16 10:39:32 -0800 |
---|---|---|
committer | Stanley Tng <stng@google.com> | 2018-02-04 15:55:39 -0800 |
commit | cf3cfd339a2635b0ccd94ad9a3eaa7229a8f3d54 (patch) | |
tree | 2273bde9a49a8c935dfc2d47515b53f283ea50a8 /framework/java/android/bluetooth/BluetoothSocket.java | |
parent | 65be80345d2c5a8812a9a196889cac5d209706a9 (diff) |
Add function to change LE Tx Data Length
As part of new SL4A tests for LE CoC to measure data throughput, this
commit adds a function to set the LE Tx Data Length parameter to its
maximum.
Test: Ran the new ACTS Tests for LE CoC (BleCocTest and BleCoc2ConnTest)
Bug: 70683224
Change-Id: Iea93f6cb9f4f7cc484f121afa158d7dae18d1ef1
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothSocket.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothSocket.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothSocket.java b/framework/java/android/bluetooth/BluetoothSocket.java index 09f96840f9..09a5b593e5 100644 --- a/framework/java/android/bluetooth/BluetoothSocket.java +++ b/framework/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]); |