Init the role holder package names in the app restriction controller

Bug: 228484169
Test: dumpsys activity -a
Change-Id: I8d20398b13ca146e73715fffb3ba1e988c2fa47d
This commit is contained in:
Jing Ji
2022-04-12 18:27:47 -07:00
parent f1f03b8f38
commit d6a9e089ef

View File

@@ -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);