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

Commit 62b8eede authored by Himanshu Rawat's avatar Himanshu Rawat Committed by Gerrit Code Review
Browse files

Merge changes I35c7aa38,I59021fc5,Ie173cc15 into main

* changes:
  Reducing Gatt_Connect overloads
  Skip ATT Read Blob request for name discovery before MTU exchange
  Add ATT MTU preference for Tesla app
parents b91e98cf 4e41e7ca
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -143,6 +143,10 @@ public class GattService extends ProfileService {
                "0201061AFF4C000215426C7565436861726D426561636F6E730EFE1355C509168020691E0EFE13551109426C7565436861726D5F31363936383500000000",
            };

    private static final Integer GATT_MTU_MAX = 517;
    private static final Map<String, Integer> EARLY_MTU_EXCHANGE_PACKAGES =
            Map.of("com.teslamotors.tesla", GATT_MTU_MAX);

    @VisibleForTesting static final int GATT_CLIENT_LIMIT_PER_APP = 32;

    public final TransitionalScanHelper mTransitionalScanHelper =
@@ -2154,6 +2158,19 @@ public class GattService extends ProfileService {
                -1);

        int preferredMtu = 0;

        // Some applications expect MTU to be exchanged immediately on connections
        String packageName = attributionSource.getPackageName();
        if (packageName != null && EARLY_MTU_EXCHANGE_PACKAGES.containsKey(packageName)) {
            preferredMtu = EARLY_MTU_EXCHANGE_PACKAGES.get(packageName);
            Log.i(
                    TAG,
                    "Early MTU exchange preference ("
                            + preferredMtu
                            + ") requested for "
                            + packageName);
        }

        mNativeInterface.gattClientConnect(
                clientIf, address, addressType, isDirect, transport, opportunistic, phy, preferredMtu);
    }
+1 −1
Original line number Diff line number Diff line
@@ -141,7 +141,7 @@ struct gatt_interface_t {
                [](tGATT_IF client_if, const RawAddress& remote_bda,
                   tBTM_BLE_CONN_TYPE connection_type, bool opportunistic, uint16_t preferred_mtu) {
                  BTA_GATTC_Open(client_if, remote_bda, BLE_ADDR_PUBLIC, connection_type,
                                 BT_TRANSPORT_LE, opportunistic, 1, preferred_mtu);
                                 BT_TRANSPORT_LE, opportunistic, LE_PHY_1M, preferred_mtu);
                },
};

+1 −1
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ gatt_interface_t default_gatt_interface = {
                          ADDRESS_TO_LOGGABLE_CSTR(remote_bda), client_if, connection_type,
                          (opportunistic) ? 'T' : 'F'));
                  BTA_GATTC_Open(client_if, remote_bda, BLE_ADDR_PUBLIC, connection_type,
                                 BT_TRANSPORT_LE, opportunistic, 1, preferred_mtu);
                                 BT_TRANSPORT_LE, opportunistic, LE_PHY_1M, preferred_mtu);
                },
};

+1 −1
Original line number Diff line number Diff line
@@ -485,7 +485,7 @@ static void bta_gattc_init_bk_conn(const tBTA_GATTC_API_OPEN* p_data, tBTA_GATTC

  /* always call open to hold a connection */
  if (!GATT_Connect(p_data->client_if, p_data->remote_bda, BLE_ADDR_PUBLIC, p_data->connection_type,
                    p_data->transport, false, 1, p_data->preferred_mtu)) {
                    p_data->transport, false, LE_PHY_1M, p_data->preferred_mtu)) {
    log::error("Unable to connect to remote bd_addr={}", p_data->remote_bda);
    bta_gattc_send_open_cback(p_clreg, GATT_ILLEGAL_PARAMETER, p_data->remote_bda,
                              GATT_INVALID_CONN_ID, BT_TRANSPORT_LE, 0);
+2 −17
Original line number Diff line number Diff line
@@ -133,13 +133,6 @@ void BTA_GATTC_AppDeregister(tGATT_IF client_if) {
 *                  opportunistic, and don't impact the disconnection timer
 *
 ******************************************************************************/
void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda,
                    tBTM_BLE_CONN_TYPE connection_type, bool opportunistic) {
  constexpr uint8_t kPhyLe1M = 0x01;  // From the old controller shim.
  uint8_t phy = kPhyLe1M;
  BTA_GATTC_Open(client_if, remote_bda, connection_type, BT_TRANSPORT_LE, opportunistic, phy);
}

void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda, tBLE_ADDR_TYPE addr_type,
                    tBTM_BLE_CONN_TYPE connection_type, tBT_TRANSPORT transport, bool opportunistic,
                    uint8_t initiating_phys, uint16_t preferred_mtu) {
@@ -164,18 +157,10 @@ void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda, tBLE_ADDR_
  post_on_bt_main([data]() { bta_gattc_process_api_open(&data); });
}

void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda, tBLE_ADDR_TYPE addr_type,
                    tBTM_BLE_CONN_TYPE connection_type, tBT_TRANSPORT transport, bool opportunistic,
                    uint8_t initiating_phys) {
  BTA_GATTC_Open(client_if, remote_bda, addr_type, connection_type, transport, opportunistic,
                 initiating_phys, 0);
}

void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda,
                    tBTM_BLE_CONN_TYPE connection_type, tBT_TRANSPORT transport, bool opportunistic,
                    uint8_t initiating_phys) {
                    tBTM_BLE_CONN_TYPE connection_type, bool opportunistic) {
  BTA_GATTC_Open(client_if, remote_bda, BLE_ADDR_PUBLIC, connection_type, BT_TRANSPORT_LE,
                 opportunistic, initiating_phys);
                 opportunistic, LE_PHY_1M, 0);
}

/*******************************************************************************
Loading