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

Commit 8377f912 authored by Evan Chen's avatar Evan Chen
Browse files

Need to check isManagedByCompanionApp before calling getMacAddress()

Since AssociationInfo.getIdOfType() might return null,
we need to to check !Association.isManagedByCompanionApp
before calling getMacAddress()

Test: cts verifier
bug: 198539218
Change-Id: Idd2e6940aea511adc08804ab4c23ea199584808d
parent a74fd755
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -775,6 +775,7 @@ public class CompanionDeviceManagerService extends SystemService {

        exemptFromAutoRevoke(packageInfo.packageName, packageInfo.applicationInfo.uid);

        if (!association.isManagedByCompanionApp()) {
            if (mCurrentlyConnectedDevices.contains(association.getDeviceMacAddress())) {
                grantDeviceProfile(association);
            }
@@ -783,6 +784,7 @@ public class CompanionDeviceManagerService extends SystemService {
                restartBleScan();
            }
        }
    }

    private void exemptFromAutoRevoke(String packageName, int uid) {
        try {
@@ -1213,6 +1215,9 @@ public class CompanionDeviceManagerService extends SystemService {
        ArrayList<ScanFilter> result = new ArrayList<>();
        ArraySet<String> addressesSeen = new ArraySet<>();
        for (AssociationInfo association : getAllAssociations()) {
            if (association.isManagedByCompanionApp()) {
                continue;
            }
            String address = association.getDeviceMacAddress();
            if (addressesSeen.contains(address)) {
                continue;