1dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller/*
2dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * Copyright (C) 2012 The Android Open Source Project
3dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller *
4dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * Licensed under the Apache License, Version 2.0 (the "License");
5dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * you may not use this file except in compliance with the License.
6dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * You may obtain a copy of the License at
7dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller *
8dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller *      http://www.apache.org/licenses/LICENSE-2.0
9dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller *
10dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * Unless required by applicable law or agreed to in writing, software
11dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * distributed under the License is distributed on an "AS IS" BASIS,
12dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * See the License for the specific language governing permissions and
14dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * limitations under the License.
15dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller */
165ecd81154fa039961f65bb4e36d18ac555b0d1d6Jim Millerpackage com.android.keyguard;
17dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
18dcb3d84b82cc2448d04e73359a716581bfb657dbJim Millerimport com.android.internal.widget.LockPatternUtils;
19dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
20dcb3d84b82cc2448d04e73359a716581bfb657dbJim Millerpublic interface KeyguardSecurityView {
21a042ac90640c0c3fd3c5349083b86bbfd6319b64Chris Wren    static public final int SCREEN_ON = 1;
22a042ac90640c0c3fd3c5349083b86bbfd6319b64Chris Wren    static public final int VIEW_REVEALED = 2;
23a042ac90640c0c3fd3c5349083b86bbfd6319b64Chris Wren
243122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek    int PROMPT_REASON_NONE = 0;
2525b4d4b280c6aa07656328bd9dd90977781d00e1Jorim Jaggi
2625b4d4b280c6aa07656328bd9dd90977781d00e1Jorim Jaggi    /**
2725b4d4b280c6aa07656328bd9dd90977781d00e1Jorim Jaggi     * Strong auth is required because the device has just booted.
2825b4d4b280c6aa07656328bd9dd90977781d00e1Jorim Jaggi     */
293122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek    int PROMPT_REASON_RESTART = 1;
303122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek
31dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
3225b4d4b280c6aa07656328bd9dd90977781d00e1Jorim Jaggi     * Strong auth is required because the user hasn't used strong auth since a while.
3325b4d4b280c6aa07656328bd9dd90977781d00e1Jorim Jaggi     */
3425b4d4b280c6aa07656328bd9dd90977781d00e1Jorim Jaggi    int PROMPT_REASON_TIMEOUT = 2;
3525b4d4b280c6aa07656328bd9dd90977781d00e1Jorim Jaggi
3625b4d4b280c6aa07656328bd9dd90977781d00e1Jorim Jaggi    /**
37c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos     * Strong auth is required because a device admin requested it.
38c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos     */
39c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos    int PROMPT_REASON_DEVICE_ADMIN = 3;
40c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos
41c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos    /**
42c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos     * Some auth is required because the user force locked.
43c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos     */
44c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos    int PROMPT_REASON_USER_REQUEST = 4;
45c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos
46c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos    /**
47c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos     * Some auth is required because too many wrong credentials led to a lockout.
48c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos     */
49c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos    int PROMPT_REASON_AFTER_LOCKOUT = 5;
50c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos
51c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos    /**
52dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Interface back to keyguard to tell it when security
53dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * @param callback
54dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
55dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    void setKeyguardCallback(KeyguardSecurityCallback callback);
56dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
57dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
58dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Set {@link LockPatternUtils} object. Useful for providing a mock interface.
59dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * @param utils
60dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
61dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    void setLockPatternUtils(LockPatternUtils utils);
62dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
63dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
64dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Reset the view and prepare to take input. This should do things like clearing the
65dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * password or pattern and clear error messages.
66dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
67dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    void reset();
68dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
69dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
70dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Emulate activity life cycle within the view. When called, the view should clean up
71dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * and prepare to be removed.
72dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
73dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    void onPause();
74dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
75dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
76dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Emulate activity life cycle within this view.  When called, the view should prepare itself
77dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * to be shown.
78a042ac90640c0c3fd3c5349083b86bbfd6319b64Chris Wren     * @param reason the root cause of the event.
79dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
80a042ac90640c0c3fd3c5349083b86bbfd6319b64Chris Wren    void onResume(int reason);
81dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
82dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
83dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Inquire whether this view requires IME (keyboard) interaction.
84dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     *
85dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * @return true if IME interaction is required.
86dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
87dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    boolean needsInput();
88dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
89dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
90dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Get {@link KeyguardSecurityCallback} for the given object
91dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * @return KeyguardSecurityCallback
92dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
93dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    KeyguardSecurityCallback getCallback();
94dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
950b728244dc87b4a453f2191c2cb37a86e91aee0aJim Miller    /**
963122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek     * Show a string explaining why the security view needs to be solved.
973122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek     *
983122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek     * @param reason a flag indicating which string should be shown, see {@link #PROMPT_REASON_NONE}
993122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek     *               and {@link #PROMPT_REASON_RESTART}
1003122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek     */
1013122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek    void showPromptReason(int reason);
1023122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek
1033122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek    /**
104cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek     * Show a message on the security view with a specified color
105cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek     *
106cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek     * @param message the message to show
107cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek     * @param color the color to use
108cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek     */
109cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek    void showMessage(String message, int color);
110cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek
111cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek    /**
1120b728244dc87b4a453f2191c2cb37a86e91aee0aJim Miller     * Instruct the view to show usability hints, if any.
1130b728244dc87b4a453f2191c2cb37a86e91aee0aJim Miller     *
1140b728244dc87b4a453f2191c2cb37a86e91aee0aJim Miller     */
1156fb841fa219eaae3e87f2fdc05e105d7a1813c42Adam Cohen    void showUsabilityHint();
116c0ae9e67ebe6f1298800feaed1b43e867139a904Chris Wren
117c0ae9e67ebe6f1298800feaed1b43e867139a904Chris Wren    /**
118c14f829506a5273e8022b461db2d61038b18ac4bJorim Jaggi     * Starts the animation which should run when the security view appears.
119c14f829506a5273e8022b461db2d61038b18ac4bJorim Jaggi     */
120c14f829506a5273e8022b461db2d61038b18ac4bJorim Jaggi    void startAppearAnimation();
12176a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi
12276a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi    /**
12376a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi     * Starts the animation which should run when the security view disappears.
12476a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi     *
12576a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi     * @param finishRunnable the runnable to be run when the animation ended
12676a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi     * @return true if an animation started and {@code finishRunnable} will be run, false if no
12776a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi     *         animation started and {@code finishRunnable} will not be run
12876a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi     */
12976a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi    boolean startDisappearAnimation(Runnable finishRunnable);
130dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller}
131