1 /*
2  * Copyright (C) 2012 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 package com.android.keyguard;
17 
18 import com.android.internal.widget.LockPatternUtils;
19 
20 public interface KeyguardSecurityView {
21     static public final int SCREEN_ON = 1;
22     static public final int VIEW_REVEALED = 2;
23 
24     int PROMPT_REASON_NONE = 0;
25 
26     /**
27      * Strong auth is required because the device has just booted.
28      */
29     int PROMPT_REASON_RESTART = 1;
30 
31     /**
32      * Strong auth is required because the user hasn't used strong auth since a while.
33      */
34     int PROMPT_REASON_TIMEOUT = 2;
35 
36     /**
37      * Strong auth is required because a device admin requested it.
38      */
39     int PROMPT_REASON_DEVICE_ADMIN = 3;
40 
41     /**
42      * Some auth is required because the user force locked.
43      */
44     int PROMPT_REASON_USER_REQUEST = 4;
45 
46     /**
47      * Some auth is required because too many wrong credentials led to a lockout.
48      */
49     int PROMPT_REASON_AFTER_LOCKOUT = 5;
50 
51     /**
52      * Some auth is required because a single wrong credential has been tried.
53      */
54     int PROMPT_REASON_WRONG_CREDENTIAL = 6;
55 
56     /**
57      * Interface back to keyguard to tell it when security
58      * @param callback
59      */
setKeyguardCallback(KeyguardSecurityCallback callback)60     void setKeyguardCallback(KeyguardSecurityCallback callback);
61 
62     /**
63      * Set {@link LockPatternUtils} object. Useful for providing a mock interface.
64      * @param utils
65      */
setLockPatternUtils(LockPatternUtils utils)66     void setLockPatternUtils(LockPatternUtils utils);
67 
68     /**
69      * Reset the view and prepare to take input. This should do things like clearing the
70      * password or pattern and clear error messages.
71      */
reset()72     void reset();
73 
74     /**
75      * Emulate activity life cycle within the view. When called, the view should clean up
76      * and prepare to be removed.
77      */
onPause()78     void onPause();
79 
80     /**
81      * Emulate activity life cycle within this view.  When called, the view should prepare itself
82      * to be shown.
83      * @param reason the root cause of the event.
84      */
onResume(int reason)85     void onResume(int reason);
86 
87     /**
88      * Inquire whether this view requires IME (keyboard) interaction.
89      *
90      * @return true if IME interaction is required.
91      */
needsInput()92     boolean needsInput();
93 
94     /**
95      * Get {@link KeyguardSecurityCallback} for the given object
96      * @return KeyguardSecurityCallback
97      */
getCallback()98     KeyguardSecurityCallback getCallback();
99 
100     /**
101      * Show a string explaining why the security view needs to be solved.
102      *
103      * @param reason a flag indicating which string should be shown, see {@link #PROMPT_REASON_NONE}
104      *               and {@link #PROMPT_REASON_RESTART}
105      */
showPromptReason(int reason)106     void showPromptReason(int reason);
107 
108     /**
109      * Show a message on the security view with a specified color
110      *
111      * @param message the message to show
112      * @param color the color to use
113      */
showMessage(String message, int color)114     void showMessage(String message, int color);
115 
116     /**
117      * Instruct the view to show usability hints, if any.
118      *
119      */
showUsabilityHint()120     void showUsabilityHint();
121 
122     /**
123      * Starts the animation which should run when the security view appears.
124      */
startAppearAnimation()125     void startAppearAnimation();
126 
127     /**
128      * Starts the animation which should run when the security view disappears.
129      *
130      * @param finishRunnable the runnable to be run when the animation ended
131      * @return true if an animation started and {@code finishRunnable} will be run, false if no
132      *         animation started and {@code finishRunnable} will not be run
133      */
startDisappearAnimation(Runnable finishRunnable)134     boolean startDisappearAnimation(Runnable finishRunnable);
135 }
136