Add helper function to extract app ID from shared app gid.

Bug:22008744
Change-Id: Ifadc7df3777dd74932833f4d22a0e285d7bdaf95
This commit is contained in:
Adam Lesinski
2015-06-26 16:33:24 -07:00
parent b035c6d9a6
commit f4216d30cd

View File

@@ -178,6 +178,19 @@ public final class UserHandle implements Parcelable {
- Process.FIRST_APPLICATION_UID;
}
/**
* Returns the app id for a given shared app gid.
* @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");
}
return (noUserGid + Process.FIRST_APPLICATION_UID) - Process.FIRST_SHARED_APPLICATION_GID;
}
/**
* Generate a text representation of the uid, breaking out its individual
* components -- user, app, isolated, etc.