Add SystemServer package to the list of optimizable packages
This will allow the normal jobs to optimize system server dex files when needed. These include: the bakground dexopt job and the upgrade job. Test: manual, DexManagerTests Bug: 148774920 Change-Id: I70f8ffa06affd06c8d25031b81cf294f2689a52f
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package com.android.server.pm;
|
||||
|
||||
import static com.android.server.pm.PackageManagerService.DEBUG_DEXOPT;
|
||||
import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.app.job.JobInfo;
|
||||
@@ -434,7 +435,7 @@ public class BackgroundDexOptService extends JobService {
|
||||
| DexoptOptions.DEXOPT_DOWNGRADE;
|
||||
long package_size_before = getPackageSize(pm, pkg);
|
||||
|
||||
if (isForPrimaryDex) {
|
||||
if (isForPrimaryDex || PLATFORM_PACKAGE_NAME.equals(pkg)) {
|
||||
// This applies for system apps or if packages location is not a directory, i.e.
|
||||
// monolithic install.
|
||||
if (!pm.canHaveOatDir(pkg)) {
|
||||
@@ -486,7 +487,9 @@ public class BackgroundDexOptService extends JobService {
|
||||
| DexoptOptions.DEXOPT_BOOT_COMPLETE
|
||||
| DexoptOptions.DEXOPT_IDLE_BACKGROUND_JOB;
|
||||
|
||||
return isForPrimaryDex
|
||||
// System server share the same code path as primary dex files.
|
||||
// PackageManagerService will select the right optimization path for it.
|
||||
return (isForPrimaryDex || PLATFORM_PACKAGE_NAME.equals(pkg))
|
||||
? performDexOptPrimary(pm, pkg, reason, dexoptFlags)
|
||||
: performDexOptSecondary(pm, pkg, reason, dexoptFlags);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import static com.android.server.pm.Installer.DEXOPT_STORAGE_CE;
|
||||
import static com.android.server.pm.Installer.DEXOPT_STORAGE_DE;
|
||||
import static com.android.server.pm.InstructionSets.getAppDexInstructionSets;
|
||||
import static com.android.server.pm.InstructionSets.getDexCodeInstructionSets;
|
||||
import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME;
|
||||
import static com.android.server.pm.PackageManagerService.WATCHDOG_TIMEOUT;
|
||||
import static com.android.server.pm.PackageManagerServiceCompilerMapping.getReasonName;
|
||||
|
||||
@@ -115,7 +116,9 @@ public class PackageDexOptimizer {
|
||||
|
||||
static boolean canOptimizePackage(AndroidPackage pkg) {
|
||||
// We do not dexopt a package with no code.
|
||||
if (!pkg.isHasCode()) {
|
||||
// Note that the system package is marked as having no code, however we can
|
||||
// still optimize it via dexoptSystemServerPath.
|
||||
if (!PLATFORM_PACKAGE_NAME.equals(pkg.getPackageName()) && !pkg.isHasCode()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -132,6 +135,10 @@ public class PackageDexOptimizer {
|
||||
int performDexOpt(AndroidPackage pkg, @NonNull PackageSetting pkgSetting,
|
||||
String[] instructionSets, CompilerStats.PackageStats packageStats,
|
||||
PackageDexUsage.PackageUseInfo packageUseInfo, DexoptOptions options) {
|
||||
if (PLATFORM_PACKAGE_NAME.equals(pkg.getPackageName())) {
|
||||
throw new IllegalArgumentException("System server dexopting should be done via "
|
||||
+ " DexManager and PackageDexOptimizer#dexoptSystemServerPath");
|
||||
}
|
||||
if (pkg.getUid() == -1) {
|
||||
throw new IllegalArgumentException("Dexopt for " + pkg.getPackageName()
|
||||
+ " has invalid uid.");
|
||||
|
||||
@@ -447,6 +447,14 @@ public class DexManager {
|
||||
* because they don't need to be compiled)..
|
||||
*/
|
||||
public boolean dexoptSecondaryDex(DexoptOptions options) {
|
||||
if (PLATFORM_PACKAGE_NAME.equals(options.getPackageName())) {
|
||||
// We could easily redirect to #dexoptSystemServer in this case. But there should be
|
||||
// no-one calling this method directly for system server.
|
||||
// As such we prefer to abort in this case.
|
||||
Slog.wtf(TAG, "System server jars should be optimized with dexoptSystemServer");
|
||||
return false;
|
||||
}
|
||||
|
||||
PackageDexOptimizer pdo = getPackageDexOptimizer(options);
|
||||
String packageName = options.getPackageName();
|
||||
PackageUseInfo useInfo = getPackageUseInfoOrDefault(packageName);
|
||||
|
||||
Reference in New Issue
Block a user