Use shared app gid for forward-locked processes

Use a shared app gid for each app across different users which allows
forward-locked applications to share the same APK file.

Change-Id: Ifecf51ee7865547117746f83e9733083d3dd5111
diff --git a/core/java/android/os/UserHandle.java b/core/java/android/os/UserHandle.java
index 7e4666c..22994ff 100644
--- a/core/java/android/os/UserHandle.java
+++ b/core/java/android/os/UserHandle.java
@@ -139,6 +139,15 @@
     }
 
     /**
+     * Returns the shared app gid for a given uid or appId.
+     * @hide
+     */
+    public static final int getSharedAppGid(int id) {
+        return Process.FIRST_SHARED_APPLICATION_GID + (id % PER_USER_RANGE)
+                - Process.FIRST_APPLICATION_UID;
+    }
+
+    /**
      * Returns the user id of the current process
      * @return user id of the current process
      * @hide