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
This commit is contained in:
Sumedh Sen
2023-01-24 10:50:44 -08:00
parent f9a03e8104
commit 05d3f055ea

View File

@@ -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.