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