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

Commit d3133ebf authored by Paul Murphy's avatar Paul Murphy
Browse files

CDM isDeviceAssociatedForWifiConnection returns false if no devices associated

The expectation is that when a caller holds COMPANION_APPROVE_WIFI_CONNECTIONS permisison,
isDeviceAssociatedForWifiConnection should always return true. In the
previous case, at least one device had to exist for this to be the case.

Bug: b/150459257
Test: A CTS test is what discovered the bug, and will be checked in
alongside this change.

Change-Id: If0a4dd427ebd437d7cd29810a26301b581ee3c75
parent d506a78e
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -369,10 +369,13 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
            boolean bypassMacPermission = getContext().getPackageManager().checkPermission(
                    android.Manifest.permission.COMPANION_APPROVE_WIFI_CONNECTIONS, packageName)
                    == PackageManager.PERMISSION_GRANTED;
            if (bypassMacPermission) {
                return true;
            }

            return CollectionUtils.any(
                    readAllAssociations(userId, packageName),
                    a -> bypassMacPermission || Objects.equals(a.deviceAddress, macAddress));
                    a -> Objects.equals(a.deviceAddress, macAddress));
        }

        private void checkCanCallNotificationApi(String callingPackage) throws RemoteException {