KeyguardSecurityCallback.java revision 34c4fe523ad96fb59cec28832b38806d04a6bebf
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 */
16dcb3d84b82cc2448d04e73359a716581bfb657dbJim Millerpackage com.android.internal.policy.impl.keyguard;
17dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
18dcb3d84b82cc2448d04e73359a716581bfb657dbJim Millerpublic interface KeyguardSecurityCallback {
19dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
2034c4fe523ad96fb59cec28832b38806d04a6bebfJohn Spurlock    /*package*/ interface OnDismissAction {
2134c4fe523ad96fb59cec28832b38806d04a6bebfJohn Spurlock
2234c4fe523ad96fb59cec28832b38806d04a6bebfJohn Spurlock        /* returns true if the dismiss should be deferred */
2334c4fe523ad96fb59cec28832b38806d04a6bebfJohn Spurlock        boolean onDismiss();
2434c4fe523ad96fb59cec28832b38806d04a6bebfJohn Spurlock    }
2534c4fe523ad96fb59cec28832b38806d04a6bebfJohn Spurlock
26dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
27dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Dismiss the given security screen.
28dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * @param securityVerified true if the user correctly entered credentials for the given screen.
29dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
30dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    void dismiss(boolean securityVerified);
31dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
32dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
33dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Manually report user activity to keep the device awake. If timeout is 0,
34dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * uses user-defined timeout.
35dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * @param timeout
36dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
37dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    void userActivity(long timeout);
38dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
39dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
40dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Checks if keyguard is in "verify credentials" mode.
41dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * @return true if user has been asked to verify security.
42dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
43dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    boolean isVerifyUnlockOnly();
44dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
45dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
46dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Call when user correctly enters their credentials
47dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
48dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    void reportSuccessfulUnlockAttempt();
49dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
50dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
51dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Call when the user incorrectly enters their credentials
52dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
53dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    void reportFailedUnlockAttempt();
54dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
55dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
56dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * Gets the number of attempts thus far as reported by {@link #reportFailedUnlockAttempt()}
57dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     * @return number of failed attempts
58dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
59dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    int getFailedAttempts();
60dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
61dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller    /**
62258341c377b6aa9f1bd29a9b507a97967e432dfeJim Miller     * Shows the backup security for the current method.  If none available, this call is a no-op.
63dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller     */
64258341c377b6aa9f1bd29a9b507a97967e432dfeJim Miller    void showBackupSecurity();
65dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller
665f75aa15d7c1c5ea1c1eecd95bf2bb0920173eb2Jim Miller    /**
6734c4fe523ad96fb59cec28832b38806d04a6bebfJohn Spurlock     * Sets an action to perform after the user successfully enters their credentials.
6834c4fe523ad96fb59cec28832b38806d04a6bebfJohn Spurlock     * @param action
695f75aa15d7c1c5ea1c1eecd95bf2bb0920173eb2Jim Miller     */
7034c4fe523ad96fb59cec28832b38806d04a6bebfJohn Spurlock    void setOnDismissAction(OnDismissAction action);
715f75aa15d7c1c5ea1c1eecd95bf2bb0920173eb2Jim Miller
72dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller}
73