Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4216d30 authored by Adam Lesinski's avatar Adam Lesinski
Browse files

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

Bug:22008744
Change-Id: Ifadc7df3777dd74932833f4d22a0e285d7bdaf95
parent b035c6d9
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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.