diff --git a/data/etc/Android.bp b/data/etc/Android.bp index d0c3e5f6a91e1..f233c6eca13b9 100644 --- a/data/etc/Android.bp +++ b/data/etc/Android.bp @@ -35,6 +35,12 @@ prebuilt_etc { src: "preinstalled-packages-platform.xml", } +prebuilt_etc { + name: "initial-package-stopped-states.xml", + sub_dir: "sysconfig", + src: "initial-package-stopped-states.xml", +} + prebuilt_etc { name: "preinstalled-packages-platform-overlays.xml", product_specific: true, diff --git a/data/etc/initial-package-stopped-states.xml b/data/etc/initial-package-stopped-states.xml new file mode 100644 index 0000000000000..6bda2c0dbc260 --- /dev/null +++ b/data/etc/initial-package-stopped-states.xml @@ -0,0 +1,38 @@ + + + + + + diff --git a/services/core/java/com/android/server/SystemConfig.java b/services/core/java/com/android/server/SystemConfig.java index 4854c37933e34..4b7612791fe7d 100644 --- a/services/core/java/com/android/server/SystemConfig.java +++ b/services/core/java/com/android/server/SystemConfig.java @@ -333,6 +333,11 @@ public class SystemConfig { // Update ownership for system applications and the installers eligible to update them. private final ArrayMap mUpdateOwnersForSystemApps = new ArrayMap<>(); + // Set of package names that should not be marked as "stopped" during initial device boot + // or when adding a new user. A new package not contained in this set will be + // marked as stopped by the system + @NonNull private final Set mInitialNonStoppedSystemPackages = new ArraySet<>(); + /** * Map of system pre-defined, uniquely named actors; keys are namespace, * value maps actor name to package name. @@ -527,6 +532,10 @@ public class SystemConfig { ? null : mOverlayConfigSignaturePackage; } + public Set getInitialNonStoppedSystemPackages() { + return mInitialNonStoppedSystemPackages; + } + /** * Only use for testing. Do NOT use in production code. * @param readPermissions false to create an empty SystemConfig; true to read the permissions. @@ -1445,6 +1454,19 @@ public class SystemConfig { } XmlUtils.skipCurrentTag(parser); } break; + case "initial-package-state": { + String pkgName = parser.getAttributeValue(null, "package"); + String stopped = parser.getAttributeValue(null, "stopped"); + if (TextUtils.isEmpty(pkgName)) { + Slog.w(TAG, "<" + name + "> without package in " + permFile + + " at " + parser.getPositionDescription()); + } else if (TextUtils.isEmpty(stopped)) { + Slog.w(TAG, "<" + name + "> without stopped in " + permFile + + " at " + parser.getPositionDescription()); + } else if (!Boolean.parseBoolean(stopped)) { + mInitialNonStoppedSystemPackages.add(pkgName); + } + } default: { Slog.w(TAG, "Tag " + name + " is unknown in " + permFile + " at " + parser.getPositionDescription());