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

Commit a01706d6 authored by Jing Ji's avatar Jing Ji Committed by Automerger Merge Worker
Browse files

Merge "Init the role holder package names in the app restriction controller"...

Merge "Init the role holder package names in the app restriction controller" into tm-dev am: 5f17b13a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17730042



Change-Id: Ia7970435ed95d385a53721413dc3af069c2fecc3
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 2d1b010c 5f17b13a
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -223,6 +223,11 @@ public final class AppRestrictionController {
    private static final String ATTR_LEVEL_TS = "levelts";
    private static final String ATTR_REASON = "reason";

    private static final String[] ROLES_IN_INTEREST = {
        RoleManager.ROLE_DIALER,
        RoleManager.ROLE_EMERGENCY,
    };

    private final Context mContext;
    private final HandlerThread mBgHandlerThread;
    private final BgHandler mBgHandler;
@@ -1386,6 +1391,7 @@ public final class AppRestrictionController {
        initBgRestrictionExemptioFromSysConfig();
        initRestrictionStates();
        initSystemModuleNames();
        initRolesInInterest();
        registerForUidObservers();
        registerForSystemBroadcasts();
        mNotificationHelper.onSystemReady();
@@ -2666,6 +2672,18 @@ public final class AppRestrictionController {
        }
    }

    private void initRolesInInterest() {
        final int[] allUsers = mInjector.getUserManagerInternal().getUserIds();
        for (String role : ROLES_IN_INTEREST) {
            if (mInjector.getRoleManager().isRoleAvailable(role)) {
                for (int userId : allUsers) {
                    final UserHandle user = UserHandle.of(userId);
                    onRoleHoldersChanged(role, user);
                }
            }
        }
    }

    private void onRoleHoldersChanged(@NonNull String roleName, @NonNull UserHandle user) {
        final List<String> rolePkgs = mInjector.getRoleManager().getRoleHoldersAsUser(
                roleName, user);