Temporarily change uid to appId

Due to b/192431153, PermissionMonitor only apply permission to
app id which is listed in settings. Thus, temporarily change uid
to appId.

Bug: 192116643
Test: atest ConnectivityManagerTest#testUidsAllowedOnRestricted\
      Networks with system & secondary user.
Change-Id: Iadec66344d88bd80170cd5441270b768cdbe0917
This commit is contained in:
paulhu
2021-07-19 16:43:40 +08:00
parent 588a92abe4
commit 0433dd20b7

View File

@@ -281,7 +281,14 @@ public class PermissionMonitor {
@VisibleForTesting @VisibleForTesting
synchronized void updateUidsAllowedOnRestrictedNetworks(final Set<Integer> uids) { synchronized void updateUidsAllowedOnRestrictedNetworks(final Set<Integer> uids) {
mUidsAllowedOnRestrictedNetworks.clear(); mUidsAllowedOnRestrictedNetworks.clear();
mUidsAllowedOnRestrictedNetworks.addAll(uids); // This is necessary for the app id to match in isUidAllowedOnRestrictedNetworks, and will
// grant the permission to all uids associated with the app ID. This is safe even if the app
// is only installed on some users because the uid cannot match some other app this uid is
// in effect not installed and can't be run.
// TODO (b/192431153): Change appIds back to uids.
for (int uid : uids) {
mUidsAllowedOnRestrictedNetworks.add(UserHandle.getAppId(uid));
}
} }
@VisibleForTesting @VisibleForTesting