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