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

Commit 55c7b67d authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

DO NOT MERGE - Enable blacklist for headless system user am: f8c0b315

Change-Id: I9da9ffcb0f8498b3a01295c23e3c78d4f85dbb20
parents ebda19f6 f8c0b315
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1274,6 +1274,16 @@ public class UserManager {
        return RoSystemProperties.FW_SYSTEM_USER_SPLIT;
    }

    /**
     * @hide
     * @return Whether the device is running in a headless system user mode. It means the headless
     * user (system user) runs system services and system UI, but is not associated with any real
     * person. Secondary users can be created to be associated with real person.
     */
    public static boolean isHeadlessSystemUserMode() {
        return RoSystemProperties.MULTIUSER_HEADLESS_SYSTEM_USER;
    }

    /**
     * @return Whether guest user is always ephemeral
     * @hide
+28 −19
Original line number Diff line number Diff line
@@ -2363,29 +2363,38 @@ public class PackageManagerService extends IPackageManager.Stub
    }
    private void enableSystemUserPackages() {
        if (!UserManager.isSplitSystemUser()) {
        boolean isHeadlessSystemUserMode = UserManager.isHeadlessSystemUserMode();
        if (!isHeadlessSystemUserMode && !UserManager.isSplitSystemUser()) {
            return;
        }
        // For system user, enable apps based on the following conditions:
        // - app is whitelisted or belong to one of these groups:
        Set<String> enableApps = new ArraySet<>();
        AppsQueryHelper queryHelper = new AppsQueryHelper(this);
        List<String> allAps = queryHelper.queryApps(0, /* systemAppsOnly */ false,
                UserHandle.SYSTEM);
        if (isHeadlessSystemUserMode) {
            enableApps.addAll(allAps);
        } else {
            // For split system user, select apps based on the following conditions:
            //   -- system app which has no launcher icons
            //   -- system app which has INTERACT_ACROSS_USERS permission
            //   -- system IME app
        // - app is not in the blacklist
        AppsQueryHelper queryHelper = new AppsQueryHelper(this);
        Set<String> enableApps = new ArraySet<>();
            enableApps.addAll(queryHelper.queryApps(AppsQueryHelper.GET_NON_LAUNCHABLE_APPS
                    | AppsQueryHelper.GET_APPS_WITH_INTERACT_ACROSS_USERS_PERM
                    | AppsQueryHelper.GET_IMES, /* systemAppsOnly */ true, UserHandle.SYSTEM));
        ArraySet<String> wlApps = SystemConfig.getInstance().getSystemUserWhitelistedApps();
        enableApps.addAll(wlApps);
            enableApps.addAll(queryHelper.queryApps(AppsQueryHelper.GET_REQUIRED_FOR_SYSTEM_USER,
                    /* systemAppsOnly */ false, UserHandle.SYSTEM));
            // Apply whitelist for split system user
            ArraySet<String> wlApps = SystemConfig.getInstance().getSystemUserWhitelistedApps();
            enableApps.addAll(wlApps);
        }
        // Apply blacklist for split system user/headless system user
        ArraySet<String> blApps = SystemConfig.getInstance().getSystemUserBlacklistedApps();
        enableApps.removeAll(blApps);
        Log.i(TAG, "Applications installed for system user: " + enableApps);
        List<String> allAps = queryHelper.queryApps(0, /* systemAppsOnly */ false,
                UserHandle.SYSTEM);
        Log.i(TAG, "Blacklisted packages: " + blApps);
        final int allAppsSize = allAps.size();
        synchronized (mPackages) {
            for  (int i = 0; i < allAppsSize; i++) {