From 5f44aa798bdfdaf219e01447743ee2204a9de46b Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Wed, 15 Nov 2017 19:07:14 -0700 Subject: [PATCH] Workaround to get passed the broken install flow For fresh installs the PM does not set the app uid before invoking dexopt; so we would always get a bogus GID. This is a temporary workaround which fixes the GID of newly installed apps to an arbitrary UNKNOWN gid. Test: adb install Bug: 64548938 Bug: 69331247 (cherry picked from commit a73e165c2ea0bb6499b89dd335d6ef878c92b8e9) Change-Id: I6438ec8cfca88df813e166f9ef5821e62faf524a --- core/java/android/os/Process.java | 3 +++ .../java/com/android/server/pm/PackageDexOptimizer.java | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java index b5d62e555edc2..0874d93e8262a 100644 --- a/core/java/android/os/Process.java +++ b/core/java/android/os/Process.java @@ -151,6 +151,9 @@ public class Process { */ public static final int OTA_UPDATE_UID = 1061; + /** {@hide} */ + public static final int NOBODY_UID = 9999; + /** * Defines the start of a range of UIDs (and GIDs), going from this * number to {@link #LAST_APPLICATION_UID} that are reserved for assigning diff --git a/services/core/java/com/android/server/pm/PackageDexOptimizer.java b/services/core/java/com/android/server/pm/PackageDexOptimizer.java index 401eb62f0b1bf..bf1c4c3dc6651 100644 --- a/services/core/java/com/android/server/pm/PackageDexOptimizer.java +++ b/services/core/java/com/android/server/pm/PackageDexOptimizer.java @@ -154,7 +154,13 @@ public class PackageDexOptimizer { targetInstructionSets : getAppDexInstructionSets(pkg.applicationInfo); final String[] dexCodeInstructionSets = getDexCodeInstructionSets(instructionSets); final List paths = pkg.getAllCodePaths(); - final int sharedGid = UserHandle.getSharedAppGid(pkg.applicationInfo.uid); + + int sharedGid = UserHandle.getSharedAppGid(pkg.applicationInfo.uid); + if (sharedGid == -1) { + Slog.wtf(TAG, "Well this is awkward; package " + pkg.applicationInfo.name + " had UID " + + pkg.applicationInfo.uid, new Throwable()); + sharedGid = android.os.Process.NOBODY_UID; + } // Get the class loader context dependencies. // For each code path in the package, this array contains the class loader context that