Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f8a1028 authored by Nicholas Sauer's avatar Nicholas Sauer
Browse files

Handle "--user current" and other valid users in the AccountManagerServiceShellCommand.

UserHandle.parseUserArg supports special params all and current.

See also: ag/9150276

bug: 139034865
Test: $ adb shell am get-current-user
10
$ adb shell cmd account set-bind-instant-service-allowed true
$ adb shell cmd account get-bind-instant-service-allowed
true
$ adb shell cmd account get-bind-instant-service-allowed --user 0
false
$ adb shell cmd account get-bind-instant-service-allowed --user 10
true
$ adb shell cmd account get-bind-instant-service-allowed --user current
true
$ adb shell cmd account set-bind-instant-service-allowed false
$ adb shell cmd account get-bind-instant-service-allowed --user 10
false
$ adb shell cmd account get-bind-instant-service-allowed --user current
false

Change-Id: I3a74aaa0dc83f8fb8b51225dfd33db184ddbde04
parent 703ce15f
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -78,7 +78,18 @@ final class AccountManagerServiceShellCommand extends ShellCommand {
        final String option = getNextOption();
        if (option != null) {
            if (option.equals("--user")) {
                return UserHandle.parseUserArg(getNextArgRequired());
                int userId = UserHandle.parseUserArg(getNextArgRequired());
                if (userId == UserHandle.USER_CURRENT) {
                    return ActivityManager.getCurrentUser();
                } else if (userId == UserHandle.USER_ALL) {
                    getErrPrintWriter().println("USER_ALL not supported. Specify a user.");
                    return null;
                } else if (userId < 0) {
                    getErrPrintWriter().println("Invalid user: " + userId);
                    return null;
                } else {
                    return userId;
                }
            } else {
                getErrPrintWriter().println("Unknown option: " + option);
                return null;