Reset mTargetUserId and dismiss UserSwitchingDialog if startUser fails
UserController.switchUser and UserController.startUserInternal both share a validation check logic but the validation code is duplicated. When switching a user, switchUser runs the validation checks, and if they pass it sets mTargetUserId and starts a call chain that eventually calls startUserInternal. Currently the validation checks are in sync, but if some other validation would be added to startUserInternal but not in switchUser we would end up with a wrong mTargetUserId and an undismissed UserSwitchingDialog. If UserSwitchingDialog is not dismissed, device would be unusable. If mTargetUserId holds wrong value, ActivityManager.getCurrentUser() would return a wrong current user id since the call chain ends in UserController.getCurrentOrTargetUserId(), which would return the mTargetUserId since it won't be UserHandle.USER_NULL. This CL resets mTargetUserId and dismisses UserSwitchingDialog if UserController.startUserInForeground() fails. Bug: 264999003 Test: atest FrameworksServicesTests:UserControllerTest Change-Id: I308cc017518a0899b10fc87a86273a9e84f6b70f
Loading
Please register or sign in to comment