Move NetworkPolicy from apps to UID.
For multi-user devices, switch to storing policy per-user instead of
per-app. Also watch for user added/removed broadcasts to clean up
policies and apply global restrictions.
Bug: 7121279
Change-Id: Ia7326bd0ebe0586fa4ec6d3a62f6313dc8814007
diff --git a/core/java/android/os/UserHandle.java b/core/java/android/os/UserHandle.java
index 22994ff..cc96152 100644
--- a/core/java/android/os/UserHandle.java
+++ b/core/java/android/os/UserHandle.java
@@ -87,15 +87,19 @@
/** @hide */
public static final boolean isIsolated(int uid) {
- uid = getAppId(uid);
- return uid >= Process.FIRST_ISOLATED_UID && uid <= Process.LAST_ISOLATED_UID;
+ if (uid > 0) {
+ final int appId = getAppId(uid);
+ return appId >= Process.FIRST_ISOLATED_UID && appId <= Process.LAST_ISOLATED_UID;
+ } else {
+ return false;
+ }
}
/** @hide */
public static boolean isApp(int uid) {
if (uid > 0) {
- uid = UserHandle.getAppId(uid);
- return uid >= Process.FIRST_APPLICATION_UID && uid <= Process.LAST_APPLICATION_UID;
+ final int appId = getAppId(uid);
+ return appId >= Process.FIRST_APPLICATION_UID && appId <= Process.LAST_APPLICATION_UID;
} else {
return false;
}