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

Commit 88c11506 authored by Patrick Baumann's avatar Patrick Baumann
Browse files

Remove then add during replace to reset vis

This change adds a special case to remove a package from the apps filter
just before adding it during a replace action to ensure we wipe any
no-longer-valid visibility grants. This was broken when we moved the
removePackage call to account for packages that are removed with
KEEP_DATA set. To account for both scenarios, we added make an
additional call for the replace case.

Fixes: 159732800
Test: atest AppEnumerationTests
Change-Id: I031c634986b0666163f0292070be31c33461b9bc
parent 8d139f6a
Loading
Loading
Loading
Loading
+15 −1
Original line number Original line Diff line number Diff line
@@ -495,10 +495,15 @@ public class AppsFilter {
     * Adds a package that should be considered when filtering visibility between apps.
     * Adds a package that should be considered when filtering visibility between apps.
     *
     *
     * @param newPkgSetting the new setting being added
     * @param newPkgSetting the new setting being added
     * @param isReplace if the package is being replaced and may need extra cleanup.
     */
     */
    public void addPackage(PackageSetting newPkgSetting) {
    public void addPackage(PackageSetting newPkgSetting, boolean isReplace) {
        Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "filter.addPackage");
        Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "filter.addPackage");
        try {
        try {
            if (isReplace) {
                // let's first remove any prior rules for this package
                removePackage(newPkgSetting);
            }
            mStateProvider.runWithState((settings, users) -> {
            mStateProvider.runWithState((settings, users) -> {
                addPackageInternal(newPkgSetting, settings);
                addPackageInternal(newPkgSetting, settings);
                if (mShouldFilterCache != null) {
                if (mShouldFilterCache != null) {
@@ -776,6 +781,15 @@ public class AppsFilter {
        return result;
        return result;
    }
    }


    /**
     * Equivalent to calling {@link #addPackage(PackageSetting, boolean)} with {@code isReplace}
     * equal to {@code false}.
     * @see AppsFilter#addPackage(PackageSetting, boolean)
     */
    public void addPackage(PackageSetting newPkgSetting) {
        addPackage(newPkgSetting, false /* isReplace */);
    }

    /**
    /**
     * Removes a package for consideration when filtering visibility between apps.
     * Removes a package for consideration when filtering visibility between apps.
     *
     *
+3 −1
Original line number Original line Diff line number Diff line
@@ -12366,7 +12366,9 @@ public class PackageManagerService extends IPackageManager.Stub
            ksms.addScannedPackageLPw(pkg);
            ksms.addScannedPackageLPw(pkg);
            mComponentResolver.addAllComponents(pkg, chatty);
            mComponentResolver.addAllComponents(pkg, chatty);
            mAppsFilter.addPackage(pkgSetting);
            final boolean isReplace =
                    reconciledPkg.prepareResult != null && reconciledPkg.prepareResult.replace;
            mAppsFilter.addPackage(pkgSetting, isReplace);
            // Don't allow ephemeral applications to define new permissions groups.
            // Don't allow ephemeral applications to define new permissions groups.
            if ((scanFlags & SCAN_AS_INSTANT_APP) != 0) {
            if ((scanFlags & SCAN_AS_INSTANT_APP) != 0) {