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

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

Change-Id: Icefe15ad100c309528869df18984baf698eea3ab
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jing Ji
2022-04-13 18:18:11 +00:00
committed by Automerger Merge Worker

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