Merge "Update user profiles on user unavailable" into sc-dev am: c8f4ca2a74

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

Change-Id: I7c72dbffb97b8160b7df8ba645a9aa91b8a41ac6
This commit is contained in:
Anna Zappone
2021-04-13 18:46:21 +00:00
committed by Automerger Merge Worker
2 changed files with 11 additions and 2 deletions

View File

@@ -1769,10 +1769,17 @@ abstract public class ManagedServices {
UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
if (userManager != null) {
int currentUserId = ActivityManager.getCurrentUser();
List<UserInfo> profiles = userManager.getProfiles(currentUserId);
List<UserInfo> unlockedProfiles = new ArrayList<>();
for (UserInfo user : userManager.getProfiles(currentUserId)) {
// Dependencies throw if we call APIs on a locked user. Only include
// unlocked users.
if (userManager.isUserUnlocked(user.id)) {
unlockedProfiles.add(user);
}
}
synchronized (mCurrentProfiles) {
mCurrentProfiles.clear();
for (UserInfo user : profiles) {
for (UserInfo user : unlockedProfiles) {
mCurrentProfiles.put(user.id, user);
}
}

View File

@@ -1780,6 +1780,8 @@ public class NotificationManagerService extends SystemService {
}
} else if (action.equals(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE)) {
int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
// Work profile user may now be locked. Refresh cache.
mUserProfiles.updateCache(context);
if (userHandle >= 0) {
cancelAllNotificationsInt(MY_UID, MY_PID, null, null, 0, 0, true, userHandle,
REASON_PROFILE_TURNED_OFF, null);