Merge "Pass bootComplete to dexopt."
This commit is contained in:
@@ -466,22 +466,13 @@ interface IPackageManager {
|
||||
*/
|
||||
void notifyDexLoad(String loadingPackageName, in List<String> dexPaths, String loaderIsa);
|
||||
|
||||
/**
|
||||
* Ask the package manager to perform dex-opt (if needed) on the given
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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, boolean checkProfiles,
|
||||
int compileReason, boolean force);
|
||||
int compileReason, boolean force, boolean bootComplete);
|
||||
|
||||
/**
|
||||
* Ask the package manager to perform a dex-opt with the given compiler filter.
|
||||
@@ -490,7 +481,7 @@ interface IPackageManager {
|
||||
* definite state.
|
||||
*/
|
||||
boolean performDexOptMode(String packageName, boolean checkProfiles,
|
||||
String targetCompilerFilter, boolean force);
|
||||
String targetCompilerFilter, boolean force, boolean bootComplete);
|
||||
|
||||
/**
|
||||
* Ask the package manager to perform a dex-opt with the given compiler filter on the
|
||||
|
||||
@@ -211,7 +211,8 @@ public class BackgroundDexOptService extends JobService {
|
||||
pm.performDexOpt(pkg,
|
||||
/* checkProfiles */ false,
|
||||
PackageManagerService.REASON_BOOT,
|
||||
/* force */ false);
|
||||
/* force */ false,
|
||||
/* bootComplete */ true);
|
||||
}
|
||||
// Ran to completion, so we abandon our timeslice and do not reschedule.
|
||||
jobFinished(jobParams, /* reschedule */ false);
|
||||
@@ -288,7 +289,8 @@ public class BackgroundDexOptService extends JobService {
|
||||
? pm.performDexOpt(pkg,
|
||||
/* checkProfiles */ true,
|
||||
PackageManagerService.REASON_BACKGROUND_DEXOPT,
|
||||
/* force */ false)
|
||||
/* force */ false,
|
||||
/* bootComplete */ true)
|
||||
: pm.performDexOptSecondary(pkg,
|
||||
PackageManagerService.REASON_BACKGROUND_DEXOPT,
|
||||
/* force */ false);
|
||||
|
||||
@@ -315,7 +315,8 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
|
||||
null /* ISAs */, false /* checkProfiles */,
|
||||
getCompilerFilterForReason(compilationReason),
|
||||
null /* CompilerStats.PackageStats */,
|
||||
mPackageManagerService.getDexManager().isUsedByOtherApps(pkg.packageName));
|
||||
mPackageManagerService.getDexManager().isUsedByOtherApps(pkg.packageName),
|
||||
true /* bootComplete */);
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,8 @@ public class PackageDexOptimizer {
|
||||
*/
|
||||
int performDexOpt(PackageParser.Package pkg, String[] sharedLibraries,
|
||||
String[] instructionSets, boolean checkProfiles, String targetCompilationFilter,
|
||||
CompilerStats.PackageStats packageStats, boolean isUsedByOtherApps) {
|
||||
CompilerStats.PackageStats packageStats, boolean isUsedByOtherApps,
|
||||
boolean bootComplete) {
|
||||
if (!canOptimizePackage(pkg)) {
|
||||
return DEX_OPT_SKIPPED;
|
||||
}
|
||||
@@ -119,7 +120,7 @@ public class PackageDexOptimizer {
|
||||
}
|
||||
try {
|
||||
return performDexOptLI(pkg, sharedLibraries, instructionSets, checkProfiles,
|
||||
targetCompilationFilter, packageStats, isUsedByOtherApps);
|
||||
targetCompilationFilter, packageStats, isUsedByOtherApps, bootComplete);
|
||||
} finally {
|
||||
if (useLock) {
|
||||
mDexoptWakeLock.release();
|
||||
@@ -136,7 +137,7 @@ public class PackageDexOptimizer {
|
||||
private int performDexOptLI(PackageParser.Package pkg, String[] sharedLibraries,
|
||||
String[] targetInstructionSets, boolean checkForProfileUpdates,
|
||||
String targetCompilerFilter, CompilerStats.PackageStats packageStats,
|
||||
boolean isUsedByOtherApps) {
|
||||
boolean isUsedByOtherApps, boolean bootComplete) {
|
||||
final String[] instructionSets = targetInstructionSets != null ?
|
||||
targetInstructionSets : getAppDexInstructionSets(pkg.applicationInfo);
|
||||
final String[] dexCodeInstructionSets = getDexCodeInstructionSets(instructionSets);
|
||||
@@ -152,7 +153,7 @@ public class PackageDexOptimizer {
|
||||
// paths (b/34169257).
|
||||
String sharedLibrariesPath = getSharedLibrariesPath(sharedLibraries);
|
||||
// Get the dexopt flags after getRealCompilerFilter to make sure we get the correct flags.
|
||||
final int dexoptFlags = getDexFlags(pkg, compilerFilter);
|
||||
final int dexoptFlags = getDexFlags(pkg, compilerFilter, bootComplete);
|
||||
|
||||
int result = DEX_OPT_SKIPPED;
|
||||
// TODO: Iterate based on dependency hierarchy (currently alphabetically by name)
|
||||
@@ -274,7 +275,9 @@ public class PackageDexOptimizer {
|
||||
@GuardedBy("mInstallLock")
|
||||
private int dexOptSecondaryDexPathLI(ApplicationInfo info, String path, Set<String> isas,
|
||||
String compilerFilter, boolean isUsedByOtherApps) {
|
||||
int dexoptFlags = getDexFlags(info, compilerFilter) | DEXOPT_SECONDARY_DEX;
|
||||
// Secondary dex files are currently not compiled at boot.
|
||||
int dexoptFlags = getDexFlags(info, compilerFilter, /* bootComplete */ true)
|
||||
| DEXOPT_SECONDARY_DEX;
|
||||
// Check the app storage and add the appropriate flags.
|
||||
if (info.dataDir.equals(info.deviceProtectedDataDir)) {
|
||||
dexoptFlags |= DEXOPT_STORAGE_DE;
|
||||
@@ -374,11 +377,12 @@ public class PackageDexOptimizer {
|
||||
* Computes the dex flags that needs to be pass to installd for the given package and compiler
|
||||
* filter.
|
||||
*/
|
||||
private int getDexFlags(PackageParser.Package pkg, String compilerFilter) {
|
||||
return getDexFlags(pkg.applicationInfo, compilerFilter);
|
||||
private int getDexFlags(PackageParser.Package pkg, String compilerFilter,
|
||||
boolean bootComplete) {
|
||||
return getDexFlags(pkg.applicationInfo, compilerFilter, bootComplete);
|
||||
}
|
||||
|
||||
private int getDexFlags(ApplicationInfo info, String compilerFilter) {
|
||||
private int getDexFlags(ApplicationInfo info, String compilerFilter, boolean bootComplete) {
|
||||
int flags = info.flags;
|
||||
boolean debuggable = (flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
|
||||
// Profile guide compiled oat files should not be public.
|
||||
@@ -389,7 +393,7 @@ public class PackageDexOptimizer {
|
||||
(isPublic ? DEXOPT_PUBLIC : 0)
|
||||
| (debuggable ? DEXOPT_DEBUGGABLE : 0)
|
||||
| profileFlag
|
||||
| DEXOPT_BOOTCOMPLETE;
|
||||
| (bootComplete ? DEXOPT_BOOTCOMPLETE : 0);
|
||||
return adjustDexoptFlags(dexFlags);
|
||||
}
|
||||
|
||||
|
||||
@@ -2662,7 +2662,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
|
||||
int[] stats = performDexOptUpgrade(coreApps, false,
|
||||
getCompilerFilterForReason(REASON_CORE_APP));
|
||||
getCompilerFilterForReason(REASON_CORE_APP), /* bootComplete */ false);
|
||||
|
||||
final int elapsedTimeSeconds =
|
||||
(int) TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - start);
|
||||
@@ -7305,7 +7305,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
|
||||
final long startTime = System.nanoTime();
|
||||
final int[] stats = performDexOptUpgrade(pkgs, mIsPreNUpgrade /* showDialog */,
|
||||
getCompilerFilterForReason(causeFirstBoot ? REASON_FIRST_BOOT : REASON_BOOT));
|
||||
getCompilerFilterForReason(causeFirstBoot ? REASON_FIRST_BOOT : REASON_BOOT),
|
||||
false /* bootComplete */);
|
||||
|
||||
final int elapsedTimeSeconds =
|
||||
(int) TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime);
|
||||
@@ -7324,7 +7325,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
* and {@code numberOfPackagesFailed}.
|
||||
*/
|
||||
private int[] performDexOptUpgrade(List<PackageParser.Package> pkgs, boolean showDialog,
|
||||
String compilerFilter) {
|
||||
String compilerFilter, boolean bootComplete) {
|
||||
|
||||
int numberOfPackagesVisited = 0;
|
||||
int numberOfPackagesOptimized = 0;
|
||||
@@ -7381,7 +7382,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
int dexOptStatus = performDexOptTraced(pkg.packageName,
|
||||
false /* checkProfiles */,
|
||||
compilerFilter,
|
||||
false /* force */);
|
||||
false /* force */,
|
||||
bootComplete);
|
||||
switch (dexOptStatus) {
|
||||
case PackageDexOptimizer.DEX_OPT_PERFORMED:
|
||||
numberOfPackagesOptimized++;
|
||||
@@ -7425,36 +7427,30 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
mDexManager.notifyDexLoad(ai, dexPaths, loaderIsa, userId);
|
||||
}
|
||||
|
||||
// TODO: this is not used nor needed. Delete it.
|
||||
@Override
|
||||
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,
|
||||
boolean checkProfiles, int compileReason, boolean force) {
|
||||
boolean checkProfiles, int compileReason, boolean force, boolean bootComplete) {
|
||||
int dexOptStatus = performDexOptTraced(packageName, checkProfiles,
|
||||
getCompilerFilterForReason(compileReason), force);
|
||||
getCompilerFilterForReason(compileReason), force, bootComplete);
|
||||
return dexOptStatus != PackageDexOptimizer.DEX_OPT_FAILED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performDexOptMode(String packageName,
|
||||
boolean checkProfiles, String targetCompilerFilter, boolean force) {
|
||||
boolean checkProfiles, String targetCompilerFilter, boolean force,
|
||||
boolean bootComplete) {
|
||||
int dexOptStatus = performDexOptTraced(packageName, checkProfiles,
|
||||
targetCompilerFilter, force);
|
||||
targetCompilerFilter, force, bootComplete);
|
||||
return dexOptStatus != PackageDexOptimizer.DEX_OPT_FAILED;
|
||||
}
|
||||
|
||||
private int performDexOptTraced(String packageName,
|
||||
boolean checkProfiles, String targetCompilerFilter, boolean force) {
|
||||
boolean checkProfiles, String targetCompilerFilter, boolean force,
|
||||
boolean bootComplete) {
|
||||
Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "dexopt");
|
||||
try {
|
||||
return performDexOptInternal(packageName, checkProfiles,
|
||||
targetCompilerFilter, force);
|
||||
targetCompilerFilter, force, bootComplete);
|
||||
} finally {
|
||||
Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
|
||||
}
|
||||
@@ -7463,7 +7459,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
// 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,
|
||||
boolean checkProfiles, String targetCompilerFilter, boolean force) {
|
||||
boolean checkProfiles, String targetCompilerFilter, boolean force,
|
||||
boolean bootComplete) {
|
||||
PackageParser.Package p;
|
||||
synchronized (mPackages) {
|
||||
p = mPackages.get(packageName);
|
||||
@@ -7478,7 +7475,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
try {
|
||||
synchronized (mInstallLock) {
|
||||
return performDexOptInternalWithDependenciesLI(p, checkProfiles,
|
||||
targetCompilerFilter, force);
|
||||
targetCompilerFilter, force, bootComplete);
|
||||
}
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(callingId);
|
||||
@@ -7499,7 +7496,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
|
||||
private int performDexOptInternalWithDependenciesLI(PackageParser.Package p,
|
||||
boolean checkProfiles, String targetCompilerFilter,
|
||||
boolean force) {
|
||||
boolean force, boolean bootComplete) {
|
||||
// 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
|
||||
// allocate an object here.
|
||||
@@ -7519,12 +7516,13 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
false /* checkProfiles */,
|
||||
getCompilerFilterForReason(REASON_NON_SYSTEM_LIBRARY),
|
||||
getOrCreateCompilerPackageStats(depPackage),
|
||||
mDexManager.isUsedByOtherApps(p.packageName));
|
||||
mDexManager.isUsedByOtherApps(p.packageName),
|
||||
bootComplete);
|
||||
}
|
||||
}
|
||||
return pdo.performDexOpt(p, p.usesLibraryFiles, instructionSets, checkProfiles,
|
||||
targetCompilerFilter, getOrCreateCompilerPackageStats(p),
|
||||
mDexManager.isUsedByOtherApps(p.packageName));
|
||||
mDexManager.isUsedByOtherApps(p.packageName), bootComplete);
|
||||
}
|
||||
|
||||
// Performs dexopt on the used secondary dex files belonging to the given package.
|
||||
@@ -7670,7 +7668,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
// Don't use profiles since that may cause compilation to be skipped.
|
||||
final int res = performDexOptInternalWithDependenciesLI(pkg,
|
||||
false /* checkProfiles */, getCompilerFilterForReason(REASON_FORCED_DEXOPT),
|
||||
true /* force */);
|
||||
true /* force */,
|
||||
true /* bootComplete */);
|
||||
|
||||
Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
|
||||
if (res != PackageDexOptimizer.DEX_OPT_PERFORMED) {
|
||||
@@ -15242,7 +15241,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
null /* instructionSets */, false /* checkProfiles */,
|
||||
getCompilerFilterForReason(REASON_INSTALL),
|
||||
getOrCreateCompilerPackageStats(pkg),
|
||||
mDexManager.isUsedByOtherApps(pkg.packageName));
|
||||
mDexManager.isUsedByOtherApps(pkg.packageName),
|
||||
true /* bootComplete */);
|
||||
Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
|
||||
|
||||
// Notify BackgroundDexOptService that the package has been changed.
|
||||
|
||||
@@ -399,7 +399,8 @@ class PackageManagerShellCommand extends ShellCommand {
|
||||
? mInterface.performDexOptSecondary(packageName,
|
||||
targetCompilerFilter, forceCompilation)
|
||||
: mInterface.performDexOptMode(packageName,
|
||||
checkProfiles, targetCompilerFilter, forceCompilation);
|
||||
checkProfiles, targetCompilerFilter, forceCompilation,
|
||||
true /* bootComplete */);
|
||||
if (!result) {
|
||||
failedPackages.add(packageName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user