Merge "Fix keyboard settings crash in multi-user case" into tm-dev am: 897b72eb1b

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/17539524

Change-Id: Ic85e2d289ad3955e7d972af830d9e1b2256217a1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-04-08 08:28:07 +00:00
committed by Automerger Merge Worker

View File

@@ -74,15 +74,11 @@ public class AvailableVirtualKeyboardFragment extends DashboardFragment
final Context newUserAwareContext;
switch (profileType) {
case ProfileSelectFragment.ProfileType.WORK: {
final UserHandle workUser;
if (currentUserId == UserHandle.MIN_SECONDARY_USER_ID) {
newUserId = currentUserId;
workUser = UserHandle.of(currentUserId);
} else {
newUserId = Utils.getManagedProfileId(userManager, currentUserId);
workUser = Utils.getManagedProfile(userManager);
}
newUserAwareContext = context.createContextAsUser(workUser, 0);
// If the user is a managed profile user, use currentUserId directly. Or get the
// managed profile userId instead.
newUserId = userManager.isManagedProfile()
? currentUserId : Utils.getManagedProfileId(userManager, currentUserId);
newUserAwareContext = context.createContextAsUser(UserHandle.of(newUserId), 0);
break;
}
case ProfileSelectFragment.ProfileType.PERSONAL: {