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.
Original-Change: https://android-review.googlesource.com/1770606
Merged-In: Iadec66344d88bd80170cd5441270b768cdbe0917
Change-Id: Iadec66344d88bd80170cd5441270b768cdbe0917
diff --git a/service/src/com/android/server/connectivity/PermissionMonitor.java b/service/src/com/android/server/connectivity/PermissionMonitor.java
index 56b2e6d..3b5a706 100755
--- a/service/src/com/android/server/connectivity/PermissionMonitor.java
+++ b/service/src/com/android/server/connectivity/PermissionMonitor.java
@@ -281,7 +281,14 @@
@VisibleForTesting
synchronized void updateUidsAllowedOnRestrictedNetworks(final Set<Integer> uids) {
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