Skip APEX when doing dexopt

APEX is not dex-optimized and doesn't have a valid UID.

Fix: 247001427
Bug: 225756739
Test: adb shell cmd package compile -m speed-profile -a
Change-Id: Idce43d23eb92c39d8861f29136adaea5a676706d
This commit is contained in:
JW Wang
2022-09-23 10:39:31 +08:00
parent d7167e5b08
commit 85cfaad535
2 changed files with 17 additions and 0 deletions

View File

@@ -385,6 +385,11 @@ final class DexOptHelper {
} else if (snapshot.isInstantApp(options.getPackageName(), UserHandle.getCallingUserId())) {
return false;
}
var pkg = snapshot.getPackage(options.getPackageName());
if (pkg != null && pkg.isApex()) {
// skip APEX
return true;
}
if (options.isDexoptOnlySecondaryDex()) {
return mPm.getDexManager().dexoptSecondaryDex(options);
@@ -427,6 +432,10 @@ final class DexOptHelper {
// Package could not be found. Report failure.
return PackageDexOptimizer.DEX_OPT_FAILED;
}
if (p.isApex()) {
// APEX needs no dexopt
return PackageDexOptimizer.DEX_OPT_SKIPPED;
}
mPm.getPackageUsage().maybeWriteAsync(mPm.mSettings.getPackagesLocked());
mPm.mCompilerStats.maybeWriteAsync();
}
@@ -498,6 +507,9 @@ final class DexOptHelper {
if (packageState == null || pkg == null) {
throw new IllegalArgumentException("Unknown package: " + packageName);
}
if (pkg.isApex()) {
throw new IllegalArgumentException("Can't dexopt APEX package: " + packageName);
}
Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "dexopt");

View File

@@ -189,6 +189,11 @@ public class PackageDexOptimizer {
return false;
}
// We do not dexopt APEX packages.
if (pkg.isApex()) {
return false;
}
// We do not dexopt unused packages.
// It's possible for this to be called before app hibernation service is ready due to
// an OTA dexopt. In this case, we ignore the hibernation check here. This is fine since