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

Commit a0f48855 authored by Nicolas Prevot's avatar Nicolas Prevot
Browse files

Cleaning CrossProfileIntentFilters on user deletion.

When a user is deleted, remove all CrossProfileIntentFilters that have this user as their target.

Change-Id: I1cac3ecc0c053ee129d7f0ad13648f44737a378d
parent 8b268f24
Loading
Loading
Loading
Loading
+20 −0
Original line number Original line Diff line number Diff line
@@ -2939,6 +2939,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