Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46dd8ab5 authored by Sumedh Sen's avatar Sumedh Sen Committed by Android (Google) Code Review
Browse files

Merge changes from topic "stopped-sys-apps"

* changes:
  Set system packages as stopped on user creation
  Set system packages as stopped
  Allowlist for exempting packages from being marked as stopped by default
  Feature flag for toggling stop system packages default behavior
parents 42044fdf 05d3f055
Loading
Loading
Loading
Loading
+23 −0
Original line number Original line Diff line number Diff line
@@ -6230,4 +6230,27 @@
        trusted certificate using the SHA-256 digest algorithm. -->
        trusted certificate using the SHA-256 digest algorithm. -->
    <string-array name="config_healthConnectMigrationKnownSigners">
    <string-array name="config_healthConnectMigrationKnownSigners">
    </string-array>
    </string-array>

    <!-- The Universal Stylus Initiative (USI) protocol version supported by each display.
         (@see https://universalstylus.org/).

         The i-th value in this array corresponds to the supported USI version of the i-th display
         listed in config_displayUniqueIdArray. On a single-display device, the
         config_displayUniqueIdArray may be empty, in which case the only value in this array should
         be the USI version for the main built-in display.

         If the display does not support USI, the version value should be an empty string. If the
         display supports USI, the version must be in the following format:
           "<major-version>.<minor-version>"

         For example, "", "1.0", and "2.0" are valid values. -->
    <string-array name="config_displayUsiVersionArray" translatable="false">
        <item>""</item>
    </string-array>

    <!-- Whether system apps should be scanned in the stopped state during initial boot.
        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.  -->
    <bool name="config_stopSystemPackagesByDefault">false</bool>
</resources>
</resources>
+2 −0
Original line number Original line Diff line number Diff line
@@ -4909,4 +4909,6 @@
  <java-symbol type="string" name="config_mainDisplayShape"/>
  <java-symbol type="string" name="config_mainDisplayShape"/>
  <java-symbol type="string" name="config_secondaryDisplayShape"/>
  <java-symbol type="string" name="config_secondaryDisplayShape"/>
  <java-symbol type="array" name="config_displayShapeArray" />
  <java-symbol type="array" name="config_displayShapeArray" />

  <java-symbol type="bool" name="config_stopSystemPackagesByDefault"/>
</resources>
</resources>
+6 −0
Original line number Original line Diff line number Diff line
@@ -35,6 +35,12 @@ prebuilt_etc {
    src: "preinstalled-packages-platform.xml",
    src: "preinstalled-packages-platform.xml",
}
}


prebuilt_etc {
    name: "initial-package-stopped-states.xml",
    sub_dir: "sysconfig",
    src: "initial-package-stopped-states.xml",
}

prebuilt_etc {
prebuilt_etc {
    name: "preinstalled-packages-platform-overlays.xml",
    name: "preinstalled-packages-platform-overlays.xml",
    product_specific: true,
    product_specific: true,
+38 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2023 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
 -->

<!--
This XML defines an allowlist for packages that should not be scanned in a "stopped" state.
When this feature is turned on (indicated by the config config_stopSystemPackagesByDefault in
core/res/res/values/config.xml) packages on the system partition that are encountered by
the PackageManagerService for the first time are scanned in the "stopped" state. This allowlist
is also considered while creating new users on the device. Stopped state is not set during
subsequent reboots.

Example usage
    1. <initial-package-state package="com.example.app" stopped="false"/>
        Indicates that a system package - com.example.app's initial stopped state should not be set
        by the Package Manager. By default, system apps are marked as stopped.
    2. <initial-package-state package="com.example.app" stopped="true"/>
        Indicates that a system package - com.example.app's initial state should be set by the
        Package Manager to "stopped=true". It will have the same effect on the
        package's stopped state even if this package was not included in the allow list.
    3. <initial-package-state package="com.example.app"/>
        Invalid usage.
-->

<config></config>
+22 −0
Original line number Original line Diff line number Diff line
@@ -333,6 +333,11 @@ public class SystemConfig {
    // Update ownership for system applications and the installers eligible to update them.
    // Update ownership for system applications and the installers eligible to update them.
    private final ArrayMap<String, String> mUpdateOwnersForSystemApps = new ArrayMap<>();
    private final ArrayMap<String, String> 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<String> mInitialNonStoppedSystemPackages = new ArraySet<>();

    /**
    /**
     * Map of system pre-defined, uniquely named actors; keys are namespace,
     * Map of system pre-defined, uniquely named actors; keys are namespace,
     * value maps actor name to package name.
     * value maps actor name to package name.
@@ -527,6 +532,10 @@ public class SystemConfig {
                ? null : mOverlayConfigSignaturePackage;
                ? null : mOverlayConfigSignaturePackage;
    }
    }


    public Set<String> getInitialNonStoppedSystemPackages() {
        return mInitialNonStoppedSystemPackages;
    }

    /**
    /**
     * Only use for testing. Do NOT use in production code.
     * Only use for testing. Do NOT use in production code.
     * @param readPermissions false to create an empty SystemConfig; true to read the permissions.
     * @param readPermissions false to create an empty SystemConfig; true to read the permissions.
@@ -1445,6 +1454,19 @@ public class SystemConfig {
                        }
                        }
                        XmlUtils.skipCurrentTag(parser);
                        XmlUtils.skipCurrentTag(parser);
                    } break;
                    } 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: {
                    default: {
                        Slog.w(TAG, "Tag " + name + " is unknown in "
                        Slog.w(TAG, "Tag " + name + " is unknown in "
                                + permFile + " at " + parser.getPositionDescription());
                                + permFile + " at " + parser.getPositionDescription());
Loading