OSDN Git Service

Add get-disabled shell command to locksettings
authorchaviw <chaviw@google.com>
Mon, 21 Aug 2017 17:46:11 +0000 (10:46 -0700)
committerchaviw <chaviw@google.com>
Thu, 24 Aug 2017 21:27:36 +0000 (14:27 -0700)
Added shell command that outputs whether the lock screen is disabled.

Test: Ran "adb shell locksettings get-disabled" while phone had lock
screen and when it did not.
Merged-In: I3532e41e2ee4770bd0801dd431fdbc884c2bafa4
Fixes: 64848695

Change-Id: I3532e41e2ee4770bd0801dd431fdbc884c2bafa4

cmds/locksettings/src/com/android/commands/locksettings/LockSettingsCmd.java
services/core/java/com/android/server/locksettings/LockSettingsShellCommand.java

index b9fedd3..6a4a4be 100644 (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);
index d39679d..4d2cf32 100644 (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);