Refactor the arguments passed to dexopt invocations
Wrap the arguments passed to the various performDexopt calls into the
DexoptOptions object.
This will make adding extra arguments (like compile only a split) much
easier and avoid extending quite a few internal methods.
(cherry picked from commit 1d0e83d2cee794ba576d573119e826905a4422cd)
Bug: 38138251
Test: adb shell cmd package compile ....
adb shell cmd package bg-dexopt-job ...
install new apps and check that they compiled
runtest -x
services/tests/servicestests/src/com/android/server/pm/dex/DexoptOptionsTests.java
Merged-In: Ia9930edd2dceb7535d6168eceb8e3199c82b6306
Change-Id: Ia9930edd2dceb7535d6168eceb8e3199c82b6306
diff --git a/services/core/java/com/android/server/pm/PackageDexOptimizer.java b/services/core/java/com/android/server/pm/PackageDexOptimizer.java
index 644bab1..4064665 100644
--- a/services/core/java/com/android/server/pm/PackageDexOptimizer.java
+++ b/services/core/java/com/android/server/pm/PackageDexOptimizer.java
@@ -19,9 +19,7 @@
import android.annotation.Nullable;
import android.content.Context;
import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageInfo;
import android.content.pm.PackageParser;
-import android.os.Environment;
import android.os.FileUtils;
import android.os.PowerManager;
import android.os.SystemClock;
@@ -35,6 +33,7 @@
import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.pm.Installer.InstallerException;
+import com.android.server.pm.dex.DexoptOptions;
import java.io.File;
import java.io.IOException;
@@ -123,18 +122,16 @@
* synchronized on {@link #mInstallLock}.
*/
int performDexOpt(PackageParser.Package pkg, String[] sharedLibraries,
- String[] instructionSets, boolean checkProfiles, String targetCompilationFilter,
- CompilerStats.PackageStats packageStats, boolean isUsedByOtherApps,
- boolean bootComplete, boolean downgrade) {
+ String[] instructionSets, CompilerStats.PackageStats packageStats,
+ boolean isUsedByOtherApps, DexoptOptions options) {
if (!canOptimizePackage(pkg)) {
return DEX_OPT_SKIPPED;
}
synchronized (mInstallLock) {
final long acquireTime = acquireWakeLockLI(pkg.applicationInfo.uid);
try {
- return performDexOptLI(pkg, sharedLibraries, instructionSets, checkProfiles,
- targetCompilationFilter, packageStats, isUsedByOtherApps, bootComplete,
- downgrade);
+ return performDexOptLI(pkg, sharedLibraries, instructionSets,
+ packageStats, isUsedByOtherApps, options);
} finally {
releaseWakeLockLI(acquireTime);
}
@@ -147,9 +144,8 @@
*/
@GuardedBy("mInstallLock")
private int performDexOptLI(PackageParser.Package pkg, String[] sharedLibraries,
- String[] targetInstructionSets, boolean checkForProfileUpdates,
- String targetCompilerFilter, CompilerStats.PackageStats packageStats,
- boolean isUsedByOtherApps, boolean bootComplete, boolean downgrade) {
+ String[] targetInstructionSets, CompilerStats.PackageStats packageStats,
+ boolean isUsedByOtherApps, DexoptOptions options) {
final String[] instructionSets = targetInstructionSets != null ?
targetInstructionSets : getAppDexInstructionSets(pkg.applicationInfo);
final String[] dexCodeInstructionSets = getDexCodeInstructionSets(instructionSets);
@@ -157,13 +153,13 @@
final int sharedGid = UserHandle.getSharedAppGid(pkg.applicationInfo.uid);
final String compilerFilter = getRealCompilerFilter(pkg.applicationInfo,
- targetCompilerFilter, isUsedByOtherApps);
- final boolean profileUpdated = checkForProfileUpdates &&
+ options.getCompilerFilter(), isUsedByOtherApps);
+ final boolean profileUpdated = options.isCheckForProfileUpdates() &&
isProfileUpdated(pkg, sharedGid, compilerFilter);
final String sharedLibrariesPath = getSharedLibrariesPath(sharedLibraries);
// Get the dexopt flags after getRealCompilerFilter to make sure we get the correct flags.
- final int dexoptFlags = getDexFlags(pkg, compilerFilter, bootComplete);
+ final int dexoptFlags = getDexFlags(pkg, compilerFilter, options.isBootComplete());
// Get the dependencies of each split in the package. For each code path in the package,
// this array contains the relative paths of each split it depends on, separated by colons.
String[] splitDependencies = getSplitDependencies(pkg);
@@ -187,7 +183,7 @@
for (String dexCodeIsa : dexCodeInstructionSets) {
int newResult = dexOptPath(pkg, path, dexCodeIsa, compilerFilter, profileUpdated,
sharedLibrariesPathWithSplits, dexoptFlags, sharedGid, packageStats,
- downgrade);
+ options.isDowngrade());
// The end result is:
// - FAILED if any path failed,
// - PERFORMED if at least one path needed compilation,