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

Commit 92b25a0e authored by Nicolas Prevot's avatar Nicolas Prevot Committed by Android (Google) Code Review
Browse files

Merge "Cleaning CrossProfileIntentFilters on user deletion."

parents dfed4bc9 a0f48855
Loading
Loading
Loading
Loading
+20 −0
Original line number Original line Diff line number Diff line
@@ -2940,6 +2940,26 @@ final class Settings {
        file.delete();
        file.delete();
        file = getUserPackagesStateBackupFile(userId);
        file = getUserPackagesStateBackupFile(userId);
        file.delete();
        file.delete();
        removeCrossProfileIntentFiltersToUserLPr(userId);
    }

    void removeCrossProfileIntentFiltersToUserLPr(int targetUserId) {
        for (int i = 0; i < mCrossProfileIntentResolvers.size(); i++) {
            int sourceUserId = mCrossProfileIntentResolvers.keyAt(i);
            CrossProfileIntentResolver cpir = mCrossProfileIntentResolvers.get(sourceUserId);
            boolean needsWriting = false;
            HashSet<CrossProfileIntentFilter> cpifs =
                    new HashSet<CrossProfileIntentFilter>(cpir.filterSet());
            for (CrossProfileIntentFilter cpif : cpifs) {
                if (cpif.getTargetUserId() == targetUserId) {
                    needsWriting = true;
                    cpir.removeFilter(cpif);
                }
            }
            if (needsWriting) {
                writePackageRestrictionsLPr(sourceUserId);
            }
        }
    }
    }


    // This should be called (at least) whenever an application is removed
    // This should be called (at least) whenever an application is removed