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 * Some auth is required because adaptive auth has determined risk 71 */ 72 int PROMPT_REASON_ADAPTIVE_AUTH_REQUEST = 9; 73 74 /** 75 * Strong auth is required because the device has just booted because of an automatic 76 * mainline update. 77 */ 78 int PROMPT_REASON_RESTART_FOR_MAINLINE_UPDATE = 16; 79 80 /** 81 * Reset the view and prepare to take input. This should do things like clearing the 82 * password or pattern and clear error messages. 83 */ reset()84 void reset(); 85 86 /** 87 * Emulate activity life cycle within the view. When called, the view should clean up 88 * and prepare to be removed. 89 */ onPause()90 void onPause(); 91 92 /** 93 * Emulate activity life cycle within this view. When called, the view should prepare itself 94 * to be shown. 95 * @param reason the root cause of the event. 96 */ onResume(int reason)97 void onResume(int reason); 98 99 /** 100 * Inquire whether this view requires IME (keyboard) interaction. 101 * 102 * @return true if IME interaction is required. 103 */ needsInput()104 boolean needsInput(); 105 106 /** 107 * Show a string explaining why the security view needs to be solved. 108 * 109 * @param reason a flag indicating which string should be shown, see {@link #PROMPT_REASON_NONE} 110 * and {@link #PROMPT_REASON_RESTART} 111 */ showPromptReason(int reason)112 void showPromptReason(int reason); 113 114 /** 115 * Show a message on the security view with a specified color 116 * 117 * @param message the message to show 118 * @param colorState the color to use 119 */ showMessage(CharSequence message, ColorStateList colorState, boolean animated)120 void showMessage(CharSequence message, ColorStateList colorState, boolean animated); 121 122 /** 123 * Starts the animation which should run when the security view appears. 124 */ startAppearAnimation()125 void startAppearAnimation(); 126 127 /** 128 * Starts the animation which should run when the security view disappears. 129 * 130 * @param finishRunnable the runnable to be run when the animation ended 131 * @return true if an animation started and {@code finishRunnable} will be run, false if no 132 * animation started and {@code finishRunnable} will not be run 133 */ startDisappearAnimation(Runnable finishRunnable)134 boolean startDisappearAnimation(Runnable finishRunnable); 135 136 /** 137 * The localized name of the security view, provided to accessibility. This may be the content 138 * description, but content descriptions have other implications, so the title is kept separate. 139 * 140 * @return The View's title. 141 */ getTitle()142 CharSequence getTitle(); 143 144 /** 145 * If the parent should not be allowed to intercept touch events. 146 * @param event A touch event. 147 * @return {@code true} if touch should be passed forward. 148 * @see android.view.ViewGroup#requestDisallowInterceptTouchEvent(boolean) 149 */ disallowInterceptTouch(MotionEvent event)150 default boolean disallowInterceptTouch(MotionEvent event) { 151 return false; 152 } 153 154 /** 155 * When bouncer was visible but is being dragged down or dismissed. 156 */ onStartingToHide()157 default void onStartingToHide() {}; 158 } 159