Merge "Ignore System Server dynamic dex files during A/B preopt" into rvc-dev

This commit is contained in:
Orion Hodson
2020-07-09 08:30:44 +00:00
committed by Android (Google) Code Review

View File

@@ -18,6 +18,7 @@ package com.android.server.pm;
import static com.android.server.pm.InstructionSets.getAppDexInstructionSets; import static com.android.server.pm.InstructionSets.getAppDexInstructionSets;
import static com.android.server.pm.InstructionSets.getDexCodeInstructionSets; import static com.android.server.pm.InstructionSets.getDexCodeInstructionSets;
import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.content.Context; import android.content.Context;
@@ -42,10 +43,9 @@ import java.io.FileDescriptor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
/** /**
* A service for A/B OTA dexopting. * A service for A/B OTA dexopting.
@@ -123,15 +123,20 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
} }
final List<PackageSetting> important; final List<PackageSetting> important;
final List<PackageSetting> others; final List<PackageSetting> others;
Predicate<PackageSetting> isPlatformPackage = pkgSetting ->
PLATFORM_PACKAGE_NAME.equals(pkgSetting.pkg.getPackageName());
synchronized (mPackageManagerService.mLock) { synchronized (mPackageManagerService.mLock) {
// Important: the packages we need to run with ab-ota compiler-reason. // Important: the packages we need to run with ab-ota compiler-reason.
important = PackageManagerServiceUtils.getPackagesForDexopt( important = PackageManagerServiceUtils.getPackagesForDexopt(
mPackageManagerService.mSettings.mPackages.values(), mPackageManagerService, mPackageManagerService.mSettings.mPackages.values(), mPackageManagerService,
DEBUG_DEXOPT); DEBUG_DEXOPT);
// Remove Platform Package from A/B OTA b/160735835.
important.removeIf(isPlatformPackage);
// Others: we should optimize this with the (first-)boot compiler-reason. // Others: we should optimize this with the (first-)boot compiler-reason.
others = new ArrayList<>(mPackageManagerService.mSettings.mPackages.values()); others = new ArrayList<>(mPackageManagerService.mSettings.mPackages.values());
others.removeAll(important); others.removeAll(important);
others.removeIf(PackageManagerServiceUtils.REMOVE_IF_NULL_PKG); others.removeIf(PackageManagerServiceUtils.REMOVE_IF_NULL_PKG);
others.removeIf(isPlatformPackage);
// Pre-size the array list by over-allocating by a factor of 1.5. // Pre-size the array list by over-allocating by a factor of 1.5.
mDexoptCommands = new ArrayList<>(3 * mPackageManagerService.mPackages.size() / 2); mDexoptCommands = new ArrayList<>(3 * mPackageManagerService.mPackages.size() / 2);
@@ -147,7 +152,7 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
throw new IllegalStateException("Found a core app that's not important"); throw new IllegalStateException("Found a core app that's not important");
} }
mDexoptCommands.addAll(generatePackageDexopts(pkgSetting.pkg, pkgSetting, mDexoptCommands.addAll(generatePackageDexopts(pkgSetting.pkg, pkgSetting,
PackageManagerService.REASON_FIRST_BOOT)); PackageManagerService.REASON_FIRST_BOOT));
} }
completeSize = mDexoptCommands.size(); completeSize = mDexoptCommands.size();