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 import com.android.internal.widget.LockPatternUtils; 22 23 public interface KeyguardSecurityView { 24 static public final int SCREEN_ON = 1; 25 static public final int VIEW_REVEALED = 2; 26 27 int PROMPT_REASON_NONE = 0; 28 29 /** 30 * Strong auth is required because the device has just booted. 31 */ 32 int PROMPT_REASON_RESTART = 1; 33 34 /** 35 * Strong auth is required because the user hasn't used strong auth since a while. 36 */ 37 int PROMPT_REASON_TIMEOUT = 2; 38 39 /** 40 * Strong auth is required because a device admin requested it. 41 */ 42 int PROMPT_REASON_DEVICE_ADMIN = 3; 43 44 /** 45 * Some auth is required because the user force locked. 46 */ 47 int PROMPT_REASON_USER_REQUEST = 4; 48 49 /** 50 * Some auth is required because too many wrong credentials led to a lockout. 51 */ 52 int PROMPT_REASON_AFTER_LOCKOUT = 5; 53 54 /** 55 * Interface back to keyguard to tell it when security 56 * @param callback 57 */ setKeyguardCallback(KeyguardSecurityCallback callback)58 void setKeyguardCallback(KeyguardSecurityCallback callback); 59 60 /** 61 * Set {@link LockPatternUtils} object. Useful for providing a mock interface. 62 * @param utils 63 */ setLockPatternUtils(LockPatternUtils utils)64 void setLockPatternUtils(LockPatternUtils utils); 65 66 /** 67 * Reset the view and prepare to take input. This should do things like clearing the 68 * password or pattern and clear error messages. 69 */ reset()70 void reset(); 71 72 /** 73 * Emulate activity life cycle within the view. When called, the view should clean up 74 * and prepare to be removed. 75 */ onPause()76 void onPause(); 77 78 /** 79 * Emulate activity life cycle within this view. When called, the view should prepare itself 80 * to be shown. 81 * @param reason the root cause of the event. 82 */ onResume(int reason)83 void onResume(int reason); 84 85 /** 86 * Inquire whether this view requires IME (keyboard) interaction. 87 * 88 * @return true if IME interaction is required. 89 */ needsInput()90 boolean needsInput(); 91 92 /** 93 * Get {@link KeyguardSecurityCallback} for the given object 94 * @return KeyguardSecurityCallback 95 */ getCallback()96 KeyguardSecurityCallback getCallback(); 97 98 /** 99 * Show a string explaining why the security view needs to be solved. 100 * 101 * @param reason a flag indicating which string should be shown, see {@link #PROMPT_REASON_NONE} 102 * and {@link #PROMPT_REASON_RESTART} 103 */ showPromptReason(int reason)104 void showPromptReason(int reason); 105 106 /** 107 * Show a message on the security view with a specified color 108 * 109 * @param message the message to show 110 * @param colorState the color to use 111 */ showMessage(CharSequence message, ColorStateList colorState)112 void showMessage(CharSequence message, ColorStateList colorState); 113 114 /** 115 * Instruct the view to show usability hints, if any. 116 * 117 */ showUsabilityHint()118 void showUsabilityHint(); 119 120 /** 121 * Starts the animation which should run when the security view appears. 122 */ startAppearAnimation()123 void startAppearAnimation(); 124 125 /** 126 * Starts the animation which should run when the security view disappears. 127 * 128 * @param finishRunnable the runnable to be run when the animation ended 129 * @return true if an animation started and {@code finishRunnable} will be run, false if no 130 * animation started and {@code finishRunnable} will not be run 131 */ startDisappearAnimation(Runnable finishRunnable)132 boolean startDisappearAnimation(Runnable finishRunnable); 133 134 /** 135 * The localized name of the security view, provided to accessibility. This may be the content 136 * description, but content descriptions have other implications, so the title is kept separate. 137 * 138 * @return The View's title. 139 */ getTitle()140 CharSequence getTitle(); 141 142 /** 143 * If the parent should not be allowed to intercept touch events. 144 * @param event A touch event. 145 * @return {@code true} if touch should be passed forward. 146 * @see android.view.ViewGroup#requestDisallowInterceptTouchEvent(boolean) 147 */ disallowInterceptTouch(MotionEvent event)148 default boolean disallowInterceptTouch(MotionEvent event) { 149 return false; 150 } 151 } 152