Merge "Add get-disabled shell command to locksettings" into oc-mr1-dev

This commit is contained in:
Chavi Weingarten
2017-08-25 16:28:14 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 1 deletions

View File

@@ -34,6 +34,8 @@ public final class LockSettingsCmd extends BaseCommand {
" locksettings set-password [--old OLD_CREDENTIAL] NEW_PASSWORD\n" +
" locksettings clear [--old OLD_CREDENTIAL]\n" +
" locksettings verify [--old OLD_CREDENTIAL]\n" +
" locksettings set-disabled DISABLED\n" +
" locksettings get-disabled\n" +
"\n" +
"flags: \n" +
" --user USER_ID: specify the user, default value is current user\n" +
@@ -50,7 +52,11 @@ public final class LockSettingsCmd extends BaseCommand {
"\n" +
"locksettings clear: clears the unlock credential\n" +
"\n" +
"locksettings verify: verifies the credential and unlocks the user\n";
"locksettings verify: verifies the credential and unlocks the user\n" +
"\n" +
"locksettings set-disabled: sets whether the lock screen should be disabled\n" +
"\n" +
"locksettings get-disabled: retrieves whether the lock screen is disabled\n";
public static void main(String[] args) {
(new LockSettingsCmd()).run(args);

View File

@@ -37,6 +37,7 @@ class LockSettingsShellCommand extends ShellCommand {
private static final String COMMAND_SP = "sp";
private static final String COMMAND_SET_DISABLED = "set-disabled";
private static final String COMMAND_VERIFY = "verify";
private static final String COMMAND_GET_DISABLED = "get-disabled";
private int mCurrentUserId;
private final LockPatternUtils mLockPatternUtils;
@@ -80,6 +81,9 @@ class LockSettingsShellCommand extends ShellCommand {
case COMMAND_VERIFY:
runVerify();
break;
case COMMAND_GET_DISABLED:
runGetDisabled();
break;
default:
getErrPrintWriter().println("Unknown command: " + cmd);
break;
@@ -156,6 +160,11 @@ class LockSettingsShellCommand extends ShellCommand {
getOutPrintWriter().println("Lock screen disabled set to " + disabled);
}
private void runGetDisabled() {
boolean isLockScreenDisabled = mLockPatternUtils.isLockScreenDisabled(mCurrentUserId);
getOutPrintWriter().println(isLockScreenDisabled);
}
private boolean checkCredential() throws RemoteException {
final boolean havePassword = mLockPatternUtils.isLockPasswordEnabled(mCurrentUserId);
final boolean havePattern = mLockPatternUtils.isLockPatternEnabled(mCurrentUserId);