• 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      * Some auth is required because the trustagent expired either from timeout or manually by the
65      * user
66      */
67     int PROMPT_REASON_TRUSTAGENT_EXPIRED = 8;
68 
69     /**
70      * Reset the view and prepare to take input. This should do things like clearing the
71      * password or pattern and clear error messages.
72      */
reset()73     void reset();
74 
75     /**
76      * Emulate activity life cycle within the view. When called, the view should clean up
77      * and prepare to be removed.
78      */
onPause()79     void onPause();
80 
81     /**
82      * Emulate activity life cycle within this view.  When called, the view should prepare itself
83      * to be shown.
84      * @param reason the root cause of the event.
85      */
onResume(int reason)86     void onResume(int reason);
87 
88     /**
89      * Inquire whether this view requires IME (keyboard) interaction.
90      *
91      * @return true if IME interaction is required.
92      */
needsInput()93     boolean needsInput();
94 
95     /**
96      * Show a string explaining why the security view needs to be solved.
97      *
98      * @param reason a flag indicating which string should be shown, see {@link #PROMPT_REASON_NONE}
99      *               and {@link #PROMPT_REASON_RESTART}
100      */
showPromptReason(int reason)101     void showPromptReason(int reason);
102 
103     /**
104      * Show a message on the security view with a specified color
105      *
106      * @param message the message to show
107      * @param colorState the color to use
108      */
showMessage(CharSequence message, ColorStateList colorState)109     void showMessage(CharSequence message, ColorStateList colorState);
110 
111     /**
112      * Starts the animation which should run when the security view appears.
113      */
startAppearAnimation()114     void startAppearAnimation();
115 
116     /**
117      * Starts the animation which should run when the security view disappears.
118      *
119      * @param finishRunnable the runnable to be run when the animation ended
120      * @return true if an animation started and {@code finishRunnable} will be run, false if no
121      *         animation started and {@code finishRunnable} will not be run
122      */
startDisappearAnimation(Runnable finishRunnable)123     boolean startDisappearAnimation(Runnable finishRunnable);
124 
125     /**
126      * The localized name of the security view, provided to accessibility. This may be the content
127      * description, but content descriptions have other implications, so the title is kept separate.
128      *
129      * @return The View's title.
130      */
getTitle()131     CharSequence getTitle();
132 
133     /**
134      * If the parent should not be allowed to intercept touch events.
135      * @param event A touch event.
136      * @return {@code true} if touch should be passed forward.
137      * @see android.view.ViewGroup#requestDisallowInterceptTouchEvent(boolean)
138      */
disallowInterceptTouch(MotionEvent event)139     default boolean disallowInterceptTouch(MotionEvent event) {
140         return false;
141     }
142 
143     /**
144      * When bouncer was visible but is being dragged down or dismissed.
145      */
onStartingToHide()146     default void onStartingToHide() {};
147 }
148