Fix pm create-user when creating user with profile of cur

Use translateUserId to convert USER_CURRENT to the actual current user
id when creating a user with cur or current.

Bug: 191043371
Test: adb shell pm create-user succesfully creates with current as
	profile
Change-Id: Idfbf65b3afee2aa7db627e9b46abd8a025e4e8ab
This commit is contained in:
William Loh
2022-03-30 19:08:23 +00:00
parent c80324f62a
commit 2b26fe2815

View File

@@ -2675,7 +2675,8 @@ class PackageManagerShellCommand extends ShellCommand {
while ((opt = getNextOption()) != null) {
String newUserType = null;
if ("--profileOf".equals(opt)) {
userId = UserHandle.parseUserArg(getNextArgRequired());
userId = translateUserId(UserHandle.parseUserArg(getNextArgRequired()),
UserHandle.USER_ALL, "runCreateUser");
} else if ("--managed".equals(opt)) {
newUserType = UserManager.USER_TYPE_PROFILE_MANAGED;
} else if ("--restricted".equals(opt)) {