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 * Interface back to keyguard to tell it when security 38 * @param callback 39 */ setKeyguardCallback(KeyguardSecurityCallback callback)40 void setKeyguardCallback(KeyguardSecurityCallback callback); 41 42 /** 43 * Set {@link LockPatternUtils} object. Useful for providing a mock interface. 44 * @param utils 45 */ setLockPatternUtils(LockPatternUtils utils)46 void setLockPatternUtils(LockPatternUtils utils); 47 48 /** 49 * Reset the view and prepare to take input. This should do things like clearing the 50 * password or pattern and clear error messages. 51 */ reset()52 void reset(); 53 54 /** 55 * Emulate activity life cycle within the view. When called, the view should clean up 56 * and prepare to be removed. 57 */ onPause()58 void onPause(); 59 60 /** 61 * Emulate activity life cycle within this view. When called, the view should prepare itself 62 * to be shown. 63 * @param reason the root cause of the event. 64 */ onResume(int reason)65 void onResume(int reason); 66 67 /** 68 * Inquire whether this view requires IME (keyboard) interaction. 69 * 70 * @return true if IME interaction is required. 71 */ needsInput()72 boolean needsInput(); 73 74 /** 75 * Get {@link KeyguardSecurityCallback} for the given object 76 * @return KeyguardSecurityCallback 77 */ getCallback()78 KeyguardSecurityCallback getCallback(); 79 80 /** 81 * Show a string explaining why the security view needs to be solved. 82 * 83 * @param reason a flag indicating which string should be shown, see {@link #PROMPT_REASON_NONE} 84 * and {@link #PROMPT_REASON_RESTART} 85 */ showPromptReason(int reason)86 void showPromptReason(int reason); 87 88 /** 89 * Show a message on the security view with a specified color 90 * 91 * @param message the message to show 92 * @param color the color to use 93 */ showMessage(String message, int color)94 void showMessage(String message, int color); 95 96 /** 97 * Instruct the view to show usability hints, if any. 98 * 99 */ showUsabilityHint()100 void showUsabilityHint(); 101 102 /** 103 * Starts the animation which should run when the security view appears. 104 */ startAppearAnimation()105 void startAppearAnimation(); 106 107 /** 108 * Starts the animation which should run when the security view disappears. 109 * 110 * @param finishRunnable the runnable to be run when the animation ended 111 * @return true if an animation started and {@code finishRunnable} will be run, false if no 112 * animation started and {@code finishRunnable} will not be run 113 */ startDisappearAnimation(Runnable finishRunnable)114 boolean startDisappearAnimation(Runnable finishRunnable); 115 } 116