OSDN Git Service

Add function to change LE Tx Data Length
authorStanley Tng <stng@google.com>
Tue, 23 Jan 2018 01:08:03 +0000 (17:08 -0800)
committerStanley Tng <stng@google.com>
Mon, 5 Feb 2018 18:04:59 +0000 (10:04 -0800)
As part of new SL4A tests for LE CoC to measure data throughput, this
commit adds a function to modify the LE Tx Data Length parameter to its
maximum.

Test: Ran the new ACTS Tests for LE CoC; BtCocTest and BtCoc2ConnTest
Bug: 70683224
Change-Id: I06d3f95a339dcdc310a18bcf17fbca8623f849d6

binder/android/bluetooth/IBluetoothSocketManager.aidl
btif/src/btif_sock.cc
include/hardware/bt_sock.h

index d7019c3..119988e 100644 (file)
@@ -29,4 +29,5 @@ interface IBluetoothSocketManager
 {
     @nullable ParcelFileDescriptor connectSocket(in BluetoothDevice device, int type, in @nullable ParcelUuid uuid, int port, int flag);
     @nullable ParcelFileDescriptor createSocketChannel(int type, in @nullable String serviceName, in @nullable ParcelUuid uuid, int port, int flag);
+    void requestMaximumTxDataLength(in BluetoothDevice device);
 }
index 61ce0c9..90121b1 100644 (file)
@@ -34,6 +34,7 @@
 #include "btif_sock_thread.h"
 #include "btif_uid.h"
 #include "btif_util.h"
+#include "device/include/controller.h"
 #include "osi/include/thread.h"
 
 using bluetooth::Uuid;
@@ -45,14 +46,19 @@ static bt_status_t btsock_connect(const RawAddress* bd_addr, btsock_type_t type,
                                   const Uuid* uuid, int channel, int* sock_fd,
                                   int flags, int app_uid);
 
+static void btsock_request_max_tx_data_length(const RawAddress& bd_addr);
+
 static void btsock_signaled(int fd, int type, int flags, uint32_t user_id);
 
 static std::atomic_int thread_handle{-1};
 static thread_t* thread;
 
 const btsock_interface_t* btif_sock_get_interface(void) {
-  static btsock_interface_t interface = {sizeof(interface), btsock_listen,
-                                         btsock_connect};
+  static btsock_interface_t interface = {
+      sizeof(interface), btsock_listen, /* listen */
+      btsock_connect,                   /* connect */
+      btsock_request_max_tx_data_length /* request_max_tx_data_length */
+  };
 
   return &interface;
 }
@@ -210,6 +216,15 @@ static bt_status_t btsock_connect(const RawAddress* bd_addr, btsock_type_t type,
   return status;
 }
 
+static void btsock_request_max_tx_data_length(const RawAddress& remote_device) {
+  const controller_t* controller = controller_get_interface();
+  uint16_t max_len = controller->get_ble_maximum_tx_data_length();
+
+  DVLOG(2) << __func__ << ": max_len=" << max_len;
+
+  BTA_DmBleSetDataLength(remote_device, max_len);
+}
+
 static void btsock_signaled(int fd, int type, int flags, uint32_t user_id) {
   switch (type) {
     case BTSOCK_RFCOMM:
index c76ef06..04827aa 100644 (file)
@@ -75,6 +75,15 @@ typedef struct {
   bt_status_t (*connect)(const RawAddress* bd_addr, btsock_type_t type,
                          const bluetooth::Uuid* uuid, int channel, int* sock_fd,
                          int flags, int callingUid);
+
+  /**
+   * Set the LE Data Length value to this connected peer to the
+   * maximum supported by this BT controller. This command
+   * suggests to the BT controller to set its maximum transmission
+   * packet size.
+   */
+  void (*request_max_tx_data_length)(const RawAddress& bd_addr);
+
 } btsock_interface_t;
 
 __END_DECLS