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.keyguard.KeyguardSecurityModel.SecurityMode;
19 
20 public interface KeyguardSecurityCallback {
21 
22     /**
23      * Dismiss the given security screen.
24      * @param securityVerified true if the user correctly entered credentials for the given screen.
25      * @param targetUserId a user that needs to be the foreground user at the dismissal completion.
26      * @param expectedSecurityMode The security mode that is invoking this dismiss.
27      */
dismiss(boolean securityVerified, int targetUserId, SecurityMode expectedSecurityMode)28     default void dismiss(boolean securityVerified, int targetUserId,
29             SecurityMode expectedSecurityMode) {
30     }
31 
32     /**
33      * Dismiss the given security screen.
34      * @param securityVerified true if the user correctly entered credentials for the given screen.
35      * @param targetUserId a user that needs to be the foreground user at the dismissal completion.
36      * @param bypassSecondaryLockScreen true if the user can bypass the secondary lock screen,
37      *                                  if any, during this dismissal.
38      * @param expectedSecurityMode The security mode that is invoking this dismiss.
39      */
dismiss(boolean securityVerified, int targetUserId, boolean bypassSecondaryLockScreen, SecurityMode expectedSecurityMode)40     default boolean dismiss(boolean securityVerified, int targetUserId,
41             boolean bypassSecondaryLockScreen,
42             SecurityMode expectedSecurityMode) {
43         return false;
44     }
45 
46     /**
47      * Manually report user activity to keep the device awake.
48      */
userActivity()49     default void userActivity() {
50     }
51 
52     /**
53      * Checks if keyguard is in "verify credentials" mode.
54      *
55      * @return true if user has been asked to verify security.
56      */
isVerifyUnlockOnly()57     default boolean isVerifyUnlockOnly() {
58         return false;
59     }
60 
61     /**
62      * Call to report an unlock attempt.
63      * @param userId id of the user whose unlock attempt is recorded.
64      * @param success set to 'true' if user correctly entered security credentials.
65      * @param timeoutMs timeout in milliseconds to wait before reattempting an unlock.
66      *                  Only nonzero if 'success' is false
67      */
reportUnlockAttempt(int userId, boolean success, int timeoutMs)68     default void reportUnlockAttempt(int userId, boolean success, int timeoutMs) {
69     }
70 
71     /**
72      * Resets the keyguard view.
73      */
reset()74     default void reset() {
75     }
76 
77     /**
78      * Call when cancel button is pressed in bouncer.
79      */
onCancelClicked()80     default void onCancelClicked() {
81         // No-op
82     }
83 
84     /**
85      * Invoked whenever users are typing their password or drawing a pattern.
86      */
onUserInput()87     default void onUserInput() {
88     }
89 
90     /**
91      * Invoked when the auth input is disabled for specified number of seconds.
92      * @param seconds Number of seconds for which the auth input is disabled.
93      */
onAttemptLockoutStart(long seconds)94     default void onAttemptLockoutStart(long seconds) {}
95 
96     /**
97      * Dismisses keyguard and go to unlocked state.
98      */
finish(int targetUserId)99     default void finish(int targetUserId) {
100     }
101 
102     /**
103      * Specifies that security mode has changed.
104      */
onSecurityModeChanged(SecurityMode securityMode, boolean needsInput)105     default void onSecurityModeChanged(SecurityMode securityMode, boolean needsInput) {
106     }
107 
108     /**
109      * Shows the security screen that should be shown.
110      *
111      * This can be considered as a "refresh" of the bouncer view. Based on certain parameters,
112      * we might switch to a different bouncer screen. e.g. SimPin to SimPuk.
113      */
showCurrentSecurityScreen()114     default void showCurrentSecurityScreen() {
115 
116     }
117 }
118