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.app.admin.DevicePolicyManager; 19 import android.graphics.Bitmap; 20 import android.media.AudioManager; 21 import android.os.SystemClock; 22 import android.hardware.fingerprint.FingerprintManager; 23 import android.telephony.TelephonyManager; 24 import android.view.WindowManagerPolicy; 25 26 import com.android.internal.telephony.IccCardConstants; 27 28 /** 29 * Callback for general information relevant to lock screen. 30 */ 31 public class KeyguardUpdateMonitorCallback { 32 33 private static final long VISIBILITY_CHANGED_COLLAPSE_MS = 1000; 34 private long mVisibilityChangedCalled; 35 private boolean mShowing; 36 37 /** 38 * Called when the battery status changes, e.g. when plugged in or unplugged, charge 39 * level, etc. changes. 40 * 41 * @param status current battery status 42 */ onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status)43 public void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) { } 44 45 /** 46 * Called once per minute or when the time changes. 47 */ onTimeChanged()48 public void onTimeChanged() { } 49 50 /** 51 * Called when the carrier PLMN or SPN changes. 52 */ onRefreshCarrierInfo()53 public void onRefreshCarrierInfo() { } 54 55 /** 56 * Called when the ringer mode changes. 57 * @param state the current ringer state, as defined in 58 * {@link AudioManager#RINGER_MODE_CHANGED_ACTION} 59 */ onRingerModeChanged(int state)60 public void onRingerModeChanged(int state) { } 61 62 /** 63 * Called when the phone state changes. String will be one of: 64 * {@link TelephonyManager#EXTRA_STATE_IDLE} 65 * {@link TelephonyManager@EXTRA_STATE_RINGING} 66 * {@link TelephonyManager#EXTRA_STATE_OFFHOOK 67 */ onPhoneStateChanged(int phoneState)68 public void onPhoneStateChanged(int phoneState) { } 69 70 /** 71 * Called when the visibility of the keyguard changes. 72 * @param showing Indicates if the keyguard is now visible. 73 */ onKeyguardVisibilityChanged(boolean showing)74 public void onKeyguardVisibilityChanged(boolean showing) { } 75 onKeyguardVisibilityChangedRaw(boolean showing)76 public void onKeyguardVisibilityChangedRaw(boolean showing) { 77 final long now = SystemClock.elapsedRealtime(); 78 if (showing == mShowing 79 && (now - mVisibilityChangedCalled) < VISIBILITY_CHANGED_COLLAPSE_MS) return; 80 onKeyguardVisibilityChanged(showing); 81 mVisibilityChangedCalled = now; 82 mShowing = showing; 83 } 84 85 /** 86 * Called when the keyguard enters or leaves bouncer mode. 87 * @param bouncer if true, keyguard is now in bouncer mode. 88 */ onKeyguardBouncerChanged(boolean bouncer)89 public void onKeyguardBouncerChanged(boolean bouncer) { } 90 91 /** 92 * Called when visibility of lockscreen clock changes, such as when 93 * obscured by a widget. 94 */ onClockVisibilityChanged()95 public void onClockVisibilityChanged() { } 96 97 /** 98 * Called when the device becomes provisioned 99 */ onDeviceProvisioned()100 public void onDeviceProvisioned() { } 101 102 /** 103 * Called when the device policy changes. 104 * See {@link DevicePolicyManager#ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED} 105 */ onDevicePolicyManagerStateChanged()106 public void onDevicePolicyManagerStateChanged() { } 107 108 /** 109 * Called when the user change begins. 110 */ onUserSwitching(int userId)111 public void onUserSwitching(int userId) { } 112 113 /** 114 * Called when the user change is complete. 115 */ onUserSwitchComplete(int userId)116 public void onUserSwitchComplete(int userId) { } 117 118 /** 119 * Called when the SIM state changes. 120 * @param slotId 121 * @param simState 122 */ onSimStateChanged(int subId, int slotId, IccCardConstants.State simState)123 public void onSimStateChanged(int subId, int slotId, IccCardConstants.State simState) { } 124 125 /** 126 * Called when the user's info changed. 127 */ onUserInfoChanged(int userId)128 public void onUserInfoChanged(int userId) { } 129 130 /** 131 * Called when boot completed. 132 * 133 * Note, this callback will only be received if boot complete occurs after registering with 134 * KeyguardUpdateMonitor. 135 */ onBootCompleted()136 public void onBootCompleted() { } 137 138 /** 139 * Called when the emergency call button is pressed. 140 */ onEmergencyCallAction()141 public void onEmergencyCallAction() { } 142 143 /** 144 * Called when the transport background changes. 145 * @param bitmap 146 */ onSetBackground(Bitmap bitmap)147 public void onSetBackground(Bitmap bitmap) { 148 } 149 150 /** 151 * Called when the device has started waking up. 152 */ onStartedWakingUp()153 public void onStartedWakingUp() { } 154 155 /** 156 * Called when the device has started going to sleep. 157 * @param why see {@link #onFinishedGoingToSleep(int)} 158 */ onStartedGoingToSleep(int why)159 public void onStartedGoingToSleep(int why) { } 160 161 /** 162 * Called when the device has finished going to sleep. 163 * @param why either {@link WindowManagerPolicy#OFF_BECAUSE_OF_ADMIN}, 164 * {@link WindowManagerPolicy#OFF_BECAUSE_OF_USER}, or 165 * {@link WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT}. 166 */ onFinishedGoingToSleep(int why)167 public void onFinishedGoingToSleep(int why) { } 168 169 /** 170 * Called when the screen has been turned on. 171 */ onScreenTurnedOn()172 public void onScreenTurnedOn() { } 173 174 /** 175 * Called when the screen has been turned off. 176 */ onScreenTurnedOff()177 public void onScreenTurnedOff() { } 178 179 /** 180 * Called when trust changes for a user. 181 */ onTrustChanged(int userId)182 public void onTrustChanged(int userId) { } 183 184 /** 185 * Called when trust being managed changes for a user. 186 */ onTrustManagedChanged(int userId)187 public void onTrustManagedChanged(int userId) { } 188 189 /** 190 * Called after trust was granted with non-zero flags. 191 */ onTrustGrantedWithFlags(int flags, int userId)192 public void onTrustGrantedWithFlags(int flags, int userId) { } 193 194 /** 195 * Called when a finger has been acquired. 196 * <p> 197 * It is guaranteed that either {@link #onFingerprintAuthenticated} or 198 * {@link #onFingerprintAuthFailed()} is called after this method eventually. 199 */ onFingerprintAcquired()200 public void onFingerprintAcquired() { } 201 202 /** 203 * Called when a fingerprint couldn't be authenticated. 204 */ onFingerprintAuthFailed()205 public void onFingerprintAuthFailed() { } 206 207 /** 208 * Called when a fingerprint is recognized. 209 * @param userId the user id for which the fingerprint was authenticated 210 */ onFingerprintAuthenticated(int userId)211 public void onFingerprintAuthenticated(int userId) { } 212 213 /** 214 * Called when fingerprint provides help string (e.g. "Try again") 215 * @param msgId 216 * @param helpString 217 */ onFingerprintHelp(int msgId, String helpString)218 public void onFingerprintHelp(int msgId, String helpString) { } 219 220 /** 221 * Called when fingerprint provides an semi-permanent error message 222 * (e.g. "Hardware not available"). 223 * @param msgId one of the error messages listed in {@link FingerprintManager} 224 * @param errString 225 */ onFingerprintError(int msgId, String errString)226 public void onFingerprintError(int msgId, String errString) { } 227 228 /** 229 * Called when the state of face unlock changed. 230 */ onFaceUnlockStateChanged(boolean running, int userId)231 public void onFaceUnlockStateChanged(boolean running, int userId) { } 232 233 /** 234 * Called when the fingerprint running state changed. 235 */ onFingerprintRunningStateChanged(boolean running)236 public void onFingerprintRunningStateChanged(boolean running) { } 237 238 /** 239 * Called when the state that the user hasn't used strong authentication since quite some time 240 * has changed. 241 */ onStrongAuthStateChanged(int userId)242 public void onStrongAuthStateChanged(int userId) { } 243 } 244