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
This commit is contained in:
Paul Murphy
2020-02-28 08:35:05 -08:00
parent d506a78e94
commit d3133ebf76

View File

@@ -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 {