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

Commit 5ef6e310 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/29740200',...

Merge cherrypicks of ['googleplex-android-review.googlesource.com/29740200', 'googleplex-android-review.googlesource.com/29740201', 'googleplex-android-review.googlesource.com/29741666', 'googleplex-android-review.googlesource.com/29740901'] into 24Q4-release.

Change-Id: I42e4c78715dd6322edd66ccfffaf00c3712c678b
parents 6c3e7860 75125a6b
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -1384,13 +1384,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,
@@ -2839,7 +2840,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 */
+25 −1
Original line number Diff line number Diff line
@@ -142,6 +142,15 @@ public class GattService extends ProfileService {
                "0201061AFF4C000215426C7565436861726D426561636F6E730EFE1355C509168020691E0EFE13551109426C7565436861726D5F31363936383500000000",
            };

<<<<<<< HEAD   (9f43bf Send preferred MTU from GattService to native GATT module)
=======
    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;

>>>>>>> CHANGE (ea9b83 Add ATT MTU preference for Tesla app)
    public final TransitionalScanHelper mTransitionalScanHelper =
            new TransitionalScanHelper(this, this::isTestModeEnabled);

@@ -2139,8 +2148,23 @@ public class GattService extends ProfileService {
                clientIf,
                BluetoothProtoEnums.CONNECTION_STATE_CONNECTING,
                -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);
                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
@@ -108,7 +108,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) {
@@ -135,8 +136,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, LE_PHY_1M, preferred_mtu);
                },
};

@@ -602,14 +604,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