Fix keyboard settings crash in multi-user case
We have CL[1] to fix the NPE when keyboard settings is launched by work app. CL[1] overlooked the work profile with multi-user case. Work profile user ID is not available(return null) when calling Utils#getManagedProfile by work identity. For work case, distinguish it's running on managed profile user(launched by work app) or not. And use corresponding userId as: -. If it's a managed profile user, use currentUserId. -. For a owner user, get managed profile userId. [1]: Iea573922ee789d9932c0de05bf71179c4f005eeb Bug: 216395439 Test: Manual test with bugs steps Test: make RunSettingsRoboTests ROBOTEST_FILTER=AvailableVirtualKeyboardFragmentTest Change-Id: If018d2fddbbcf932927d2235bb8e99393df1e67c
This commit is contained in:
@@ -74,15 +74,11 @@ public class AvailableVirtualKeyboardFragment extends DashboardFragment
|
|||||||
final Context newUserAwareContext;
|
final Context newUserAwareContext;
|
||||||
switch (profileType) {
|
switch (profileType) {
|
||||||
case ProfileSelectFragment.ProfileType.WORK: {
|
case ProfileSelectFragment.ProfileType.WORK: {
|
||||||
final UserHandle workUser;
|
// If the user is a managed profile user, use currentUserId directly. Or get the
|
||||||
if (currentUserId == UserHandle.MIN_SECONDARY_USER_ID) {
|
// managed profile userId instead.
|
||||||
newUserId = currentUserId;
|
newUserId = userManager.isManagedProfile()
|
||||||
workUser = UserHandle.of(currentUserId);
|
? currentUserId : Utils.getManagedProfileId(userManager, currentUserId);
|
||||||
} else {
|
newUserAwareContext = context.createContextAsUser(UserHandle.of(newUserId), 0);
|
||||||
newUserId = Utils.getManagedProfileId(userManager, currentUserId);
|
|
||||||
workUser = Utils.getManagedProfile(userManager);
|
|
||||||
}
|
|
||||||
newUserAwareContext = context.createContextAsUser(workUser, 0);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ProfileSelectFragment.ProfileType.PERSONAL: {
|
case ProfileSelectFragment.ProfileType.PERSONAL: {
|
||||||
|
Reference in New Issue
Block a user