blob: 0fef755b5abaa58d60e6dc2fdcab3a753e71b081 [file] [log] [blame]
Jim Millerbbf1a742012-07-17 18:30:30 -07001/*
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 */
Jim Miller5ecd8112013-01-09 18:50:26 -080016package com.android.keyguard;
Jim Millerbbf1a742012-07-17 18:30:30 -070017
18import android.app.admin.DevicePolicyManager;
Adam Powell43a372f2013-09-27 17:43:53 -070019import android.graphics.Bitmap;
Gilad Brettercb51b8b2018-03-22 17:04:51 +020020import android.hardware.biometrics.BiometricSourceType;
Jim Millerbbf1a742012-07-17 18:30:30 -070021import android.media.AudioManager;
John Spurlock385a63d2013-10-30 19:40:48 -040022import android.os.SystemClock;
Jorim Jaggi5cf17872014-03-26 18:31:48 +010023import android.telephony.TelephonyManager;
Adrian Roose99bc052017-11-20 17:55:31 +010024import android.view.WindowManagerPolicyConstants;
Jim Millerbbf1a742012-07-17 18:30:30 -070025
Jim Millerbbf1a742012-07-17 18:30:30 -070026import com.android.internal.telephony.IccCardConstants;
Lucas Dupinef886542018-01-03 16:03:07 -080027import com.android.systemui.statusbar.KeyguardIndicationController;
Jim Millerbbf1a742012-07-17 18:30:30 -070028
Robert Snoeberger9c1074f2018-12-07 17:35:21 -050029import java.util.TimeZone;
30
Jim Millerbbf1a742012-07-17 18:30:30 -070031/**
32 * Callback for general information relevant to lock screen.
33 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +010034public class KeyguardUpdateMonitorCallback {
John Spurlock385a63d2013-10-30 19:40:48 -040035
36 private static final long VISIBILITY_CHANGED_COLLAPSE_MS = 1000;
37 private long mVisibilityChangedCalled;
38 private boolean mShowing;
39
Jim Millerbbf1a742012-07-17 18:30:30 -070040 /**
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 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +010046 public void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) { }
Jim Millerbbf1a742012-07-17 18:30:30 -070047
48 /**
49 * Called once per minute or when the time changes.
50 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +010051 public void onTimeChanged() { }
Jim Millerbbf1a742012-07-17 18:30:30 -070052
53 /**
Robert Snoeberger9c1074f2018-12-07 17:35:21 -050054 * Called when time zone changes.
55 *
56 * @note When time zone changes, onTimeChanged will be called too.
57 */
58 public void onTimeZoneChanged(TimeZone timeZone) { }
59
60 /**
Jim Millerbbf1a742012-07-17 18:30:30 -070061 * Called when the carrier PLMN or SPN changes.
Jim Millerbbf1a742012-07-17 18:30:30 -070062 */
Jason Monk9ff69bd2014-12-02 16:43:17 -050063 public void onRefreshCarrierInfo() { }
Jim Millerbbf1a742012-07-17 18:30:30 -070064
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 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +010070 public void onRingerModeChanged(int state) { }
Jim Millerbbf1a742012-07-17 18:30:30 -070071
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 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +010078 public void onPhoneStateChanged(int phoneState) { }
Jim Millerbbf1a742012-07-17 18:30:30 -070079
80 /**
Danielle Millettf6d0fc12012-10-23 16:16:52 -040081 * Called when the visibility of the keyguard changes.
82 * @param showing Indicates if the keyguard is now visible.
83 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +010084 public void onKeyguardVisibilityChanged(boolean showing) { }
Danielle Millettf6d0fc12012-10-23 16:16:52 -040085
Jorim Jaggi5cf17872014-03-26 18:31:48 +010086 public void onKeyguardVisibilityChangedRaw(boolean showing) {
John Spurlock385a63d2013-10-30 19:40:48 -040087 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
Danielle Millettf6d0fc12012-10-23 16:16:52 -040095 /**
Adrian Roosb6011622014-05-14 15:52:53 +020096 * Called when the keyguard enters or leaves bouncer mode.
97 * @param bouncer if true, keyguard is now in bouncer mode.
98 */
99 public void onKeyguardBouncerChanged(boolean bouncer) { }
100
101 /**
Jim Millerbbf1a742012-07-17 18:30:30 -0700102 * Called when visibility of lockscreen clock changes, such as when
103 * obscured by a widget.
104 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100105 public void onClockVisibilityChanged() { }
Jim Millerbbf1a742012-07-17 18:30:30 -0700106
107 /**
108 * Called when the device becomes provisioned
109 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100110 public void onDeviceProvisioned() { }
Jim Millerbbf1a742012-07-17 18:30:30 -0700111
112 /**
113 * Called when the device policy changes.
114 * See {@link DevicePolicyManager#ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED}
115 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100116 public void onDevicePolicyManagerStateChanged() { }
Jim Millerbbf1a742012-07-17 18:30:30 -0700117
118 /**
Chris Wrenf41c61b2012-11-29 15:19:54 -0500119 * Called when the user change begins.
Jim Millerbbf1a742012-07-17 18:30:30 -0700120 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100121 public void onUserSwitching(int userId) { }
Chris Wrenf41c61b2012-11-29 15:19:54 -0500122
123 /**
124 * Called when the user change is complete.
125 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100126 public void onUserSwitchComplete(int userId) { }
Jim Millerbbf1a742012-07-17 18:30:30 -0700127
128 /**
Bill Linef81cbd2018-07-05 17:48:49 +0800129 * Called when the Telephony capable
130 * @param capable
131 */
132 public void onTelephonyCapable(boolean capable) { }
133
134 /**
Jim Millerbbf1a742012-07-17 18:30:30 -0700135 * Called when the SIM state changes.
Jim Miller52a61332014-11-12 19:29:51 -0800136 * @param slotId
Jim Millerbbf1a742012-07-17 18:30:30 -0700137 * @param simState
138 */
Jim Miller52a61332014-11-12 19:29:51 -0800139 public void onSimStateChanged(int subId, int slotId, IccCardConstants.State simState) { }
Jim Millerbbf1a742012-07-17 18:30:30 -0700140
141 /**
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -0700142 * Called when the user's info changed.
143 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100144 public void onUserInfoChanged(int userId) { }
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -0700145
146 /**
Jorim Jaggidadafd42016-09-30 07:20:25 -0700147 * Called when a user got unlocked.
148 */
149 public void onUserUnlocked() { }
150
151 /**
Adam Cohenefb3ffb2012-11-06 16:55:32 -0800152 * Called when boot completed.
153 *
154 * Note, this callback will only be received if boot complete occurs after registering with
155 * KeyguardUpdateMonitor.
156 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100157 public void onBootCompleted() { }
Jim Miller8f09fd22013-03-14 19:04:28 -0700158
159 /**
Brian Colonna7fce3802013-09-17 15:51:32 -0400160 * Called when the emergency call button is pressed.
161 */
John Spurlock813552c2014-09-19 08:30:21 -0400162 public void onEmergencyCallAction() { }
Adam Powell43a372f2013-09-27 17:43:53 -0700163
Jim Miller20daffd2013-10-07 14:59:53 -0700164 /**
165 * Called when the transport background changes.
166 * @param bitmap
167 */
Adam Powell43a372f2013-09-27 17:43:53 -0700168 public void onSetBackground(Bitmap bitmap) {
Adam Powell43a372f2013-09-27 17:43:53 -0700169 }
Jim Miller20daffd2013-10-07 14:59:53 -0700170
171 /**
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700172 * Called when the device has started waking up.
Adrian Roos369907f2017-07-14 14:53:39 +0200173 *
174 * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}.
Jim Miller20daffd2013-10-07 14:59:53 -0700175 */
Adrian Roos369907f2017-07-14 14:53:39 +0200176 @Deprecated
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700177 public void onStartedWakingUp() { }
Jim Miller20daffd2013-10-07 14:59:53 -0700178
179 /**
Jorim Jaggi95e40382015-09-16 15:53:42 -0700180 * Called when the device has started going to sleep.
181 * @param why see {@link #onFinishedGoingToSleep(int)}
Adrian Roos369907f2017-07-14 14:53:39 +0200182 *
183 * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}.
Jorim Jaggi95e40382015-09-16 15:53:42 -0700184 */
Adrian Roos369907f2017-07-14 14:53:39 +0200185 @Deprecated
Jorim Jaggi95e40382015-09-16 15:53:42 -0700186 public void onStartedGoingToSleep(int why) { }
187
188 /**
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700189 * Called when the device has finished going to sleep.
Adrian Roose99bc052017-11-20 17:55:31 +0100190 * @param why either {@link WindowManagerPolicyConstants#OFF_BECAUSE_OF_ADMIN},
191 * {@link WindowManagerPolicyConstants#OFF_BECAUSE_OF_USER}, or
192 * {@link WindowManagerPolicyConstants#OFF_BECAUSE_OF_TIMEOUT}.
Adrian Roos369907f2017-07-14 14:53:39 +0200193 *
194 * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}.
Jim Miller20daffd2013-10-07 14:59:53 -0700195 */
Adrian Roos369907f2017-07-14 14:53:39 +0200196 @Deprecated
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700197 public void onFinishedGoingToSleep(int why) { }
Adrian Roos2fe592d2014-05-17 03:11:59 +0200198
199 /**
Jorim Jaggif1518da2015-07-30 11:56:36 -0700200 * Called when the screen has been turned on.
Adrian Roos369907f2017-07-14 14:53:39 +0200201 *
202 * @deprecated use {@link com.android.systemui.keyguard.ScreenLifecycle}.
Jorim Jaggif1518da2015-07-30 11:56:36 -0700203 */
Adrian Roos369907f2017-07-14 14:53:39 +0200204 @Deprecated
Jorim Jaggif1518da2015-07-30 11:56:36 -0700205 public void onScreenTurnedOn() { }
206
207 /**
208 * Called when the screen has been turned off.
Adrian Roos369907f2017-07-14 14:53:39 +0200209 *
210 * @deprecated use {@link com.android.systemui.keyguard.ScreenLifecycle}.
Jorim Jaggif1518da2015-07-30 11:56:36 -0700211 */
Adrian Roos369907f2017-07-14 14:53:39 +0200212 @Deprecated
Jorim Jaggif1518da2015-07-30 11:56:36 -0700213 public void onScreenTurnedOff() { }
214
215 /**
Adrian Roos2fe592d2014-05-17 03:11:59 +0200216 * Called when trust changes for a user.
217 */
218 public void onTrustChanged(int userId) { }
Jim Millerf41fc962014-06-18 16:33:51 -0700219
220 /**
Adrian Roos7861c662014-07-25 15:37:28 +0200221 * Called when trust being managed changes for a user.
222 */
223 public void onTrustManagedChanged(int userId) { }
224
225 /**
Adrian Roos94e15a52015-04-16 12:23:18 -0700226 * Called after trust was granted with non-zero flags.
Adrian Roos3c9a3502014-08-06 19:09:45 +0200227 */
Adrian Roos94e15a52015-04-16 12:23:18 -0700228 public void onTrustGrantedWithFlags(int flags, int userId) { }
Adrian Roos3c9a3502014-08-06 19:09:45 +0200229
230 /**
Gilad Brettercb51b8b2018-03-22 17:04:51 +0200231 * Called when a biometric has been acquired.
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700232 * <p>
Gilad Brettercb51b8b2018-03-22 17:04:51 +0200233 * It is guaranteed that either {@link #onBiometricAuthenticated} or
234 * {@link #onBiometricAuthFailed(BiometricSourceType)} is called after this method eventually.
235 * @param biometricSourceType
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700236 */
Gilad Brettercb51b8b2018-03-22 17:04:51 +0200237 public void onBiometricAcquired(BiometricSourceType biometricSourceType) { }
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700238
239 /**
Gilad Brettercb51b8b2018-03-22 17:04:51 +0200240 * Called when a biometric couldn't be authenticated.
241 * @param biometricSourceType
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700242 */
Gilad Brettercb51b8b2018-03-22 17:04:51 +0200243 public void onBiometricAuthFailed(BiometricSourceType biometricSourceType) { }
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700244
245 /**
Gilad Brettercb51b8b2018-03-22 17:04:51 +0200246 * Called when a biometric is recognized.
247 * @param userId the user id for which the biometric sample was authenticated
248 * @param biometricSourceType
Jim Millerf41fc962014-06-18 16:33:51 -0700249 */
Gilad Brettercb51b8b2018-03-22 17:04:51 +0200250 public void onBiometricAuthenticated(int userId, BiometricSourceType biometricSourceType) { }
Jorim Jaggi007f0e82015-08-14 13:56:01 -0700251
252 /**
Gilad Brettercb51b8b2018-03-22 17:04:51 +0200253 * Called when biometric authentication provides help string (e.g. "Try again")
Jim Miller9f0753f2015-03-23 23:59:22 -0700254 * @param msgId
255 * @param helpString
Gilad Brettercb51b8b2018-03-22 17:04:51 +0200256 * @param biometricSourceType
Jim Millerf41fc962014-06-18 16:33:51 -0700257 */
Gilad Brettercb51b8b2018-03-22 17:04:51 +0200258 public void onBiometricHelp(int msgId, String helpString,
259 BiometricSourceType biometricSourceType) { }
Jim Miller9f0753f2015-03-23 23:59:22 -0700260
261 /**
Gilad Brettercb51b8b2018-03-22 17:04:51 +0200262 * Called when biometric authentication method provides a semi-permanent
263 * error message (e.g. "Hardware not available").
264 * @param msgId one of the error messages listed in
265 * {@link android.hardware.biometrics.BiometricConstants}
Jim Miller9f0753f2015-03-23 23:59:22 -0700266 * @param errString
Gilad Brettercb51b8b2018-03-22 17:04:51 +0200267 * @param biometricSourceType
Jim Miller9f0753f2015-03-23 23:59:22 -0700268 */
Gilad Brettercb51b8b2018-03-22 17:04:51 +0200269 public void onBiometricError(int msgId, String errString,
270 BiometricSourceType biometricSourceType) { }
Jorim Jaggie7b12522014-08-06 16:41:21 +0200271
272 /**
273 * Called when the state of face unlock changed.
274 */
Adrian Roos4a410172014-08-20 17:41:44 +0200275 public void onFaceUnlockStateChanged(boolean running, int userId) { }
Jorim Jaggi27c9b742015-04-09 10:34:49 -0700276
277 /**
Gilad Brettercb51b8b2018-03-22 17:04:51 +0200278 * Called when biometric running state changed.
Jorim Jaggi27c9b742015-04-09 10:34:49 -0700279 */
Gilad Brettercb51b8b2018-03-22 17:04:51 +0200280 public void onBiometricRunningStateChanged(boolean running,
281 BiometricSourceType biometricSourceType) { }
Jorim Jaggi25b4d4b2015-08-11 15:54:06 -0700282
283 /**
284 * Called when the state that the user hasn't used strong authentication since quite some time
285 * has changed.
286 */
Adrian Roos1de8bcb2015-08-19 16:52:52 -0700287 public void onStrongAuthStateChanged(int userId) { }
Jorim Jaggid11d1a92016-08-16 16:02:32 -0700288
289 /**
290 * Called when the state whether we have a lockscreen wallpaper has changed.
291 */
292 public void onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper) { }
Selim Cinek99415392016-09-09 14:58:41 -0700293
294 /**
295 * Called when the dream's window state is changed.
296 * @param dreaming true if the dream's window has been created and is visible
297 */
298 public void onDreamingStateChanged(boolean dreaming) { }
Lucas Dupinef886542018-01-03 16:03:07 -0800299
300 /**
301 * Called when an error message needs to be presented on the keyguard.
302 * Message will be visible briefly, and might be overridden by other keyguard events,
303 * like fingerprint authentication errors.
304 *
305 * @param message Message that indicates an error.
306 * @see KeyguardIndicationController.BaseKeyguardCallback#HIDE_DELAY_MS
307 * @see KeyguardIndicationController#showTransientIndication(CharSequence)
308 */
309 public void onTrustAgentErrorMessage(CharSequence message) { }
Alex Chauff7653d2018-02-01 17:18:08 +0000310
311
312 /**
313 * Called when a value of logout enabled is change.
314 */
315 public void onLogoutEnabledChanged() { }
316
Aran Ink4c0d5602019-06-21 14:27:32 -0400317 /**
318 * Called when authenticated biometrics are cleared.
319 */
320 public void onBiometricsCleared() { }
321
Jim Millerbbf1a742012-07-17 18:30:30 -0700322}