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

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

Merge "Send preferred MTU from GattService to native GATT module" into main

parents d7540f74 7613d0c3
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -1387,13 +1387,14 @@ static void gattClientScanNative(JNIEnv* /* env */, jobject /* object */, jboole

static void gattClientConnectNative(JNIEnv* env, jobject /* object */, jint clientif,
                                    jstring address, jint addressType, jboolean isDirect,
                                    jint transport, jboolean opportunistic, jint initiating_phys) {
                                    jint transport, jboolean opportunistic, jint initiating_phys,
                                    jint preferred_mtu) {
  if (!sGattIf) {
    return;
  }

  sGattIf->client->connect(clientif, str2addr(env, address), addressType, isDirect, transport,
                           opportunistic, initiating_phys);
                           opportunistic, initiating_phys, preferred_mtu);
}

static void gattClientDisconnectNative(JNIEnv* env, jobject /* object */, jint clientIf,
@@ -2842,7 +2843,7 @@ static int register_com_android_bluetooth_gatt_(JNIEnv* env) {
           (void*)gattClientGetDeviceTypeNative},
          {"gattClientRegisterAppNative", "(JJZ)V", (void*)gattClientRegisterAppNative},
          {"gattClientUnregisterAppNative", "(I)V", (void*)gattClientUnregisterAppNative},
          {"gattClientConnectNative", "(ILjava/lang/String;IZIZI)V",
          {"gattClientConnectNative", "(ILjava/lang/String;IZIZII)V",
           (void*)gattClientConnectNative},
          {"gattClientDisconnectNative", "(ILjava/lang/String;I)V",
           (void*)gattClientDisconnectNative},
+12 −3
Original line number Diff line number Diff line
@@ -293,7 +293,8 @@ public class GattNativeInterface {
            boolean isDirect,
            int transport,
            boolean opportunistic,
            int initiatingPhys);
            int initiatingPhys,
            int preferredMtu);

    private native void gattClientDisconnectNative(int clientIf, String address, int connId);

@@ -447,9 +448,17 @@ public class GattNativeInterface {
            boolean isDirect,
            int transport,
            boolean opportunistic,
            int initiatingPhys) {
            int initiatingPhys,
            int preferredMtu) {
        gattClientConnectNative(
                clientIf, address, addressType, isDirect, transport, opportunistic, initiatingPhys);
                clientIf,
                address,
                addressType,
                isDirect,
                transport,
                opportunistic,
                initiatingPhys,
                preferredMtu);
    }

    /** Disconnect from the remote Gatt server */
+3 −1
Original line number Diff line number Diff line
@@ -2152,8 +2152,10 @@ public class GattService extends ProfileService {
                clientIf,
                BluetoothProtoEnums.CONNECTION_STATE_CONNECTING,
                -1);

        int preferredMtu = 0;
        mNativeInterface.gattClientConnect(
                clientIf, address, addressType, isDirect, transport, opportunistic, phy);
                clientIf, address, addressType, isDirect, transport, opportunistic, phy, preferredMtu);
    }

    @RequiresPermission(BLUETOOTH_CONNECT)
+1 −1
Original line number Diff line number Diff line
@@ -265,7 +265,7 @@ public class GattServiceTest {

        verify(mNativeInterface)
                .gattClientConnect(
                        clientIf, address, addressType, isDirect, transport, opportunistic, phy);
                        clientIf, address, addressType, isDirect, transport, opportunistic, phy, 0);
    }

    @Test
+7 −5
Original line number Diff line number Diff line
@@ -111,7 +111,8 @@ struct gatt_interface_t {
  void (*BTA_GATTC_Close)(tCONN_ID conn_id);
  void (*BTA_GATTC_ServiceSearchRequest)(tCONN_ID conn_id, const bluetooth::Uuid* p_srvc_uuid);
  void (*BTA_GATTC_Open)(tGATT_IF client_if, const RawAddress& remote_bda,
                         tBTM_BLE_CONN_TYPE connection_type, bool opportunistic);
                         tBTM_BLE_CONN_TYPE connection_type, bool opportunistic,
                         uint16_t preferred_mtu);
} default_gatt_interface = {
        .BTA_GATTC_CancelOpen =
                [](tGATT_IF client_if, const RawAddress& remote_bda, bool is_direct) {
@@ -138,8 +139,9 @@ struct gatt_interface_t {
                },
        .BTA_GATTC_Open =
                [](tGATT_IF client_if, const RawAddress& remote_bda,
                   tBTM_BLE_CONN_TYPE connection_type, bool opportunistic) {
                  BTA_GATTC_Open(client_if, remote_bda, connection_type, opportunistic);
                   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);
                },
};

@@ -605,14 +607,14 @@ static void btm_dm_start_gatt_discovery(const RawAddress& bd_addr) {
              "transport:{} opportunistic:{:c}",
              bd_addr, bt_transport_text(BT_TRANSPORT_LE), (kUseOpportunistic) ? 'T' : 'F');
      get_gatt_interface().BTA_GATTC_Open(bta_dm_discovery_cb.client_if, bd_addr,
                                          BTM_BLE_DIRECT_CONNECTION, kUseOpportunistic);
                                          BTM_BLE_DIRECT_CONNECTION, kUseOpportunistic, 0);
    } else {
      log::debug(
              "Opening new gatt client connection for discovery peer:{} "
              "transport:{} opportunistic:{:c}",
              bd_addr, bt_transport_text(BT_TRANSPORT_LE), (!kUseOpportunistic) ? 'T' : 'F');
      get_gatt_interface().BTA_GATTC_Open(bta_dm_discovery_cb.client_if, bd_addr,
                                          BTM_BLE_DIRECT_CONNECTION, !kUseOpportunistic);
                                          BTM_BLE_DIRECT_CONNECTION, !kUseOpportunistic, 0);
    }
  }
}
Loading