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 */ 165ecd81154fa039961f65bb4e36d18ac555b0d1d6Jim Millerpackage com.android.keyguard; 17dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller 18dcb3d84b82cc2448d04e73359a716581bfb657dbJim Millerimport com.android.internal.widget.LockPatternUtils; 19dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller 20dcb3d84b82cc2448d04e73359a716581bfb657dbJim Millerpublic interface KeyguardSecurityView { 21a042ac90640c0c3fd3c5349083b86bbfd6319b64Chris Wren static public final int SCREEN_ON = 1; 22a042ac90640c0c3fd3c5349083b86bbfd6319b64Chris Wren static public final int VIEW_REVEALED = 2; 23a042ac90640c0c3fd3c5349083b86bbfd6319b64Chris Wren 243122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek int PROMPT_REASON_NONE = 0; 2525b4d4b280c6aa07656328bd9dd90977781d00e1Jorim Jaggi 2625b4d4b280c6aa07656328bd9dd90977781d00e1Jorim Jaggi /** 2725b4d4b280c6aa07656328bd9dd90977781d00e1Jorim Jaggi * Strong auth is required because the device has just booted. 2825b4d4b280c6aa07656328bd9dd90977781d00e1Jorim Jaggi */ 293122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek int PROMPT_REASON_RESTART = 1; 303122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek 31dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller /** 3225b4d4b280c6aa07656328bd9dd90977781d00e1Jorim Jaggi * Strong auth is required because the user hasn't used strong auth since a while. 3325b4d4b280c6aa07656328bd9dd90977781d00e1Jorim Jaggi */ 3425b4d4b280c6aa07656328bd9dd90977781d00e1Jorim Jaggi int PROMPT_REASON_TIMEOUT = 2; 3525b4d4b280c6aa07656328bd9dd90977781d00e1Jorim Jaggi 3625b4d4b280c6aa07656328bd9dd90977781d00e1Jorim Jaggi /** 37c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos * Strong auth is required because a device admin requested it. 38c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos */ 39c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos int PROMPT_REASON_DEVICE_ADMIN = 3; 40c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos 41c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos /** 42c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos * Some auth is required because the user force locked. 43c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos */ 44c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos int PROMPT_REASON_USER_REQUEST = 4; 45c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos 46c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos /** 47c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos * Some auth is required because too many wrong credentials led to a lockout. 48c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos */ 49c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos int PROMPT_REASON_AFTER_LOCKOUT = 5; 50c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos 51c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos /** 52c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos * Some auth is required because a single wrong credential has been tried. 53c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos */ 54c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos int PROMPT_REASON_WRONG_CREDENTIAL = 6; 55c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos 56c13723f22e476b4558061942c001ee62eaca79e4Adrian Roos /** 57dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * Interface back to keyguard to tell it when security 58dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * @param callback 59dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller */ 60dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller void setKeyguardCallback(KeyguardSecurityCallback callback); 61dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller 62dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller /** 63dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * Set {@link LockPatternUtils} object. Useful for providing a mock interface. 64dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * @param utils 65dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller */ 66dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller void setLockPatternUtils(LockPatternUtils utils); 67dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller 68dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller /** 69dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * Reset the view and prepare to take input. This should do things like clearing the 70dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * password or pattern and clear error messages. 71dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller */ 72dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller void reset(); 73dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller 74dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller /** 75dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * Emulate activity life cycle within the view. When called, the view should clean up 76dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * and prepare to be removed. 77dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller */ 78dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller void onPause(); 79dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller 80dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller /** 81dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * Emulate activity life cycle within this view. When called, the view should prepare itself 82dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * to be shown. 83a042ac90640c0c3fd3c5349083b86bbfd6319b64Chris Wren * @param reason the root cause of the event. 84dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller */ 85a042ac90640c0c3fd3c5349083b86bbfd6319b64Chris Wren void onResume(int reason); 86dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller 87dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller /** 88dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * Inquire whether this view requires IME (keyboard) interaction. 89dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * 90dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * @return true if IME interaction is required. 91dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller */ 92dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller boolean needsInput(); 93dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller 94dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller /** 95dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * Get {@link KeyguardSecurityCallback} for the given object 96dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * @return KeyguardSecurityCallback 97dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller */ 98dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller KeyguardSecurityCallback getCallback(); 99dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller 1000b728244dc87b4a453f2191c2cb37a86e91aee0aJim Miller /** 1013122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek * Show a string explaining why the security view needs to be solved. 1023122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek * 1033122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek * @param reason a flag indicating which string should be shown, see {@link #PROMPT_REASON_NONE} 1043122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek * and {@link #PROMPT_REASON_RESTART} 1053122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek */ 1063122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek void showPromptReason(int reason); 1073122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek 1083122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek /** 109cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek * Show a message on the security view with a specified color 110cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek * 111cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek * @param message the message to show 112cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek * @param color the color to use 113cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek */ 114cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek void showMessage(String message, int color); 115cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek 116cfafe4ea6ff1610c24d94a9a9ecc7df6b841518cSelim Cinek /** 1170b728244dc87b4a453f2191c2cb37a86e91aee0aJim Miller * Instruct the view to show usability hints, if any. 1180b728244dc87b4a453f2191c2cb37a86e91aee0aJim Miller * 1190b728244dc87b4a453f2191c2cb37a86e91aee0aJim Miller */ 1206fb841fa219eaae3e87f2fdc05e105d7a1813c42Adam Cohen void showUsabilityHint(); 121c0ae9e67ebe6f1298800feaed1b43e867139a904Chris Wren 122c0ae9e67ebe6f1298800feaed1b43e867139a904Chris Wren /** 123c14f829506a5273e8022b461db2d61038b18ac4bJorim Jaggi * Starts the animation which should run when the security view appears. 124c14f829506a5273e8022b461db2d61038b18ac4bJorim Jaggi */ 125c14f829506a5273e8022b461db2d61038b18ac4bJorim Jaggi void startAppearAnimation(); 12676a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi 12776a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi /** 12876a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi * Starts the animation which should run when the security view disappears. 12976a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi * 13076a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi * @param finishRunnable the runnable to be run when the animation ended 13176a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi * @return true if an animation started and {@code finishRunnable} will be run, false if no 13276a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi * animation started and {@code finishRunnable} will not be run 13376a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi */ 13476a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi boolean startDisappearAnimation(Runnable finishRunnable); 135dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller} 136