summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2015-08-14 19:38:34 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-08-14 19:38:34 +0000
commit504600bb09e51f0187d81cacb1dc2de77c6256b6 (patch)
tree7c295fd484a21618760f18b42b20ece3db4b8b34 /core
parent7df411d0cced4a849bcdca58fa3c27eb731e0862 (diff)
parent621e06a64d0a18f357a874de15a84c3ec1d64d49 (diff)
downloadframeworks_base-504600bb09e51f0187d81cacb1dc2de77c6256b6.zip
frameworks_base-504600bb09e51f0187d81cacb1dc2de77c6256b6.tar.gz
frameworks_base-504600bb09e51f0187d81cacb1dc2de77c6256b6.tar.bz2
Merge "Fix UserHandle.getAppIdFromSharedAppGid to allow system UIDs" into mnc-dev
Diffstat (limited to 'core')
-rw-r--r--core/java/android/os/UserHandle.java12
1 files changed, 6 insertions, 6 deletions
diff --git a/core/java/android/os/UserHandle.java b/core/java/android/os/UserHandle.java
index 20bcf62..bfca719 100644
--- a/core/java/android/os/UserHandle.java
+++ b/core/java/android/os/UserHandle.java
@@ -179,16 +179,16 @@ public final class UserHandle implements Parcelable {
}
/**
- * Returns the app id for a given shared app gid.
+ * Returns the app id for a given shared app gid. Returns -1 if the ID is invalid.
* @hide
*/
public static final int getAppIdFromSharedAppGid(int gid) {
- final int noUserGid = getAppId(gid);
- if (noUserGid < Process.FIRST_SHARED_APPLICATION_GID ||
- noUserGid > Process.LAST_SHARED_APPLICATION_GID) {
- throw new IllegalArgumentException(Integer.toString(gid) + " is not a shared app gid");
+ final int appId = getAppId(gid) + Process.FIRST_APPLICATION_UID
+ - Process.FIRST_SHARED_APPLICATION_GID;
+ if (appId < 0 || appId >= Process.FIRST_SHARED_APPLICATION_GID) {
+ return -1;
}
- return (noUserGid + Process.FIRST_APPLICATION_UID) - Process.FIRST_SHARED_APPLICATION_GID;
+ return appId;
}
/**