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 * Prompt that is shown when there is an incorrect primary authentication input. 71 */ 72 int PROMPT_REASON_INCORRECT_PRIMARY_AUTH_INPUT = 9; 73 74 /** 75 * Prompt that is shown when there is an incorrect face biometric input. 76 */ 77 int PROMPT_REASON_INCORRECT_FACE_INPUT = 10; 78 79 /** 80 * Prompt that is shown when there is an incorrect fingerprint biometric input. 81 */ 82 int PROMPT_REASON_INCORRECT_FINGERPRINT_INPUT = 11; 83 84 /** 85 * Prompt that is shown when face authentication is in locked out state. 86 */ 87 int PROMPT_REASON_FACE_LOCKED_OUT = 12; 88 89 /** 90 * Prompt that is shown when fingerprint authentication is in locked out state. 91 */ 92 int PROMPT_REASON_FINGERPRINT_LOCKED_OUT = 13; 93 94 /** 95 * Default prompt that is shown on the bouncer. 96 */ 97 int PROMPT_REASON_DEFAULT = 14; 98 99 /** 100 * Prompt that is shown when primary authentication is in locked out state after too many 101 * attempts 102 */ 103 int PROMPT_REASON_PRIMARY_AUTH_LOCKED_OUT = 15; 104 105 /** 106 * Strong auth is required because the device has just booted because of an automatic 107 * mainline update. 108 */ 109 int PROMPT_REASON_RESTART_FOR_MAINLINE_UPDATE = 16; 110 111 /** 112 * Reset the view and prepare to take input. This should do things like clearing the 113 * password or pattern and clear error messages. 114 */ reset()115 void reset(); 116 117 /** 118 * Emulate activity life cycle within the view. When called, the view should clean up 119 * and prepare to be removed. 120 */ onPause()121 void onPause(); 122 123 /** 124 * Emulate activity life cycle within this view. When called, the view should prepare itself 125 * to be shown. 126 * @param reason the root cause of the event. 127 */ onResume(int reason)128 void onResume(int reason); 129 130 /** 131 * Inquire whether this view requires IME (keyboard) interaction. 132 * 133 * @return true if IME interaction is required. 134 */ needsInput()135 boolean needsInput(); 136 137 /** 138 * Show a string explaining why the security view needs to be solved. 139 * 140 * @param reason a flag indicating which string should be shown, see {@link #PROMPT_REASON_NONE} 141 * and {@link #PROMPT_REASON_RESTART} 142 */ showPromptReason(int reason)143 void showPromptReason(int reason); 144 145 /** 146 * Show a message on the security view with a specified color 147 * 148 * @param message the message to show 149 * @param colorState the color to use 150 */ showMessage(CharSequence message, ColorStateList colorState, boolean animated)151 void showMessage(CharSequence message, ColorStateList colorState, boolean animated); 152 153 /** 154 * Starts the animation which should run when the security view appears. 155 */ startAppearAnimation()156 void startAppearAnimation(); 157 158 /** 159 * Starts the animation which should run when the security view disappears. 160 * 161 * @param finishRunnable the runnable to be run when the animation ended 162 * @return true if an animation started and {@code finishRunnable} will be run, false if no 163 * animation started and {@code finishRunnable} will not be run 164 */ startDisappearAnimation(Runnable finishRunnable)165 boolean startDisappearAnimation(Runnable finishRunnable); 166 167 /** 168 * The localized name of the security view, provided to accessibility. This may be the content 169 * description, but content descriptions have other implications, so the title is kept separate. 170 * 171 * @return The View's title. 172 */ getTitle()173 CharSequence getTitle(); 174 175 /** 176 * If the parent should not be allowed to intercept touch events. 177 * @param event A touch event. 178 * @return {@code true} if touch should be passed forward. 179 * @see android.view.ViewGroup#requestDisallowInterceptTouchEvent(boolean) 180 */ disallowInterceptTouch(MotionEvent event)181 default boolean disallowInterceptTouch(MotionEvent event) { 182 return false; 183 } 184 185 /** 186 * When bouncer was visible but is being dragged down or dismissed. 187 */ onStartingToHide()188 default void onStartingToHide() {}; 189 } 190