summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2015-08-13 22:06:31 -0700
committerAdam Lesinski <adamlesinski@google.com>2015-08-13 22:06:31 -0700
commit621e06a64d0a18f357a874de15a84c3ec1d64d49 (patch)
tree663ed1b1cca271d408145b6f065518dc3ba24938 /core
parent81eeef589386483722c21572d9ab6d3f95dd26be (diff)
downloadframeworks_base-621e06a64d0a18f357a874de15a84c3ec1d64d49.zip
frameworks_base-621e06a64d0a18f357a874de15a84c3ec1d64d49.tar.gz
frameworks_base-621e06a64d0a18f357a874de15a84c3ec1d64d49.tar.bz2
Fix UserHandle.getAppIdFromSharedAppGid to allow system UIDs
System UIDs are also run as shared GIDs, so this should not throw an exception. Bug:23189342 Change-Id: Ia180db012c25615cde1720ae0d41d1378f7bfb1a
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;
}
/**