• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 android.content.res.ColorStateList;
19 import android.view.MotionEvent;
20 
21 public interface KeyguardSecurityView {
22     int SCREEN_ON = 1;
23     int VIEW_REVEALED = 2;
24 
25     int PROMPT_REASON_NONE = 0;
26 
27     /**
28      * Strong auth is required because the device has just booted.
29      */
30     int PROMPT_REASON_RESTART = 1;
31 
32     /**
33      * Strong auth is required because the user hasn't used strong auth since a while.
34      */
35     int PROMPT_REASON_TIMEOUT = 2;
36 
37     /**
38      * Strong auth is required because a device admin requested it.
39      */
40     int PROMPT_REASON_DEVICE_ADMIN = 3;
41 
42     /**
43      * Some auth is required because the user force locked.
44      */
45     int PROMPT_REASON_USER_REQUEST = 4;
46 
47     /**
48      * Some auth is required because too many wrong credentials led to a lockout.
49      */
50     int PROMPT_REASON_AFTER_LOCKOUT = 5;
51 
52     /***
53      * Strong auth is require to prepare for an unattended update.
54      */
55     int PROMPT_REASON_PREPARE_FOR_UPDATE = 6;
56 
57     /**
58      * Primary auth is required because the user uses weak/convenience biometrics and hasn't used
59      * primary auth since a while
60      */
61     int PROMPT_REASON_NON_STRONG_BIOMETRIC_TIMEOUT = 7;
62 
63     /**
64      * Reset the view and prepare to take input. This should do things like clearing the
65      * password or pattern and clear error messages.
66      */
reset()67     void reset();
68 
69     /**
70      * Emulate activity life cycle within the view. When called, the view should clean up
71      * and prepare to be removed.
72      */
onPause()73     void onPause();
74 
75     /**
76      * Emulate activity life cycle within this view.  When called, the view should prepare itself
77      * to be shown.
78      * @param reason the root cause of the event.
79      */
onResume(int reason)80     void onResume(int reason);
81 
82     /**
83      * Inquire whether this view requires IME (keyboard) interaction.
84      *
85      * @return true if IME interaction is required.
86      */
needsInput()87     boolean needsInput();
88 
89     /**
90      * Show a string explaining why the security view needs to be solved.
91      *
92      * @param reason a flag indicating which string should be shown, see {@link #PROMPT_REASON_NONE}
93      *               and {@link #PROMPT_REASON_RESTART}
94      */
showPromptReason(int reason)95     void showPromptReason(int reason);
96 
97     /**
98      * Show a message on the security view with a specified color
99      *
100      * @param message the message to show
101      * @param colorState the color to use
102      */
showMessage(CharSequence message, ColorStateList colorState)103     void showMessage(CharSequence message, ColorStateList colorState);
104 
105     /**
106      * Starts the animation which should run when the security view appears.
107      */
startAppearAnimation()108     void startAppearAnimation();
109 
110     /**
111      * Starts the animation which should run when the security view disappears.
112      *
113      * @param finishRunnable the runnable to be run when the animation ended
114      * @return true if an animation started and {@code finishRunnable} will be run, false if no
115      *         animation started and {@code finishRunnable} will not be run
116      */
startDisappearAnimation(Runnable finishRunnable)117     boolean startDisappearAnimation(Runnable finishRunnable);
118 
119     /**
120      * The localized name of the security view, provided to accessibility. This may be the content
121      * description, but content descriptions have other implications, so the title is kept separate.
122      *
123      * @return The View's title.
124      */
getTitle()125     CharSequence getTitle();
126 
127     /**
128      * If the parent should not be allowed to intercept touch events.
129      * @param event A touch event.
130      * @return {@code true} if touch should be passed forward.
131      * @see android.view.ViewGroup#requestDisallowInterceptTouchEvent(boolean)
132      */
disallowInterceptTouch(MotionEvent event)133     default boolean disallowInterceptTouch(MotionEvent event) {
134         return false;
135     }
136 
137     /**
138      * When bouncer was visible but is being dragged down or dismissed.
139      */
onStartingToHide()140     default void onStartingToHide() {};
141 }
142