From 05d3f055ea4596fddcfb6b8972fa8d90f844204b Mon Sep 17 00:00:00 2001 From: Sumedh Sen Date: Tue, 24 Jan 2023 10:50:44 -0800 Subject: [PATCH] Set system packages as stopped on user creation When new users are created, apps preloaded on the system partition will be scanned with an initial state of "stopped=true". Packages can be added to an allowlist to skip setting them initially as stopped. Bug: 249514169 Test: atest CtsContentTestCases:SystemPackageDefaultStoppedStateTest Change-Id: I48523c534f8e00e6953dbe774d7d68b2060c7809 --- services/core/java/com/android/server/pm/Settings.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java index 0ef94e85102a2..4f0a1159a4926 100644 --- a/services/core/java/com/android/server/pm/Settings.java +++ b/services/core/java/com/android/server/pm/Settings.java @@ -4430,6 +4430,15 @@ public final class Settings implements Watchable, Snappable { ps.getPackageName())); // Only system apps are initially installed. ps.setInstalled(shouldReallyInstall, userHandle); + + // Non-Apex system apps, that are not included in the allowlist in + // initialNonStoppedSystemPackages, should be marked as stopped by default. + final boolean shouldBeStopped = service.mShouldStopSystemPackagesByDefault + && ps.isSystem() + && !ps.isApex() + && !service.mInitialNonStoppedSystemPackages.contains(ps.getPackageName()); + ps.setStopped(shouldBeStopped, userHandle); + // If userTypeInstallablePackages is the *only* reason why we're not installing, // then uninstallReason is USER_TYPE. If there's a different reason, or if we // actually are installing, put UNKNOWN.