blob: 2cdd4a5886c584d1e5847d763f8a53528feaec71 [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;
Lucas Dupinef886542018-01-03 16:03:07 -080020import android.hardware.fingerprint.FingerprintManager;
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
29/**
30 * Callback for general information relevant to lock screen.
31 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +010032public class KeyguardUpdateMonitorCallback {
John Spurlock385a63d2013-10-30 19:40:48 -040033
34 private static final long VISIBILITY_CHANGED_COLLAPSE_MS = 1000;
35 private long mVisibilityChangedCalled;
36 private boolean mShowing;
37
Jim Millerbbf1a742012-07-17 18:30:30 -070038 /**
39 * Called when the battery status changes, e.g. when plugged in or unplugged, charge
40 * level, etc. changes.
41 *
42 * @param status current battery status
43 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +010044 public void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) { }
Jim Millerbbf1a742012-07-17 18:30:30 -070045
46 /**
47 * Called once per minute or when the time changes.
48 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +010049 public void onTimeChanged() { }
Jim Millerbbf1a742012-07-17 18:30:30 -070050
51 /**
52 * Called when the carrier PLMN or SPN changes.
Jim Millerbbf1a742012-07-17 18:30:30 -070053 */
Jason Monk9ff69bd2014-12-02 16:43:17 -050054 public void onRefreshCarrierInfo() { }
Jim Millerbbf1a742012-07-17 18:30:30 -070055
56 /**
57 * Called when the ringer mode changes.
58 * @param state the current ringer state, as defined in
59 * {@link AudioManager#RINGER_MODE_CHANGED_ACTION}
60 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +010061 public void onRingerModeChanged(int state) { }
Jim Millerbbf1a742012-07-17 18:30:30 -070062
63 /**
64 * Called when the phone state changes. String will be one of:
65 * {@link TelephonyManager#EXTRA_STATE_IDLE}
66 * {@link TelephonyManager@EXTRA_STATE_RINGING}
67 * {@link TelephonyManager#EXTRA_STATE_OFFHOOK
68 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +010069 public void onPhoneStateChanged(int phoneState) { }
Jim Millerbbf1a742012-07-17 18:30:30 -070070
71 /**
Danielle Millettf6d0fc12012-10-23 16:16:52 -040072 * Called when the visibility of the keyguard changes.
73 * @param showing Indicates if the keyguard is now visible.
74 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +010075 public void onKeyguardVisibilityChanged(boolean showing) { }
Danielle Millettf6d0fc12012-10-23 16:16:52 -040076
Jorim Jaggi5cf17872014-03-26 18:31:48 +010077 public void onKeyguardVisibilityChangedRaw(boolean showing) {
John Spurlock385a63d2013-10-30 19:40:48 -040078 final long now = SystemClock.elapsedRealtime();
79 if (showing == mShowing
80 && (now - mVisibilityChangedCalled) < VISIBILITY_CHANGED_COLLAPSE_MS) return;
81 onKeyguardVisibilityChanged(showing);
82 mVisibilityChangedCalled = now;
83 mShowing = showing;
84 }
85
Danielle Millettf6d0fc12012-10-23 16:16:52 -040086 /**
Adrian Roosb6011622014-05-14 15:52:53 +020087 * Called when the keyguard enters or leaves bouncer mode.
88 * @param bouncer if true, keyguard is now in bouncer mode.
89 */
90 public void onKeyguardBouncerChanged(boolean bouncer) { }
91
92 /**
Jim Millerbbf1a742012-07-17 18:30:30 -070093 * Called when visibility of lockscreen clock changes, such as when
94 * obscured by a widget.
95 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +010096 public void onClockVisibilityChanged() { }
Jim Millerbbf1a742012-07-17 18:30:30 -070097
98 /**
99 * Called when the device becomes provisioned
100 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100101 public void onDeviceProvisioned() { }
Jim Millerbbf1a742012-07-17 18:30:30 -0700102
103 /**
104 * Called when the device policy changes.
105 * See {@link DevicePolicyManager#ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED}
106 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100107 public void onDevicePolicyManagerStateChanged() { }
Jim Millerbbf1a742012-07-17 18:30:30 -0700108
109 /**
Chris Wrenf41c61b2012-11-29 15:19:54 -0500110 * Called when the user change begins.
Jim Millerbbf1a742012-07-17 18:30:30 -0700111 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100112 public void onUserSwitching(int userId) { }
Chris Wrenf41c61b2012-11-29 15:19:54 -0500113
114 /**
115 * Called when the user change is complete.
116 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100117 public void onUserSwitchComplete(int userId) { }
Jim Millerbbf1a742012-07-17 18:30:30 -0700118
119 /**
Bill Lin6c7ccab2018-07-05 17:48:49 +0800120 * Called when the Telephony capable
121 * @param capable
122 */
123 public void onTelephonyCapable(boolean capable) { }
124
125 /**
Jim Millerbbf1a742012-07-17 18:30:30 -0700126 * Called when the SIM state changes.
Jim Miller52a61332014-11-12 19:29:51 -0800127 * @param slotId
Jim Millerbbf1a742012-07-17 18:30:30 -0700128 * @param simState
129 */
Jim Miller52a61332014-11-12 19:29:51 -0800130 public void onSimStateChanged(int subId, int slotId, IccCardConstants.State simState) { }
Jim Millerbbf1a742012-07-17 18:30:30 -0700131
132 /**
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -0700133 * Called when the user's info changed.
134 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100135 public void onUserInfoChanged(int userId) { }
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -0700136
137 /**
Jorim Jaggidadafd42016-09-30 07:20:25 -0700138 * Called when a user got unlocked.
139 */
140 public void onUserUnlocked() { }
141
142 /**
Adam Cohenefb3ffb2012-11-06 16:55:32 -0800143 * Called when boot completed.
144 *
145 * Note, this callback will only be received if boot complete occurs after registering with
146 * KeyguardUpdateMonitor.
147 */
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100148 public void onBootCompleted() { }
Jim Miller8f09fd22013-03-14 19:04:28 -0700149
150 /**
Brian Colonna7fce3802013-09-17 15:51:32 -0400151 * Called when the emergency call button is pressed.
152 */
John Spurlock813552c2014-09-19 08:30:21 -0400153 public void onEmergencyCallAction() { }
Adam Powell43a372f2013-09-27 17:43:53 -0700154
Jim Miller20daffd2013-10-07 14:59:53 -0700155 /**
156 * Called when the transport background changes.
157 * @param bitmap
158 */
Adam Powell43a372f2013-09-27 17:43:53 -0700159 public void onSetBackground(Bitmap bitmap) {
Adam Powell43a372f2013-09-27 17:43:53 -0700160 }
Jim Miller20daffd2013-10-07 14:59:53 -0700161
162 /**
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700163 * Called when the device has started waking up.
Adrian Roos369907f2017-07-14 14:53:39 +0200164 *
165 * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}.
Jim Miller20daffd2013-10-07 14:59:53 -0700166 */
Adrian Roos369907f2017-07-14 14:53:39 +0200167 @Deprecated
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700168 public void onStartedWakingUp() { }
Jim Miller20daffd2013-10-07 14:59:53 -0700169
170 /**
Jorim Jaggi95e40382015-09-16 15:53:42 -0700171 * Called when the device has started going to sleep.
172 * @param why see {@link #onFinishedGoingToSleep(int)}
Adrian Roos369907f2017-07-14 14:53:39 +0200173 *
174 * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}.
Jorim Jaggi95e40382015-09-16 15:53:42 -0700175 */
Adrian Roos369907f2017-07-14 14:53:39 +0200176 @Deprecated
Jorim Jaggi95e40382015-09-16 15:53:42 -0700177 public void onStartedGoingToSleep(int why) { }
178
179 /**
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700180 * Called when the device has finished going to sleep.
Adrian Roose99bc052017-11-20 17:55:31 +0100181 * @param why either {@link WindowManagerPolicyConstants#OFF_BECAUSE_OF_ADMIN},
182 * {@link WindowManagerPolicyConstants#OFF_BECAUSE_OF_USER}, or
183 * {@link WindowManagerPolicyConstants#OFF_BECAUSE_OF_TIMEOUT}.
Adrian Roos369907f2017-07-14 14:53:39 +0200184 *
185 * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}.
Jim Miller20daffd2013-10-07 14:59:53 -0700186 */
Adrian Roos369907f2017-07-14 14:53:39 +0200187 @Deprecated
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700188 public void onFinishedGoingToSleep(int why) { }
Adrian Roos2fe592d2014-05-17 03:11:59 +0200189
190 /**
Jorim Jaggif1518da2015-07-30 11:56:36 -0700191 * Called when the screen has been turned on.
Adrian Roos369907f2017-07-14 14:53:39 +0200192 *
193 * @deprecated use {@link com.android.systemui.keyguard.ScreenLifecycle}.
Jorim Jaggif1518da2015-07-30 11:56:36 -0700194 */
Adrian Roos369907f2017-07-14 14:53:39 +0200195 @Deprecated
Jorim Jaggif1518da2015-07-30 11:56:36 -0700196 public void onScreenTurnedOn() { }
197
198 /**
199 * Called when the screen has been turned off.
Adrian Roos369907f2017-07-14 14:53:39 +0200200 *
201 * @deprecated use {@link com.android.systemui.keyguard.ScreenLifecycle}.
Jorim Jaggif1518da2015-07-30 11:56:36 -0700202 */
Adrian Roos369907f2017-07-14 14:53:39 +0200203 @Deprecated
Jorim Jaggif1518da2015-07-30 11:56:36 -0700204 public void onScreenTurnedOff() { }
205
206 /**
Adrian Roos2fe592d2014-05-17 03:11:59 +0200207 * Called when trust changes for a user.
208 */
209 public void onTrustChanged(int userId) { }
Jim Millerf41fc962014-06-18 16:33:51 -0700210
211 /**
Adrian Roos7861c662014-07-25 15:37:28 +0200212 * Called when trust being managed changes for a user.
213 */
214 public void onTrustManagedChanged(int userId) { }
215
216 /**
Adrian Roos94e15a52015-04-16 12:23:18 -0700217 * Called after trust was granted with non-zero flags.
Adrian Roos3c9a3502014-08-06 19:09:45 +0200218 */
Adrian Roos94e15a52015-04-16 12:23:18 -0700219 public void onTrustGrantedWithFlags(int flags, int userId) { }
Adrian Roos3c9a3502014-08-06 19:09:45 +0200220
221 /**
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700222 * Called when a finger has been acquired.
223 * <p>
224 * It is guaranteed that either {@link #onFingerprintAuthenticated} or
225 * {@link #onFingerprintAuthFailed()} is called after this method eventually.
226 */
227 public void onFingerprintAcquired() { }
228
229 /**
230 * Called when a fingerprint couldn't be authenticated.
231 */
232 public void onFingerprintAuthFailed() { }
233
234 /**
Jim Millerf41fc962014-06-18 16:33:51 -0700235 * Called when a fingerprint is recognized.
Jim Miller9f0753f2015-03-23 23:59:22 -0700236 * @param userId the user id for which the fingerprint was authenticated
Jim Millerf41fc962014-06-18 16:33:51 -0700237 */
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700238 public void onFingerprintAuthenticated(int userId) { }
Jorim Jaggi007f0e82015-08-14 13:56:01 -0700239
240 /**
Jim Miller9f0753f2015-03-23 23:59:22 -0700241 * Called when fingerprint provides help string (e.g. "Try again")
242 * @param msgId
243 * @param helpString
Jim Millerf41fc962014-06-18 16:33:51 -0700244 */
Jim Miller9f0753f2015-03-23 23:59:22 -0700245 public void onFingerprintHelp(int msgId, String helpString) { }
246
247 /**
248 * Called when fingerprint provides an semi-permanent error message
249 * (e.g. "Hardware not available").
250 * @param msgId one of the error messages listed in {@link FingerprintManager}
251 * @param errString
252 */
253 public void onFingerprintError(int msgId, String errString) { }
Jorim Jaggie7b12522014-08-06 16:41:21 +0200254
255 /**
256 * Called when the state of face unlock changed.
257 */
Adrian Roos4a410172014-08-20 17:41:44 +0200258 public void onFaceUnlockStateChanged(boolean running, int userId) { }
Jorim Jaggi27c9b742015-04-09 10:34:49 -0700259
260 /**
261 * Called when the fingerprint running state changed.
262 */
263 public void onFingerprintRunningStateChanged(boolean running) { }
Jorim Jaggi25b4d4b2015-08-11 15:54:06 -0700264
265 /**
266 * Called when the state that the user hasn't used strong authentication since quite some time
267 * has changed.
268 */
Adrian Roos1de8bcb2015-08-19 16:52:52 -0700269 public void onStrongAuthStateChanged(int userId) { }
Jorim Jaggid11d1a92016-08-16 16:02:32 -0700270
271 /**
272 * Called when the state whether we have a lockscreen wallpaper has changed.
273 */
274 public void onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper) { }
Selim Cinek99415392016-09-09 14:58:41 -0700275
276 /**
277 * Called when the dream's window state is changed.
278 * @param dreaming true if the dream's window has been created and is visible
279 */
280 public void onDreamingStateChanged(boolean dreaming) { }
Lucas Dupinef886542018-01-03 16:03:07 -0800281
282 /**
283 * Called when an error message needs to be presented on the keyguard.
284 * Message will be visible briefly, and might be overridden by other keyguard events,
285 * like fingerprint authentication errors.
286 *
287 * @param message Message that indicates an error.
288 * @see KeyguardIndicationController.BaseKeyguardCallback#HIDE_DELAY_MS
289 * @see KeyguardIndicationController#showTransientIndication(CharSequence)
290 */
291 public void onTrustAgentErrorMessage(CharSequence message) { }
Alex Chauff7653d2018-02-01 17:18:08 +0000292
293
294 /**
295 * Called when a value of logout enabled is change.
296 */
297 public void onLogoutEnabledChanged() { }
298
Jim Millerbbf1a742012-07-17 18:30:30 -0700299}