• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License
15  */
16 
17 package com.android.commands.locksettings;
18 
19 import android.os.ResultReceiver;
20 import android.os.ServiceManager;
21 import android.os.ShellCallback;
22 
23 import com.android.internal.os.BaseCommand;
24 import com.android.internal.widget.ILockSettings;
25 
26 import java.io.FileDescriptor;
27 import java.io.PrintStream;
28 
29 public final class LockSettingsCmd extends BaseCommand {
30 
31     private static final String USAGE =
32             "usage: locksettings set-pattern [--old OLD_CREDENTIAL] NEW_PATTERN\n" +
33             "       locksettings set-pin [--old OLD_CREDENTIAL] NEW_PIN\n" +
34             "       locksettings set-password [--old OLD_CREDENTIAL] NEW_PASSWORD\n" +
35             "       locksettings clear [--old OLD_CREDENTIAL]\n" +
36             "\n" +
37             "locksettings set-pattern: sets a pattern\n" +
38             "    A pattern is specified by a non-separated list of numbers that index the cell\n" +
39             "    on the pattern in a 1-based manner in left to right and top to bottom order,\n" +
40             "    i.e. the top-left cell is indexed with 1, whereas the bottom-right cell\n" +
41             "    is indexed with 9. Example: 1234\n" +
42             "\n" +
43             "locksettings set-pin: sets a PIN\n" +
44             "\n" +
45             "locksettings set-password: sets a password\n" +
46             "\n" +
47             "locksettings clear: clears the unlock credential\n";
48 
main(String[] args)49     public static void main(String[] args) {
50         (new LockSettingsCmd()).run(args);
51     }
52 
53     @Override
onShowUsage(PrintStream out)54     public void onShowUsage(PrintStream out) {
55         out.println(USAGE);
56     }
57 
58     @Override
onRun()59     public void onRun() throws Exception {
60         ILockSettings lockSettings = ILockSettings.Stub.asInterface(
61                 ServiceManager.getService("lock_settings"));
62         lockSettings.asBinder().shellCommand(FileDescriptor.in, FileDescriptor.out,
63                 FileDescriptor.err, getRawArgs(), new ShellCallback(), new ResultReceiver(null) {});
64     }
65 }
66