Cleanup performDexOpt with instruction sets.
Always use the packages' derived instruction sets.
This fixes a bug where otas and background dexopt would only
look at one instruction set.
bug:28994818
Change-Id: I730b59d24943c71de30adb485a823fd79c6806a6
diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl
index 03f83d6..4bbbdee 100644
--- a/core/java/android/content/pm/IPackageManager.aidl
+++ b/core/java/android/content/pm/IPackageManager.aidl
@@ -459,23 +459,19 @@
/**
* Ask the package manager to perform dex-opt (if needed) on the given
- * package and for the given instruction set if it already hasn't done
- * so.
- *
- * If the supplied instructionSet is null, the package manager will use
- * the packages default instruction set.
+ * package if it already hasn't done so.
*
* In most cases, apps are dexopted in advance and this function will
* be a no-op.
*/
- boolean performDexOptIfNeeded(String packageName, String instructionSet);
+ boolean performDexOptIfNeeded(String packageName);
/**
* Ask the package manager to perform a dex-opt for the given reason. The package
* manager will map the reason to a compiler filter according to the current system
* configuration.
*/
- boolean performDexOpt(String packageName, String instructionSet, boolean checkProfiles,
+ boolean performDexOpt(String packageName, boolean checkProfiles,
int compileReason, boolean force);
/**
* Ask the package manager to perform a dex-opt with the given compiler filter.
@@ -483,7 +479,7 @@
* Note: exposed only for the shell command to allow moving packages explicitly to a
* definite state.
*/
- boolean performDexOptMode(String packageName, String instructionSet, boolean checkProfiles,
+ boolean performDexOptMode(String packageName, boolean checkProfiles,
String targetCompilerFilter, boolean force);
void forceDexOpt(String packageName);
diff --git a/services/core/java/com/android/server/pm/BackgroundDexOptService.java b/services/core/java/com/android/server/pm/BackgroundDexOptService.java
index ee02a99..87f0581 100644
--- a/services/core/java/com/android/server/pm/BackgroundDexOptService.java
+++ b/services/core/java/com/android/server/pm/BackgroundDexOptService.java
@@ -154,7 +154,6 @@
// behave differently than "pm.dexopt.bg-dexopt=speed-profile" but that's a
// trade-off worth doing to save boot time work.
pm.performDexOpt(pkg,
- /* instruction set */ null,
/* checkProfiles */ false,
PackageManagerService.REASON_BOOT,
/* force */ false);
@@ -192,7 +191,6 @@
// Optimize package if needed. Note that there can be no race between
// concurrent jobs because PackageDexOptimizer.performDexOpt is synchronized.
if (pm.performDexOpt(pkg,
- /* instruction set */ null,
/* checkProfiles */ true,
PackageManagerService.REASON_BACKGROUND_DEXOPT,
/* force */ false)) {
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 35bcaa9..1b88be7 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -7267,7 +7267,6 @@
// behave differently than "pm.dexopt.bg-dexopt=speed-profile" but that's a
// trade-off worth doing to save boot time work.
int dexOptStatus = performDexOptTraced(pkg.packageName,
- null /* instructionSet */,
false /* checkProfiles */,
getCompilerFilterForReason(causeFirstBoot ? REASON_FIRST_BOOT : REASON_BOOT),
false /* force */);
@@ -7309,33 +7308,33 @@
// TODO: this is not used nor needed. Delete it.
@Override
- public boolean performDexOptIfNeeded(String packageName, String instructionSet) {
- int dexOptStatus = performDexOptTraced(packageName, instructionSet,
+ public boolean performDexOptIfNeeded(String packageName) {
+ int dexOptStatus = performDexOptTraced(packageName,
false /* checkProfiles */, getFullCompilerFilter(), false /* force */);
return dexOptStatus != PackageDexOptimizer.DEX_OPT_FAILED;
}
@Override
- public boolean performDexOpt(String packageName, String instructionSet,
+ public boolean performDexOpt(String packageName,
boolean checkProfiles, int compileReason, boolean force) {
- int dexOptStatus = performDexOptTraced(packageName, instructionSet, checkProfiles,
+ int dexOptStatus = performDexOptTraced(packageName, checkProfiles,
getCompilerFilterForReason(compileReason), force);
return dexOptStatus != PackageDexOptimizer.DEX_OPT_FAILED;
}
@Override
- public boolean performDexOptMode(String packageName, String instructionSet,
+ public boolean performDexOptMode(String packageName,
boolean checkProfiles, String targetCompilerFilter, boolean force) {
- int dexOptStatus = performDexOptTraced(packageName, instructionSet, checkProfiles,
+ int dexOptStatus = performDexOptTraced(packageName, checkProfiles,
targetCompilerFilter, force);
return dexOptStatus != PackageDexOptimizer.DEX_OPT_FAILED;
}
- private int performDexOptTraced(String packageName, String instructionSet,
+ private int performDexOptTraced(String packageName,
boolean checkProfiles, String targetCompilerFilter, boolean force) {
Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "dexopt");
try {
- return performDexOptInternal(packageName, instructionSet, checkProfiles,
+ return performDexOptInternal(packageName, checkProfiles,
targetCompilerFilter, force);
} finally {
Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
@@ -7344,10 +7343,9 @@
// Run dexopt on a given package. Returns true if dexopt did not fail, i.e.
// if the package can now be considered up to date for the given filter.
- private int performDexOptInternal(String packageName, String instructionSet,
+ private int performDexOptInternal(String packageName,
boolean checkProfiles, String targetCompilerFilter, boolean force) {
PackageParser.Package p;
- final String targetInstructionSet;
synchronized (mPackages) {
p = mPackages.get(packageName);
if (p == null) {
@@ -7355,15 +7353,11 @@
return PackageDexOptimizer.DEX_OPT_FAILED;
}
mPackageUsage.write(false);
-
- targetInstructionSet = instructionSet != null ? instructionSet :
- getPrimaryInstructionSet(p.applicationInfo);
}
long callingId = Binder.clearCallingIdentity();
try {
synchronized (mInstallLock) {
- final String[] instructionSets = new String[] { targetInstructionSet };
- return performDexOptInternalWithDependenciesLI(p, instructionSets, checkProfiles,
+ return performDexOptInternalWithDependenciesLI(p, checkProfiles,
targetCompilerFilter, force);
}
} finally {
@@ -7384,7 +7378,7 @@
}
private int performDexOptInternalWithDependenciesLI(PackageParser.Package p,
- String instructionSets[], boolean checkProfiles, String targetCompilerFilter,
+ boolean checkProfiles, String targetCompilerFilter,
boolean force) {
// Select the dex optimizer based on the force parameter.
// Note: The force option is rarely used (cmdline input for testing, mostly), so it's OK to
@@ -7396,6 +7390,7 @@
// Optimize all dependencies first. Note: we ignore the return value and march on
// on errors.
Collection<PackageParser.Package> deps = findSharedNonSystemLibraries(p);
+ final String[] instructionSets = getAppDexInstructionSets(p.applicationInfo);
if (!deps.isEmpty()) {
for (PackageParser.Package depPackage : deps) {
// TODO: Analyze and investigate if we (should) profile libraries.
@@ -7405,7 +7400,6 @@
getCompilerFilterForReason(REASON_NON_SYSTEM_LIBRARY));
}
}
-
return pdo.performDexOpt(p, p.usesLibraryFiles, instructionSets, checkProfiles,
targetCompilerFilter);
}
@@ -7477,14 +7471,11 @@
}
synchronized (mInstallLock) {
- final String[] instructionSets = new String[] {
- getPrimaryInstructionSet(pkg.applicationInfo) };
-
Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "dexopt");
// Whoever is calling forceDexOpt wants a fully compiled package.
// Don't use profiles since that may cause compilation to be skipped.
- final int res = performDexOptInternalWithDependenciesLI(pkg, instructionSets,
+ final int res = performDexOptInternalWithDependenciesLI(pkg,
false /* checkProfiles */, getCompilerFilterForReason(REASON_FORCED_DEXOPT),
true /* force */);
diff --git a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
index 1eeff14..beff8fc 100644
--- a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
+++ b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
@@ -358,7 +358,7 @@
mInterface.clearApplicationProfileData(packageName);
}
- boolean result = mInterface.performDexOptMode(packageName, null /* instructionSet */,
+ boolean result = mInterface.performDexOptMode(packageName,
checkProfiles, targetCompilerFilter, forceCompilation);
if (!result) {
failedPackages.add(packageName);