Merge "Dexopt the launcher(s) after a Mainline update." into udc-dev

This commit is contained in:
Martin Stjernholm
2023-02-23 10:59:41 +00:00
committed by Android (Google) Code Review

View File

@@ -40,6 +40,7 @@ import static dalvik.system.DexFile.isProfileGuidedCompilerFilter;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.AppGlobals;
import android.app.role.RoleManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -272,7 +273,6 @@ public final class DexOptHelper {
* compiles it if needed.
*/
private void checkAndDexOptSystemUi(int reason) throws LegacyDexoptDisabledException {
Installer.checkLegacyDexoptDisabled();
Computer snapshot = mPm.snapshotComputer();
String sysUiPackageName =
mPm.mContext.getString(com.android.internal.R.string.config_systemUi);
@@ -288,7 +288,7 @@ public final class DexOptHelper {
String compilerFilter;
if (isProfileGuidedCompilerFilter(targetCompilerFilter)) {
compilerFilter = defaultCompilerFilter;
compilerFilter = "verify";
File profileFile = new File(getPrebuildProfilePath(pkg));
// Copy the profile to the reference profile path if it exists. Installd can only use a
@@ -312,7 +312,26 @@ public final class DexOptHelper {
compilerFilter = targetCompilerFilter;
}
// We don't expect updates in current profiles to be significant here, but
performDexoptPackage(sysUiPackageName, reason, compilerFilter);
}
private void dexoptLauncher(int reason) throws LegacyDexoptDisabledException {
Computer snapshot = mPm.snapshotComputer();
RoleManager roleManager = mPm.mContext.getSystemService(RoleManager.class);
for (var packageName : roleManager.getRoleHolders(RoleManager.ROLE_HOME)) {
AndroidPackage pkg = snapshot.getPackage(packageName);
if (pkg == null) {
Log.w(TAG, "Launcher package " + packageName + " is not found for dexopting");
} else {
performDexoptPackage(packageName, reason, "speed-profile");
}
}
}
private void performDexoptPackage(@NonNull String packageName, int reason,
@NonNull String compilerFilter) throws LegacyDexoptDisabledException {
Installer.checkLegacyDexoptDisabled();
// DEXOPT_CHECK_FOR_PROFILES_UPDATES is set to replicate behaviour that will be
// unconditionally enabled for profile guided filters when ART Service is called instead of
// the legacy PackageDexOptimizer implementation.
@@ -320,8 +339,8 @@ public final class DexOptHelper {
? DexoptOptions.DEXOPT_CHECK_FOR_PROFILES_UPDATES
: 0;
performDexOptTraced(new DexoptOptions(pkg.getPackageName(), REASON_BOOT_AFTER_OTA,
compilerFilter, null /* splitName */, dexoptFlags));
performDexOptTraced(new DexoptOptions(
packageName, reason, compilerFilter, null /* splitName */, dexoptFlags));
}
/**
@@ -343,6 +362,10 @@ public final class DexOptHelper {
return;
}
Log.i(TAG,
"Starting boot dexopt for reason "
+ DexoptOptions.convertToArtServiceDexoptReason(reason));
final long startTime = System.nanoTime();
if (useArtService()) {
@@ -351,9 +374,10 @@ public final class DexOptHelper {
null /* progressCallbackExecutor */, null /* progressCallback */);
} else {
try {
// System UI is important to user experience, so we check it after a mainline update
// or an OTA. It may need to be re-compiled in these cases.
// System UI and the launcher are important to user experience, so we check them
// after a mainline update or OTA. They may need to be re-compiled in these cases.
checkAndDexOptSystemUi(reason);
dexoptLauncher(reason);
if (reason != REASON_BOOT_AFTER_OTA && reason != REASON_FIRST_BOOT) {
return;