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 a73e165c2e)

Change-Id: I6438ec8cfca88df813e166f9ef5821e62faf524a
This commit is contained in:
Jeff Sharkey
2017-11-15 19:07:14 -07:00
committed by Calin Juravle
parent a89f6150dc
commit 5f44aa798b
2 changed files with 10 additions and 1 deletions

View File

@@ -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

View File

@@ -154,7 +154,13 @@ public class PackageDexOptimizer {
targetInstructionSets : getAppDexInstructionSets(pkg.applicationInfo);
final String[] dexCodeInstructionSets = getDexCodeInstructionSets(instructionSets);
final List<String> 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