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

Commit 8da956fb authored by Himanshu Rawat's avatar Himanshu Rawat Committed by Android Build Coastguard Worker
Browse files

Match package prefix instead of complete package name

Tesla app may have different package names for internal testing and service centers

Test: mmm packages/modules/Bluetooth
Flag: EXEMPT IOP fix
Bug: 369329192
(cherry picked from https://android-review.googlesource.com/q/commit:108aa4d79ef071d38fc2e762b49b54a2c531bd63)
Merged-In: I560beee7947b699e3a63df998f5733ce558041d6
Change-Id: I560beee7947b699e3a63df998f5733ce558041d6
parent ea1a7550
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@ public class GattService extends ProfileService {

    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);
            Map.of("com.teslamotors", GATT_MTU_MAX);

    @VisibleForTesting static final int GATT_CLIENT_LIMIT_PER_APP = 32;

@@ -2150,14 +2150,19 @@ public class GattService extends ProfileService {

        // 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);
        if (packageName != null) {
            for (Map.Entry<String, Integer> entry : EARLY_MTU_EXCHANGE_PACKAGES.entrySet()) {
                if (packageName.contains(entry.getKey())) {
                    preferredMtu = entry.getValue();
                    Log.i(
                            TAG,
                            "Early MTU exchange preference ("
                                    + preferredMtu
                                    + ") requested for "
                                    + packageName);
                    break;
                }
            }
        }

        mNativeInterface.gattClientConnect(