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.internal.widget.LockPatternUtils; 19 20 public interface KeyguardSecurityView { 21 static public final int SCREEN_ON = 1; 22 static public final int VIEW_REVEALED = 2; 23 24 int PROMPT_REASON_NONE = 0; 25 26 /** 27 * Strong auth is required because the device has just booted. 28 */ 29 int PROMPT_REASON_RESTART = 1; 30 31 /** 32 * Strong auth is required because the user hasn't used strong auth since a while. 33 */ 34 int PROMPT_REASON_TIMEOUT = 2; 35 36 /** 37 * Strong auth is required because a device admin requested it. 38 */ 39 int PROMPT_REASON_DEVICE_ADMIN = 3; 40 41 /** 42 * Some auth is required because the user force locked. 43 */ 44 int PROMPT_REASON_USER_REQUEST = 4; 45 46 /** 47 * Some auth is required because too many wrong credentials led to a lockout. 48 */ 49 int PROMPT_REASON_AFTER_LOCKOUT = 5; 50 51 /** 52 * Interface back to keyguard to tell it when security 53 * @param callback 54 */ 55 void setKeyguardCallback(KeyguardSecurityCallback callback); 56 57 /** 58 * Set {@link LockPatternUtils} object. Useful for providing a mock interface. 59 * @param utils 60 */ 61 void setLockPatternUtils(LockPatternUtils utils); 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 */ 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 */ 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 */ 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 */ 87 boolean needsInput(); 88 89 /** 90 * Get {@link KeyguardSecurityCallback} for the given object 91 * @return KeyguardSecurityCallback 92 */ 93 KeyguardSecurityCallback getCallback(); 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 */ 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 color the color to use 108 */ 109 void showMessage(String message, int color); 110 111 /** 112 * Instruct the view to show usability hints, if any. 113 * 114 */ 115 void showUsabilityHint(); 116 117 /** 118 * Starts the animation which should run when the security view appears. 119 */ 120 void startAppearAnimation(); 121 122 /** 123 * Starts the animation which should run when the security view disappears. 124 * 125 * @param finishRunnable the runnable to be run when the animation ended 126 * @return true if an animation started and {@code finishRunnable} will be run, false if no 127 * animation started and {@code finishRunnable} will not be run 128 */ 129 boolean startDisappearAnimation(Runnable finishRunnable); 130 } 131