Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 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 | */ |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 16 | package com.android.keyguard; |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 17 | |
| 18 | import android.app.admin.DevicePolicyManager; |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 19 | import android.graphics.Bitmap; |
Lucas Dupin | ef88654 | 2018-01-03 16:03:07 -0800 | [diff] [blame] | 20 | import android.hardware.fingerprint.FingerprintManager; |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 21 | import android.media.AudioManager; |
John Spurlock | 385a63d | 2013-10-30 19:40:48 -0400 | [diff] [blame] | 22 | import android.os.SystemClock; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 23 | import android.telephony.TelephonyManager; |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 24 | import android.view.WindowManagerPolicyConstants; |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 25 | |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 26 | import com.android.internal.telephony.IccCardConstants; |
Lucas Dupin | ef88654 | 2018-01-03 16:03:07 -0800 | [diff] [blame] | 27 | import com.android.systemui.statusbar.KeyguardIndicationController; |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 28 | |
| 29 | /** |
| 30 | * Callback for general information relevant to lock screen. |
| 31 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 32 | public class KeyguardUpdateMonitorCallback { |
John Spurlock | 385a63d | 2013-10-30 19:40:48 -0400 | [diff] [blame] | 33 | |
| 34 | private static final long VISIBILITY_CHANGED_COLLAPSE_MS = 1000; |
| 35 | private long mVisibilityChangedCalled; |
| 36 | private boolean mShowing; |
| 37 | |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 38 | /** |
| 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 Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 44 | public void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * Called once per minute or when the time changes. |
| 48 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 49 | public void onTimeChanged() { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 50 | |
| 51 | /** |
| 52 | * Called when the carrier PLMN or SPN changes. |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 53 | */ |
Jason Monk | 9ff69bd | 2014-12-02 16:43:17 -0500 | [diff] [blame] | 54 | public void onRefreshCarrierInfo() { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 55 | |
| 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 Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 61 | public void onRingerModeChanged(int state) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 62 | |
| 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 Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 69 | public void onPhoneStateChanged(int phoneState) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 70 | |
| 71 | /** |
Danielle Millett | f6d0fc1 | 2012-10-23 16:16:52 -0400 | [diff] [blame] | 72 | * Called when the visibility of the keyguard changes. |
| 73 | * @param showing Indicates if the keyguard is now visible. |
| 74 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 75 | public void onKeyguardVisibilityChanged(boolean showing) { } |
Danielle Millett | f6d0fc1 | 2012-10-23 16:16:52 -0400 | [diff] [blame] | 76 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 77 | public void onKeyguardVisibilityChangedRaw(boolean showing) { |
John Spurlock | 385a63d | 2013-10-30 19:40:48 -0400 | [diff] [blame] | 78 | 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 Millett | f6d0fc1 | 2012-10-23 16:16:52 -0400 | [diff] [blame] | 86 | /** |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 87 | * 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 Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 93 | * Called when visibility of lockscreen clock changes, such as when |
| 94 | * obscured by a widget. |
| 95 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 96 | public void onClockVisibilityChanged() { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 97 | |
| 98 | /** |
| 99 | * Called when the device becomes provisioned |
| 100 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 101 | public void onDeviceProvisioned() { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 102 | |
| 103 | /** |
| 104 | * Called when the device policy changes. |
| 105 | * See {@link DevicePolicyManager#ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED} |
| 106 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 107 | public void onDevicePolicyManagerStateChanged() { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 108 | |
| 109 | /** |
Chris Wren | f41c61b | 2012-11-29 15:19:54 -0500 | [diff] [blame] | 110 | * Called when the user change begins. |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 111 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 112 | public void onUserSwitching(int userId) { } |
Chris Wren | f41c61b | 2012-11-29 15:19:54 -0500 | [diff] [blame] | 113 | |
| 114 | /** |
| 115 | * Called when the user change is complete. |
| 116 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 117 | public void onUserSwitchComplete(int userId) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 118 | |
| 119 | /** |
| 120 | * Called when the SIM state changes. |
Jim Miller | 52a6133 | 2014-11-12 19:29:51 -0800 | [diff] [blame] | 121 | * @param slotId |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 122 | * @param simState |
| 123 | */ |
Jim Miller | 52a6133 | 2014-11-12 19:29:51 -0800 | [diff] [blame] | 124 | public void onSimStateChanged(int subId, int slotId, IccCardConstants.State simState) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 125 | |
| 126 | /** |
Amith Yamasani | 6fc1d4e | 2013-05-08 16:43:58 -0700 | [diff] [blame] | 127 | * Called when the user's info changed. |
| 128 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 129 | public void onUserInfoChanged(int userId) { } |
Amith Yamasani | 6fc1d4e | 2013-05-08 16:43:58 -0700 | [diff] [blame] | 130 | |
| 131 | /** |
Jorim Jaggi | dadafd4 | 2016-09-30 07:20:25 -0700 | [diff] [blame] | 132 | * Called when a user got unlocked. |
| 133 | */ |
| 134 | public void onUserUnlocked() { } |
| 135 | |
| 136 | /** |
Adam Cohen | efb3ffb | 2012-11-06 16:55:32 -0800 | [diff] [blame] | 137 | * Called when boot completed. |
| 138 | * |
| 139 | * Note, this callback will only be received if boot complete occurs after registering with |
| 140 | * KeyguardUpdateMonitor. |
| 141 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 142 | public void onBootCompleted() { } |
Jim Miller | 8f09fd2 | 2013-03-14 19:04:28 -0700 | [diff] [blame] | 143 | |
| 144 | /** |
Brian Colonna | 7fce380 | 2013-09-17 15:51:32 -0400 | [diff] [blame] | 145 | * Called when the emergency call button is pressed. |
| 146 | */ |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 147 | public void onEmergencyCallAction() { } |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 148 | |
Jim Miller | 20daffd | 2013-10-07 14:59:53 -0700 | [diff] [blame] | 149 | /** |
| 150 | * Called when the transport background changes. |
| 151 | * @param bitmap |
| 152 | */ |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 153 | public void onSetBackground(Bitmap bitmap) { |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 154 | } |
Jim Miller | 20daffd | 2013-10-07 14:59:53 -0700 | [diff] [blame] | 155 | |
| 156 | /** |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 157 | * Called when the device has started waking up. |
Adrian Roos | 369907f | 2017-07-14 14:53:39 +0200 | [diff] [blame] | 158 | * |
| 159 | * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}. |
Jim Miller | 20daffd | 2013-10-07 14:59:53 -0700 | [diff] [blame] | 160 | */ |
Adrian Roos | 369907f | 2017-07-14 14:53:39 +0200 | [diff] [blame] | 161 | @Deprecated |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 162 | public void onStartedWakingUp() { } |
Jim Miller | 20daffd | 2013-10-07 14:59:53 -0700 | [diff] [blame] | 163 | |
| 164 | /** |
Jorim Jaggi | 95e4038 | 2015-09-16 15:53:42 -0700 | [diff] [blame] | 165 | * Called when the device has started going to sleep. |
| 166 | * @param why see {@link #onFinishedGoingToSleep(int)} |
Adrian Roos | 369907f | 2017-07-14 14:53:39 +0200 | [diff] [blame] | 167 | * |
| 168 | * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}. |
Jorim Jaggi | 95e4038 | 2015-09-16 15:53:42 -0700 | [diff] [blame] | 169 | */ |
Adrian Roos | 369907f | 2017-07-14 14:53:39 +0200 | [diff] [blame] | 170 | @Deprecated |
Jorim Jaggi | 95e4038 | 2015-09-16 15:53:42 -0700 | [diff] [blame] | 171 | public void onStartedGoingToSleep(int why) { } |
| 172 | |
| 173 | /** |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 174 | * Called when the device has finished going to sleep. |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 175 | * @param why either {@link WindowManagerPolicyConstants#OFF_BECAUSE_OF_ADMIN}, |
| 176 | * {@link WindowManagerPolicyConstants#OFF_BECAUSE_OF_USER}, or |
| 177 | * {@link WindowManagerPolicyConstants#OFF_BECAUSE_OF_TIMEOUT}. |
Adrian Roos | 369907f | 2017-07-14 14:53:39 +0200 | [diff] [blame] | 178 | * |
| 179 | * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}. |
Jim Miller | 20daffd | 2013-10-07 14:59:53 -0700 | [diff] [blame] | 180 | */ |
Adrian Roos | 369907f | 2017-07-14 14:53:39 +0200 | [diff] [blame] | 181 | @Deprecated |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 182 | public void onFinishedGoingToSleep(int why) { } |
Adrian Roos | 2fe592d | 2014-05-17 03:11:59 +0200 | [diff] [blame] | 183 | |
| 184 | /** |
Jorim Jaggi | f1518da | 2015-07-30 11:56:36 -0700 | [diff] [blame] | 185 | * Called when the screen has been turned on. |
Adrian Roos | 369907f | 2017-07-14 14:53:39 +0200 | [diff] [blame] | 186 | * |
| 187 | * @deprecated use {@link com.android.systemui.keyguard.ScreenLifecycle}. |
Jorim Jaggi | f1518da | 2015-07-30 11:56:36 -0700 | [diff] [blame] | 188 | */ |
Adrian Roos | 369907f | 2017-07-14 14:53:39 +0200 | [diff] [blame] | 189 | @Deprecated |
Jorim Jaggi | f1518da | 2015-07-30 11:56:36 -0700 | [diff] [blame] | 190 | public void onScreenTurnedOn() { } |
| 191 | |
| 192 | /** |
| 193 | * Called when the screen has been turned off. |
Adrian Roos | 369907f | 2017-07-14 14:53:39 +0200 | [diff] [blame] | 194 | * |
| 195 | * @deprecated use {@link com.android.systemui.keyguard.ScreenLifecycle}. |
Jorim Jaggi | f1518da | 2015-07-30 11:56:36 -0700 | [diff] [blame] | 196 | */ |
Adrian Roos | 369907f | 2017-07-14 14:53:39 +0200 | [diff] [blame] | 197 | @Deprecated |
Jorim Jaggi | f1518da | 2015-07-30 11:56:36 -0700 | [diff] [blame] | 198 | public void onScreenTurnedOff() { } |
| 199 | |
| 200 | /** |
Adrian Roos | 2fe592d | 2014-05-17 03:11:59 +0200 | [diff] [blame] | 201 | * Called when trust changes for a user. |
| 202 | */ |
| 203 | public void onTrustChanged(int userId) { } |
Jim Miller | f41fc96 | 2014-06-18 16:33:51 -0700 | [diff] [blame] | 204 | |
| 205 | /** |
Adrian Roos | 7861c66 | 2014-07-25 15:37:28 +0200 | [diff] [blame] | 206 | * Called when trust being managed changes for a user. |
| 207 | */ |
| 208 | public void onTrustManagedChanged(int userId) { } |
| 209 | |
| 210 | /** |
Adrian Roos | 94e15a5 | 2015-04-16 12:23:18 -0700 | [diff] [blame] | 211 | * Called after trust was granted with non-zero flags. |
Adrian Roos | 3c9a350 | 2014-08-06 19:09:45 +0200 | [diff] [blame] | 212 | */ |
Adrian Roos | 94e15a5 | 2015-04-16 12:23:18 -0700 | [diff] [blame] | 213 | public void onTrustGrantedWithFlags(int flags, int userId) { } |
Adrian Roos | 3c9a350 | 2014-08-06 19:09:45 +0200 | [diff] [blame] | 214 | |
| 215 | /** |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 216 | * Called when a finger has been acquired. |
| 217 | * <p> |
| 218 | * It is guaranteed that either {@link #onFingerprintAuthenticated} or |
| 219 | * {@link #onFingerprintAuthFailed()} is called after this method eventually. |
| 220 | */ |
| 221 | public void onFingerprintAcquired() { } |
| 222 | |
| 223 | /** |
| 224 | * Called when a fingerprint couldn't be authenticated. |
| 225 | */ |
| 226 | public void onFingerprintAuthFailed() { } |
| 227 | |
| 228 | /** |
Jim Miller | f41fc96 | 2014-06-18 16:33:51 -0700 | [diff] [blame] | 229 | * Called when a fingerprint is recognized. |
Jim Miller | 9f0753f | 2015-03-23 23:59:22 -0700 | [diff] [blame] | 230 | * @param userId the user id for which the fingerprint was authenticated |
Jim Miller | f41fc96 | 2014-06-18 16:33:51 -0700 | [diff] [blame] | 231 | */ |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 232 | public void onFingerprintAuthenticated(int userId) { } |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 233 | |
| 234 | /** |
Jim Miller | 9f0753f | 2015-03-23 23:59:22 -0700 | [diff] [blame] | 235 | * Called when fingerprint provides help string (e.g. "Try again") |
| 236 | * @param msgId |
| 237 | * @param helpString |
Jim Miller | f41fc96 | 2014-06-18 16:33:51 -0700 | [diff] [blame] | 238 | */ |
Jim Miller | 9f0753f | 2015-03-23 23:59:22 -0700 | [diff] [blame] | 239 | public void onFingerprintHelp(int msgId, String helpString) { } |
| 240 | |
| 241 | /** |
| 242 | * Called when fingerprint provides an semi-permanent error message |
| 243 | * (e.g. "Hardware not available"). |
| 244 | * @param msgId one of the error messages listed in {@link FingerprintManager} |
| 245 | * @param errString |
| 246 | */ |
| 247 | public void onFingerprintError(int msgId, String errString) { } |
Jorim Jaggi | e7b1252 | 2014-08-06 16:41:21 +0200 | [diff] [blame] | 248 | |
| 249 | /** |
| 250 | * Called when the state of face unlock changed. |
| 251 | */ |
Adrian Roos | 4a41017 | 2014-08-20 17:41:44 +0200 | [diff] [blame] | 252 | public void onFaceUnlockStateChanged(boolean running, int userId) { } |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 253 | |
| 254 | /** |
| 255 | * Called when the fingerprint running state changed. |
| 256 | */ |
| 257 | public void onFingerprintRunningStateChanged(boolean running) { } |
Jorim Jaggi | 25b4d4b | 2015-08-11 15:54:06 -0700 | [diff] [blame] | 258 | |
| 259 | /** |
| 260 | * Called when the state that the user hasn't used strong authentication since quite some time |
| 261 | * has changed. |
| 262 | */ |
Adrian Roos | 1de8bcb | 2015-08-19 16:52:52 -0700 | [diff] [blame] | 263 | public void onStrongAuthStateChanged(int userId) { } |
Jorim Jaggi | d11d1a9 | 2016-08-16 16:02:32 -0700 | [diff] [blame] | 264 | |
| 265 | /** |
| 266 | * Called when the state whether we have a lockscreen wallpaper has changed. |
| 267 | */ |
| 268 | public void onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper) { } |
Selim Cinek | 9941539 | 2016-09-09 14:58:41 -0700 | [diff] [blame] | 269 | |
| 270 | /** |
| 271 | * Called when the dream's window state is changed. |
| 272 | * @param dreaming true if the dream's window has been created and is visible |
| 273 | */ |
| 274 | public void onDreamingStateChanged(boolean dreaming) { } |
Lucas Dupin | ef88654 | 2018-01-03 16:03:07 -0800 | [diff] [blame] | 275 | |
| 276 | /** |
| 277 | * Called when an error message needs to be presented on the keyguard. |
| 278 | * Message will be visible briefly, and might be overridden by other keyguard events, |
| 279 | * like fingerprint authentication errors. |
| 280 | * |
| 281 | * @param message Message that indicates an error. |
| 282 | * @see KeyguardIndicationController.BaseKeyguardCallback#HIDE_DELAY_MS |
| 283 | * @see KeyguardIndicationController#showTransientIndication(CharSequence) |
| 284 | */ |
| 285 | public void onTrustAgentErrorMessage(CharSequence message) { } |
Alex Chau | ff7653d | 2018-02-01 17:18:08 +0000 | [diff] [blame] | 286 | |
| 287 | |
| 288 | /** |
| 289 | * Called when a value of logout enabled is change. |
| 290 | */ |
| 291 | public void onLogoutEnabledChanged() { } |
| 292 | |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 293 | } |