Clean up old code that only applied to upgrades from Android older than N.

This means completely removing the dexopt progress dialog, which was
only shown on such an upgrade. The fstrim message was blocked on that
dialog, which means it's practically never shown. This CL changes it to
show regardless.

Test: Boot
Bug: 251903639
Change-Id: Iba515866a085c0abb2e7701b95249a5863da2bc5
This commit is contained in:
Martin Stjernholm
2023-01-16 14:38:23 +00:00
parent dc8d24ee23
commit a1131b1763
3 changed files with 9 additions and 50 deletions

View File

@@ -40,7 +40,6 @@ import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.app.ActivityManager;
import android.app.AppGlobals;
import android.content.Context;
import android.content.Intent;
@@ -59,8 +58,6 @@ import android.util.ArraySet;
import android.util.Log;
import android.util.Slog;
import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.logging.MetricsLogger;
import com.android.server.LocalManagerRegistry;
import com.android.server.art.ArtManagerLocal;
@@ -99,18 +96,6 @@ public final class DexOptHelper {
private final PackageManagerService mPm;
public boolean isDexOptDialogShown() {
synchronized (mLock) {
return mDexOptDialogShown;
}
}
// TODO: Is this lock really necessary?
private final Object mLock = new Object();
@GuardedBy("mLock")
private boolean mDexOptDialogShown;
DexOptHelper(PackageManagerService pm) {
mPm = pm;
}
@@ -128,7 +113,7 @@ public final class DexOptHelper {
* which are (in order) {@code numberOfPackagesOptimized}, {@code numberOfPackagesSkipped}
* and {@code numberOfPackagesFailed}.
*/
public int[] performDexOptUpgrade(List<PackageStateInternal> packageStates, boolean showDialog,
public int[] performDexOptUpgrade(List<PackageStateInternal> packageStates,
final int compilationReason, boolean bootComplete)
throws LegacyDexoptDisabledException {
Installer.checkLegacyDexoptDisabled();
@@ -220,18 +205,6 @@ public final class DexOptHelper {
+ numberOfPackagesToDexopt + ": " + pkg.getPackageName());
}
if (showDialog) {
try {
ActivityManager.getService().showBootMessage(
mPm.mContext.getResources().getString(R.string.android_upgrading_apk,
numberOfPackagesVisited, numberOfPackagesToDexopt), true);
} catch (RemoteException e) {
}
synchronized (mLock) {
mDexOptDialogShown = true;
}
}
int pkgCompilationReason = compilationReason;
if (useProfileForDexopt) {
// Use background dexopt mode to try and use the profile. Note that this does not
@@ -364,9 +337,7 @@ public final class DexOptHelper {
boolean causeUpgrade = mPm.isDeviceUpgrading();
// First boot or factory reset.
// Note: we also handle devices that are upgrading to N right now as if it is their
// first boot, as they do not have profile data.
boolean causeFirstBoot = mPm.isFirstBoot() || mPm.isPreNUpgrade();
boolean causeFirstBoot = mPm.isFirstBoot();
if (!causeUpgrade && !causeFirstBoot) {
return;
@@ -377,7 +348,7 @@ public final class DexOptHelper {
getPackagesForDexopt(snapshot.getPackageStates().values(), mPm);
final long startTime = System.nanoTime();
final int[] stats = performDexOptUpgrade(pkgSettings, mPm.isPreNUpgrade() /* showDialog */,
final int[] stats = performDexOptUpgrade(pkgSettings,
causeFirstBoot ? REASON_FIRST_BOOT : REASON_BOOT_AFTER_OTA,
false /* bootComplete */);

View File

@@ -588,7 +588,6 @@ public class PackageManagerService implements PackageSender, TestUtilityService
private final int mDefParseFlags;
private final String[] mSeparateProcesses;
private final boolean mIsUpgrade;
private final boolean mIsPreNUpgrade;
private final boolean mIsPreNMR1Upgrade;
private final boolean mIsPreQUpgrade;
@@ -1734,7 +1733,6 @@ public class PackageManagerService implements PackageSender, TestUtilityService
mInstantAppResolverConnection = testParams.instantAppResolverConnection;
mInstantAppResolverSettingsComponent = testParams.instantAppResolverSettingsComponent;
mIsPreNMR1Upgrade = testParams.isPreNmr1Upgrade;
mIsPreNUpgrade = testParams.isPreNupgrade;
mIsPreQUpgrade = testParams.isPreQupgrade;
mIsUpgrade = testParams.isUpgrade;
mMetrics = testParams.Metrics;
@@ -2069,10 +2067,6 @@ public class PackageManagerService implements PackageSender, TestUtilityService
mPromoteSystemApps =
mIsUpgrade && ver.sdkVersion <= Build.VERSION_CODES.LOLLIPOP_MR1;
// When upgrading from pre-N, we need to handle package extraction like first boot,
// as there is no profiling data available.
mIsPreNUpgrade = mIsUpgrade && ver.sdkVersion < Build.VERSION_CODES.N;
mIsPreNMR1Upgrade = mIsUpgrade && ver.sdkVersion < Build.VERSION_CODES.N_MR1;
mIsPreQUpgrade = mIsUpgrade && ver.sdkVersion < Build.VERSION_CODES.Q;
@@ -2954,13 +2948,12 @@ public class PackageManagerService implements PackageSender, TestUtilityService
}
if (doTrim) {
if (!isFirstBoot()) {
if (mDexOptHelper.isDexOptDialogShown()) {
try {
ActivityManager.getService().showBootMessage(
mContext.getResources().getString(
R.string.android_upgrading_fstrim), true);
} catch (RemoteException e) {
}
try {
ActivityManager.getService().showBootMessage(
mContext.getResources().getString(
R.string.android_upgrading_fstrim),
true);
} catch (RemoteException e) {
}
}
sm.runMaintenance();
@@ -7495,10 +7488,6 @@ public class PackageManagerService implements PackageSender, TestUtilityService
return mPlatformPackage;
}
boolean isPreNUpgrade() {
return mIsPreNUpgrade;
}
boolean isPreNMR1Upgrade() {
return mIsPreNMR1Upgrade;
}

View File

@@ -63,7 +63,6 @@ public final class PackageManagerServiceTestParams {
public InstantAppResolverConnection instantAppResolverConnection;
public ComponentName instantAppResolverSettingsComponent;
public boolean isPreNmr1Upgrade;
public boolean isPreNupgrade;
public boolean isPreQupgrade;
public boolean isUpgrade;
public LegacyPermissionManagerInternal legacyPermissionManagerInternal;