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.hardware.biometrics.BiometricSourceType; 21 import android.media.AudioManager; 22 import android.os.SystemClock; 23 import android.telephony.TelephonyManager; 24 import android.view.WindowManagerPolicyConstants; 25 26 import com.android.settingslib.fuelgauge.BatteryStatus; 27 import com.android.systemui.statusbar.KeyguardIndicationController; 28 29 import java.util.TimeZone; 30 31 /** 32 * Callback for general information relevant to lock screen. 33 */ 34 public class KeyguardUpdateMonitorCallback { 35 36 private static final long VISIBILITY_CHANGED_COLLAPSE_MS = 1000; 37 private long mVisibilityChangedCalled; 38 private boolean mShowing; 39 40 /** 41 * Called when the battery status changes, e.g. when plugged in or unplugged, charge 42 * level, etc. changes. 43 * 44 * @param status current battery status 45 */ onRefreshBatteryInfo(BatteryStatus status)46 public void onRefreshBatteryInfo(BatteryStatus status) { } 47 48 /** 49 * Called once per minute or when the time changes. 50 */ onTimeChanged()51 public void onTimeChanged() { } 52 53 /** 54 * Called when time zone changes. 55 * 56 * @note When time zone changes, onTimeChanged will be called too. 57 */ onTimeZoneChanged(TimeZone timeZone)58 public void onTimeZoneChanged(TimeZone timeZone) { } 59 60 /** 61 * Called when the carrier PLMN or SPN changes. 62 */ onRefreshCarrierInfo()63 public void onRefreshCarrierInfo() { } 64 65 /** 66 * Called when the ringer mode changes. 67 * @param state the current ringer state, as defined in 68 * {@link AudioManager#RINGER_MODE_CHANGED_ACTION} 69 */ onRingerModeChanged(int state)70 public void onRingerModeChanged(int state) { } 71 72 /** 73 * Called when the phone state changes. String will be one of: 74 * {@link TelephonyManager#EXTRA_STATE_IDLE} 75 * {@link TelephonyManager@EXTRA_STATE_RINGING} 76 * {@link TelephonyManager#EXTRA_STATE_OFFHOOK 77 */ onPhoneStateChanged(int phoneState)78 public void onPhoneStateChanged(int phoneState) { } 79 80 /** 81 * Called when the visibility of the keyguard changes. 82 * @param showing Indicates if the keyguard is now visible. 83 */ onKeyguardVisibilityChanged(boolean showing)84 public void onKeyguardVisibilityChanged(boolean showing) { } 85 onKeyguardVisibilityChangedRaw(boolean showing)86 public void onKeyguardVisibilityChangedRaw(boolean showing) { 87 final long now = SystemClock.elapsedRealtime(); 88 if (showing == mShowing 89 && (now - mVisibilityChangedCalled) < VISIBILITY_CHANGED_COLLAPSE_MS) return; 90 onKeyguardVisibilityChanged(showing); 91 mVisibilityChangedCalled = now; 92 mShowing = showing; 93 } 94 95 /** 96 * Called when the keyguard enters or leaves bouncer mode. 97 * @param bouncer if true, keyguard is now in bouncer mode. 98 */ onKeyguardBouncerChanged(boolean bouncer)99 public void onKeyguardBouncerChanged(boolean bouncer) { } 100 101 /** 102 * Called when visibility of lockscreen clock changes, such as when 103 * obscured by a widget. 104 */ onClockVisibilityChanged()105 public void onClockVisibilityChanged() { } 106 107 /** 108 * Called when the device becomes provisioned 109 */ onDeviceProvisioned()110 public void onDeviceProvisioned() { } 111 112 /** 113 * Called when the device policy changes. 114 * See {@link DevicePolicyManager#ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED} 115 */ onDevicePolicyManagerStateChanged()116 public void onDevicePolicyManagerStateChanged() { } 117 118 /** 119 * Called when the user change begins. 120 */ onUserSwitching(int userId)121 public void onUserSwitching(int userId) { } 122 123 /** 124 * Called when the user change is complete. 125 */ onUserSwitchComplete(int userId)126 public void onUserSwitchComplete(int userId) { } 127 128 /** 129 * Called when the Telephony capable 130 * @param capable 131 */ onTelephonyCapable(boolean capable)132 public void onTelephonyCapable(boolean capable) { } 133 134 /** 135 * Called when the SIM state changes. 136 * @param slotId 137 * @param simState 138 */ onSimStateChanged(int subId, int slotId, int simState)139 public void onSimStateChanged(int subId, int slotId, int simState) { } 140 141 /** 142 * Called when the user's info changed. 143 */ onUserInfoChanged(int userId)144 public void onUserInfoChanged(int userId) { } 145 146 /** 147 * Called when a user got unlocked. 148 */ onUserUnlocked()149 public void onUserUnlocked() { } 150 151 /** 152 * Called when the emergency call button is pressed. 153 */ onEmergencyCallAction()154 public void onEmergencyCallAction() { } 155 156 /** 157 * Called when the transport background changes. 158 * @param bitmap 159 */ onSetBackground(Bitmap bitmap)160 public void onSetBackground(Bitmap bitmap) { 161 } 162 163 /** 164 * Called when the device has started waking up. 165 * 166 * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}. 167 */ 168 @Deprecated onStartedWakingUp()169 public void onStartedWakingUp() { } 170 171 /** 172 * Called when the device has started going to sleep. 173 * @param why see {@link #onFinishedGoingToSleep(int)} 174 * 175 * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}. 176 */ 177 @Deprecated onStartedGoingToSleep(int why)178 public void onStartedGoingToSleep(int why) { } 179 180 /** 181 * Called when the device has finished going to sleep. 182 * @param why either {@link WindowManagerPolicyConstants#OFF_BECAUSE_OF_ADMIN}, 183 * {@link WindowManagerPolicyConstants#OFF_BECAUSE_OF_USER}, or 184 * {@link WindowManagerPolicyConstants#OFF_BECAUSE_OF_TIMEOUT}. 185 * 186 * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}. 187 */ 188 @Deprecated onFinishedGoingToSleep(int why)189 public void onFinishedGoingToSleep(int why) { } 190 191 /** 192 * Called when the screen has been turned on. 193 * 194 * @deprecated use {@link com.android.systemui.keyguard.ScreenLifecycle}. 195 */ 196 @Deprecated onScreenTurnedOn()197 public void onScreenTurnedOn() { } 198 199 /** 200 * Called when the screen has been turned off. 201 * 202 * @deprecated use {@link com.android.systemui.keyguard.ScreenLifecycle}. 203 */ 204 @Deprecated onScreenTurnedOff()205 public void onScreenTurnedOff() { } 206 207 /** 208 * Called when trust changes for a user. 209 */ onTrustChanged(int userId)210 public void onTrustChanged(int userId) { } 211 212 /** 213 * Called when trust being managed changes for a user. 214 */ onTrustManagedChanged(int userId)215 public void onTrustManagedChanged(int userId) { } 216 217 /** 218 * Called after trust was granted with non-zero flags. 219 */ onTrustGrantedWithFlags(int flags, int userId)220 public void onTrustGrantedWithFlags(int flags, int userId) { } 221 222 /** 223 * Called when a biometric has been acquired. 224 * <p> 225 * It is guaranteed that either {@link #onBiometricAuthenticated} or 226 * {@link #onBiometricAuthFailed(BiometricSourceType)} is called after this method eventually. 227 * @param biometricSourceType 228 */ onBiometricAcquired(BiometricSourceType biometricSourceType)229 public void onBiometricAcquired(BiometricSourceType biometricSourceType) { } 230 231 /** 232 * Called when a biometric couldn't be authenticated. 233 * @param biometricSourceType 234 */ onBiometricAuthFailed(BiometricSourceType biometricSourceType)235 public void onBiometricAuthFailed(BiometricSourceType biometricSourceType) { } 236 237 /** 238 * Called when a biometric is recognized. 239 * @param userId the user id for which the biometric sample was authenticated 240 * @param biometricSourceType 241 */ onBiometricAuthenticated(int userId, BiometricSourceType biometricSourceType, boolean isStrongBiometric)242 public void onBiometricAuthenticated(int userId, BiometricSourceType biometricSourceType, 243 boolean isStrongBiometric) { } 244 245 /** 246 * Called when biometric authentication provides help string (e.g. "Try again") 247 * @param msgId 248 * @param helpString 249 * @param biometricSourceType 250 */ onBiometricHelp(int msgId, String helpString, BiometricSourceType biometricSourceType)251 public void onBiometricHelp(int msgId, String helpString, 252 BiometricSourceType biometricSourceType) { } 253 254 /** 255 * Called when biometric authentication method provides a semi-permanent 256 * error message (e.g. "Hardware not available"). 257 * @param msgId one of the error messages listed in 258 * {@link android.hardware.biometrics.BiometricConstants} 259 * @param errString 260 * @param biometricSourceType 261 */ onBiometricError(int msgId, String errString, BiometricSourceType biometricSourceType)262 public void onBiometricError(int msgId, String errString, 263 BiometricSourceType biometricSourceType) { } 264 265 /** 266 * Called when the state of face unlock changed. 267 */ onFaceUnlockStateChanged(boolean running, int userId)268 public void onFaceUnlockStateChanged(boolean running, int userId) { } 269 270 /** 271 * Called when biometric running state changed. 272 */ onBiometricRunningStateChanged(boolean running, BiometricSourceType biometricSourceType)273 public void onBiometricRunningStateChanged(boolean running, 274 BiometricSourceType biometricSourceType) { } 275 276 /** 277 * Called when the state that the user hasn't used strong authentication since quite some time 278 * has changed. 279 */ onStrongAuthStateChanged(int userId)280 public void onStrongAuthStateChanged(int userId) { } 281 282 /** 283 * Called when the state whether we have a lockscreen wallpaper has changed. 284 */ onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper)285 public void onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper) { } 286 287 /** 288 * Called when the dream's window state is changed. 289 * @param dreaming true if the dream's window has been created and is visible 290 */ onDreamingStateChanged(boolean dreaming)291 public void onDreamingStateChanged(boolean dreaming) { } 292 293 /** 294 * Called when an error message needs to be presented on the keyguard. 295 * Message will be visible briefly, and might be overridden by other keyguard events, 296 * like fingerprint authentication errors. 297 * 298 * @param message Message that indicates an error. 299 * @see KeyguardIndicationController.BaseKeyguardCallback#HIDE_DELAY_MS 300 * @see KeyguardIndicationController#showTransientIndication(CharSequence) 301 */ onTrustAgentErrorMessage(CharSequence message)302 public void onTrustAgentErrorMessage(CharSequence message) { } 303 304 305 /** 306 * Called when a value of logout enabled is change. 307 */ onLogoutEnabledChanged()308 public void onLogoutEnabledChanged() { } 309 310 /** 311 * Called when authenticated biometrics are cleared. 312 */ onBiometricsCleared()313 public void onBiometricsCleared() { } 314 315 /** 316 * Called when the secondary lock screen requirement changes. 317 */ onSecondaryLockscreenRequirementChanged(int userId)318 public void onSecondaryLockscreenRequirementChanged(int userId) { } 319 320 } 321