KeyguardSecurityView.java revision 25b4d4b280c6aa07656328bd9dd90977781d00e1
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    /**
37dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Interface back to keyguard to tell it when security
38dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * @param callback
39dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
40dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    void setKeyguardCallback(KeyguardSecurityCallback callback);
41dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
42dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
43dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Set {@link LockPatternUtils} object. Useful for providing a mock interface.
44dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * @param utils
45dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
46dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    void setLockPatternUtils(LockPatternUtils utils);
47dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
48dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
49dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Reset the view and prepare to take input. This should do things like clearing the
50dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * password or pattern and clear error messages.
51dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
52dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    void reset();
53dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
54dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
55dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Emulate activity life cycle within the view. When called, the view should clean up
56dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * and prepare to be removed.
57dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
58dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    void onPause();
59dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
60dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
61dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Emulate activity life cycle within this view.  When called, the view should prepare itself
62dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * to be shown.
63a042ac90640c0c3fd3c5349083b86bbfd6319b64Chris Wren     * @param reason the root cause of the event.
64dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
65a042ac90640c0c3fd3c5349083b86bbfd6319b64Chris Wren    void onResume(int reason);
66dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
67dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
68dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Inquire whether this view requires IME (keyboard) interaction.
69dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     *
70dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * @return true if IME interaction is required.
71dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
72dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    boolean needsInput();
73dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
74dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
75dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Get {@link KeyguardSecurityCallback} for the given object
76dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * @return KeyguardSecurityCallback
77dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
78dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    KeyguardSecurityCallback getCallback();
79dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
800b728244dc87b4a453f2191c2cb37a86e91aee0aJim Miller    /**
813122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek     * Show a string explaining why the security view needs to be solved.
823122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek     *
833122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek     * @param reason a flag indicating which string should be shown, see {@link #PROMPT_REASON_NONE}
843122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek     *               and {@link #PROMPT_REASON_RESTART}
853122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek     */
863122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek    void showPromptReason(int reason);
873122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek
883122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek    /**
89cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek     * Show a message on the security view with a specified color
90cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek     *
91cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek     * @param message the message to show
92cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek     * @param color the color to use
93cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek     */
94cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek    void showMessage(String message, int color);
95cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek
96cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek    /**
970b728244dc87b4a453f2191c2cb37a86e91aee0aJim Miller     * Instruct the view to show usability hints, if any.
980b728244dc87b4a453f2191c2cb37a86e91aee0aJim Miller     *
990b728244dc87b4a453f2191c2cb37a86e91aee0aJim Miller     */
1006fb841fa219eaae3e87f2fdc05e105d7a1813c42Adam Cohen    void showUsabilityHint();
101c0ae9e67ebe6f1298800feaed1b43e867139a904Chris Wren
102c0ae9e67ebe6f1298800feaed1b43e867139a904Chris Wren    /**
103c14f829506a5273e8022b461db2d61038b18ac4bJorim Jaggi     * Starts the animation which should run when the security view appears.
104c14f829506a5273e8022b461db2d61038b18ac4bJorim Jaggi     */
105c14f829506a5273e8022b461db2d61038b18ac4bJorim Jaggi    void startAppearAnimation();
10676a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi
10776a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi    /**
10876a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi     * Starts the animation which should run when the security view disappears.
10976a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi     *
11076a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi     * @param finishRunnable the runnable to be run when the animation ended
11176a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi     * @return true if an animation started and {@code finishRunnable} will be run, false if no
11276a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi     *         animation started and {@code finishRunnable} will not be run
11376a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi     */
11476a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi    boolean startDisappearAnimation(Runnable finishRunnable);
115dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller}
116