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 a user got unlocked. 132 */ onUserUnlocked()133 public void onUserUnlocked() { } 134 135 /** 136 * Called when boot completed. 137 * 138 * Note, this callback will only be received if boot complete occurs after registering with 139 * KeyguardUpdateMonitor. 140 */ onBootCompleted()141 public void onBootCompleted() { } 142 143 /** 144 * Called when the emergency call button is pressed. 145 */ onEmergencyCallAction()146 public void onEmergencyCallAction() { } 147 148 /** 149 * Called when the transport background changes. 150 * @param bitmap 151 */ onSetBackground(Bitmap bitmap)152 public void onSetBackground(Bitmap bitmap) { 153 } 154 155 /** 156 * Called when the device has started waking up. 157 * 158 * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}. 159 */ 160 @Deprecated onStartedWakingUp()161 public void onStartedWakingUp() { } 162 163 /** 164 * Called when the device has started going to sleep. 165 * @param why see {@link #onFinishedGoingToSleep(int)} 166 * 167 * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}. 168 */ 169 @Deprecated onStartedGoingToSleep(int why)170 public void onStartedGoingToSleep(int why) { } 171 172 /** 173 * Called when the device has finished going to sleep. 174 * @param why either {@link WindowManagerPolicy#OFF_BECAUSE_OF_ADMIN}, 175 * {@link WindowManagerPolicy#OFF_BECAUSE_OF_USER}, or 176 * {@link WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT}. 177 * 178 * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}. 179 */ 180 @Deprecated onFinishedGoingToSleep(int why)181 public void onFinishedGoingToSleep(int why) { } 182 183 /** 184 * Called when the screen has been turned on. 185 * 186 * @deprecated use {@link com.android.systemui.keyguard.ScreenLifecycle}. 187 */ 188 @Deprecated onScreenTurnedOn()189 public void onScreenTurnedOn() { } 190 191 /** 192 * Called when the screen has been turned off. 193 * 194 * @deprecated use {@link com.android.systemui.keyguard.ScreenLifecycle}. 195 */ 196 @Deprecated onScreenTurnedOff()197 public void onScreenTurnedOff() { } 198 199 /** 200 * Called when trust changes for a user. 201 */ onTrustChanged(int userId)202 public void onTrustChanged(int userId) { } 203 204 /** 205 * Called when trust being managed changes for a user. 206 */ onTrustManagedChanged(int userId)207 public void onTrustManagedChanged(int userId) { } 208 209 /** 210 * Called after trust was granted with non-zero flags. 211 */ onTrustGrantedWithFlags(int flags, int userId)212 public void onTrustGrantedWithFlags(int flags, int userId) { } 213 214 /** 215 * Called when a finger has been acquired. 216 * <p> 217 * It is guaranteed that either {@link #onFingerprintAuthenticated} or 218 * {@link #onFingerprintAuthFailed()} is called after this method eventually. 219 */ onFingerprintAcquired()220 public void onFingerprintAcquired() { } 221 222 /** 223 * Called when a fingerprint couldn't be authenticated. 224 */ onFingerprintAuthFailed()225 public void onFingerprintAuthFailed() { } 226 227 /** 228 * Called when a fingerprint is recognized. 229 * @param userId the user id for which the fingerprint was authenticated 230 */ onFingerprintAuthenticated(int userId)231 public void onFingerprintAuthenticated(int userId) { } 232 233 /** 234 * Called when fingerprint provides help string (e.g. "Try again") 235 * @param msgId 236 * @param helpString 237 */ onFingerprintHelp(int msgId, String helpString)238 public void onFingerprintHelp(int msgId, String helpString) { } 239 240 /** 241 * Called when fingerprint provides an semi-permanent error message 242 * (e.g. "Hardware not available"). 243 * @param msgId one of the error messages listed in {@link FingerprintManager} 244 * @param errString 245 */ onFingerprintError(int msgId, String errString)246 public void onFingerprintError(int msgId, String errString) { } 247 248 /** 249 * Called when the state of face unlock changed. 250 */ onFaceUnlockStateChanged(boolean running, int userId)251 public void onFaceUnlockStateChanged(boolean running, int userId) { } 252 253 /** 254 * Called when the fingerprint running state changed. 255 */ onFingerprintRunningStateChanged(boolean running)256 public void onFingerprintRunningStateChanged(boolean running) { } 257 258 /** 259 * Called when the state that the user hasn't used strong authentication since quite some time 260 * has changed. 261 */ onStrongAuthStateChanged(int userId)262 public void onStrongAuthStateChanged(int userId) { } 263 264 /** 265 * Called when the state whether we have a lockscreen wallpaper has changed. 266 */ onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper)267 public void onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper) { } 268 269 /** 270 * Called when the dream's window state is changed. 271 * @param dreaming true if the dream's window has been created and is visible 272 */ onDreamingStateChanged(boolean dreaming)273 public void onDreamingStateChanged(boolean dreaming) { } 274 } 275