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

Commit 5f679b21 authored by Pavel Grafov's avatar Pavel Grafov
Browse files

Add credential verification command to locksetting.

This is useful when we need to unlock the user in a test.
Currently credential verification is done for any command
(e.g. "clear") when "--old" parameter is provided, so this
CL doesn't add anything new really, just makes it official.

Test: adb shell locksettings set-pin 1111
Test: adb shell locksettings verify --old 1111
Bug: 36608972
Change-Id: I3fdd6a309479739567622285945d17bb3acf972e
parent da149534
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -33,6 +33,10 @@ public final class LockSettingsCmd extends BaseCommand {
            "       locksettings set-pin [--old OLD_CREDENTIAL] NEW_PIN\n" +
            "       locksettings set-password [--old OLD_CREDENTIAL] NEW_PASSWORD\n" +
            "       locksettings clear [--old OLD_CREDENTIAL]\n" +
            "       locksettings verify [--old OLD_CREDENTIAL]\n" +
            "\n" +
            "flags: \n" +
            "       --user USER_ID: specify the user, default value is current user\n" +
            "\n" +
            "locksettings set-pattern: sets a pattern\n" +
            "    A pattern is specified by a non-separated list of numbers that index the cell\n" +
@@ -44,7 +48,9 @@ public final class LockSettingsCmd extends BaseCommand {
            "\n" +
            "locksettings set-password: sets a password\n" +
            "\n" +
            "locksettings clear: clears the unlock credential\n";
            "locksettings clear: clears the unlock credential\n" +
            "\n" +
            "locksettings verify: verifies the credential and unlocks the user\n";

    public static void main(String[] args) {
        (new LockSettingsCmd()).run(args);
+9 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ class LockSettingsShellCommand extends ShellCommand {
    private static final String COMMAND_CLEAR = "clear";
    private static final String COMMAND_SP = "sp";
    private static final String COMMAND_SET_DISABLED = "set-disabled";
    private static final String COMMAND_VERIFY = "verify";

    private int mCurrentUserId;
    private final LockPatternUtils mLockPatternUtils;
@@ -76,6 +77,9 @@ class LockSettingsShellCommand extends ShellCommand {
                case COMMAND_SET_DISABLED:
                    runSetDisabled();
                    break;
                case COMMAND_VERIFY:
                    runVerify();
                    break;
                default:
                    getErrPrintWriter().println("Unknown command: " + cmd);
                    break;
@@ -88,6 +92,11 @@ class LockSettingsShellCommand extends ShellCommand {
        }
    }

    private void runVerify() {
        // The command is only run if the credential is correct.
        getOutPrintWriter().println("Lock credential verified successfully");
    }

    @Override
    public void onHelp() {
    }