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/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 6da8403..1c5a8a5 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -2008,9 +2008,10 @@
int[] gids = null;
int mountExternal = Zygote.MOUNT_EXTERNAL_NONE;
if (!app.isolated) {
+ int[] permGids = null;
try {
final PackageManager pm = mContext.getPackageManager();
- gids = pm.getPackageGids(app.info.packageName);
+ permGids = pm.getPackageGids(app.info.packageName);
if (Environment.isExternalStorageEmulated()) {
if (pm.checkPermission(
@@ -2024,6 +2025,18 @@
} catch (PackageManager.NameNotFoundException e) {
Slog.w(TAG, "Unable to retrieve gids", e);
}
+
+ /*
+ * Add shared application GID so applications can share some
+ * resources like shared libraries
+ */
+ if (permGids == null) {
+ gids = new int[1];
+ } else {
+ gids = new int[permGids.length + 1];
+ System.arraycopy(permGids, 0, gids, 1, permGids.length);
+ }
+ gids[0] = UserHandle.getSharedAppGid(UserHandle.getAppId(uid));
}
if (mFactoryTest != SystemServer.FACTORY_TEST_OFF) {
if (mFactoryTest == SystemServer.FACTORY_TEST_LOW_LEVEL