Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4e95f339 authored by Stanley Tng's avatar Stanley Tng
Browse files

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 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
parent 47815ed8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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);
}
+17 −2
Original line number Diff line number Diff line
@@ -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:
+9 −0
Original line number Diff line number Diff line
@@ -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