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 */ onStartedWakingUp()158 public void onStartedWakingUp() { } 159 160 /** 161 * Called when the device has started going to sleep. 162 * @param why see {@link #onFinishedGoingToSleep(int)} 163 */ onStartedGoingToSleep(int why)164 public void onStartedGoingToSleep(int why) { } 165 166 /** 167 * Called when the device has finished going to sleep. 168 * @param why either {@link WindowManagerPolicy#OFF_BECAUSE_OF_ADMIN}, 169 * {@link WindowManagerPolicy#OFF_BECAUSE_OF_USER}, or 170 * {@link WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT}. 171 */ onFinishedGoingToSleep(int why)172 public void onFinishedGoingToSleep(int why) { } 173 174 /** 175 * Called when the screen has been turned on. 176 */ onScreenTurnedOn()177 public void onScreenTurnedOn() { } 178 179 /** 180 * Called when the screen has been turned off. 181 */ onScreenTurnedOff()182 public void onScreenTurnedOff() { } 183 184 /** 185 * Called when trust changes for a user. 186 */ onTrustChanged(int userId)187 public void onTrustChanged(int userId) { } 188 189 /** 190 * Called when trust being managed changes for a user. 191 */ onTrustManagedChanged(int userId)192 public void onTrustManagedChanged(int userId) { } 193 194 /** 195 * Called after trust was granted with non-zero flags. 196 */ onTrustGrantedWithFlags(int flags, int userId)197 public void onTrustGrantedWithFlags(int flags, int userId) { } 198 199 /** 200 * Called when a finger has been acquired. 201 * <p> 202 * It is guaranteed that either {@link #onFingerprintAuthenticated} or 203 * {@link #onFingerprintAuthFailed()} is called after this method eventually. 204 */ onFingerprintAcquired()205 public void onFingerprintAcquired() { } 206 207 /** 208 * Called when a fingerprint couldn't be authenticated. 209 */ onFingerprintAuthFailed()210 public void onFingerprintAuthFailed() { } 211 212 /** 213 * Called when a fingerprint is recognized. 214 * @param userId the user id for which the fingerprint was authenticated 215 */ onFingerprintAuthenticated(int userId)216 public void onFingerprintAuthenticated(int userId) { } 217 218 /** 219 * Called when fingerprint provides help string (e.g. "Try again") 220 * @param msgId 221 * @param helpString 222 */ onFingerprintHelp(int msgId, String helpString)223 public void onFingerprintHelp(int msgId, String helpString) { } 224 225 /** 226 * Called when fingerprint provides an semi-permanent error message 227 * (e.g. "Hardware not available"). 228 * @param msgId one of the error messages listed in {@link FingerprintManager} 229 * @param errString 230 */ onFingerprintError(int msgId, String errString)231 public void onFingerprintError(int msgId, String errString) { } 232 233 /** 234 * Called when the state of face unlock changed. 235 */ onFaceUnlockStateChanged(boolean running, int userId)236 public void onFaceUnlockStateChanged(boolean running, int userId) { } 237 238 /** 239 * Called when the fingerprint running state changed. 240 */ onFingerprintRunningStateChanged(boolean running)241 public void onFingerprintRunningStateChanged(boolean running) { } 242 243 /** 244 * Called when the state that the user hasn't used strong authentication since quite some time 245 * has changed. 246 */ onStrongAuthStateChanged(int userId)247 public void onStrongAuthStateChanged(int userId) { } 248 249 /** 250 * Called when the state whether we have a lockscreen wallpaper has changed. 251 */ onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper)252 public void onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper) { } 253 254 /** 255 * Called when the dream's window state is changed. 256 * @param dreaming true if the dream's window has been created and is visible 257 */ onDreamingStateChanged(boolean dreaming)258 public void onDreamingStateChanged(boolean dreaming) { } 259 } 260