From 9c1aeb8dad25009e3f2da16337a5799e49adfa2e Mon Sep 17 00:00:00 2001 From: Patrick Baumann Date: Fri, 17 Mar 2023 14:50:04 +0000 Subject: [PATCH] Enable default stopped state for system apps This change adds a few additional exceptions for system apps to start in the default stopped state and turns the feature on. Bug: 269129704 Test: inspect output of pm list packages --show-stopped Change-Id: Ia07877356c3522a449c611e12eba787018a3d35f --- core/res/res/values/config.xml | 2 +- .../server/pm/InstallPackageHelper.java | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 0600b3802fe14..8f15ae0912cad 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -6360,7 +6360,7 @@ Packages can be added by OEMs in an allowlist, to prevent them from being scanned as "stopped" during initial boot of a device, or after an OTA update. Stopped state of an app is not changed during subsequent reboots. --> - false + true false diff --git a/services/core/java/com/android/server/pm/InstallPackageHelper.java b/services/core/java/com/android/server/pm/InstallPackageHelper.java index 5f424edb15c4b..6fd52ec788d0b 100644 --- a/services/core/java/com/android/server/pm/InstallPackageHelper.java +++ b/services/core/java/com/android/server/pm/InstallPackageHelper.java @@ -4312,12 +4312,22 @@ final class InstallPackageHelper { // A new application appeared on /system, and we are seeing it for the first time. // Its also not updated as we don't have a copy of it on /data. So, scan it in a - // STOPPED state. Ignore if it's an APEX package since stopped state does not affect them. + // STOPPED state. + // We'll skip this step under the following conditions: + // - It's "android" + // - It's an APEX or overlay package since stopped state does not affect them. + // - It is enumerated with a tag having the stopped attribute + // set to false final boolean isApexPkg = (scanFlags & SCAN_AS_APEX) != 0; - if (mPm.mShouldStopSystemPackagesByDefault && scanSystemPartition - && !pkgAlreadyExists && !isApexPkg) { + if (mPm.mShouldStopSystemPackagesByDefault + && scanSystemPartition + && !pkgAlreadyExists + && !isApexPkg + && !parsedPackage.isOverlayIsStatic() + ) { String packageName = parsedPackage.getPackageName(); - if (!mPm.mInitialNonStoppedSystemPackages.contains(packageName)) { + if (!mPm.mInitialNonStoppedSystemPackages.contains(packageName) + && !"android".contentEquals(packageName)) { scanFlags |= SCAN_AS_STOPPED_SYSTEM_APP; } }