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.internal.telephony.IccCardConstants;
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(KeyguardUpdateMonitor.BatteryStatus status)46     public void onRefreshBatteryInfo(KeyguardUpdateMonitor.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 the carrier PLMN or SPN changes.
62      */
onRefreshCarrierInfo()63     public void onRefreshCarrierInfo() { }
64 
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      */
onRingerModeChanged(int state)70     public void onRingerModeChanged(int state) { }
71 
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      */
onPhoneStateChanged(int phoneState)78     public void onPhoneStateChanged(int phoneState) { }
79 
80     /**
81      * Called when the visibility of the keyguard changes.
82      * @param showing Indicates if the keyguard is now visible.
83      */
onKeyguardVisibilityChanged(boolean showing)84     public void onKeyguardVisibilityChanged(boolean showing) { }
85 
onKeyguardVisibilityChangedRaw(boolean showing)86     public void onKeyguardVisibilityChangedRaw(boolean showing) {
87         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 
95     /**
96      * Called when the keyguard enters or leaves bouncer mode.
97      * @param bouncer if true, keyguard is now in bouncer mode.
98      */
onKeyguardBouncerChanged(boolean bouncer)99     public void onKeyguardBouncerChanged(boolean bouncer) { }
100 
101     /**
102      * Called when visibility of lockscreen clock changes, such as when
103      * obscured by a widget.
104      */
onClockVisibilityChanged()105     public void onClockVisibilityChanged() { }
106 
107     /**
108      * Called when the device becomes provisioned
109      */
onDeviceProvisioned()110     public void onDeviceProvisioned() { }
111 
112     /**
113      * Called when the device policy changes.
114      * See {@link DevicePolicyManager#ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED}
115      */
onDevicePolicyManagerStateChanged()116     public void onDevicePolicyManagerStateChanged() { }
117 
118     /**
119      * Called when the user change begins.
120      */
onUserSwitching(int userId)121     public void onUserSwitching(int userId) { }
122 
123     /**
124      * Called when the user change is complete.
125      */
onUserSwitchComplete(int userId)126     public void onUserSwitchComplete(int userId) { }
127 
128     /**
129      * Called when the Telephony capable
130      * @param capable
131      */
onTelephonyCapable(boolean capable)132     public void onTelephonyCapable(boolean capable) { }
133 
134     /**
135      * Called when the SIM state changes.
136      * @param slotId
137      * @param simState
138      */
onSimStateChanged(int subId, int slotId, IccCardConstants.State simState)139     public void onSimStateChanged(int subId, int slotId, IccCardConstants.State simState) { }
140 
141     /**
142      * Called when the user's info changed.
143      */
onUserInfoChanged(int userId)144     public void onUserInfoChanged(int userId) { }
145 
146     /**
147      * Called when a user got unlocked.
148      */
onUserUnlocked()149     public void onUserUnlocked() { }
150 
151     /**
152      * Called when boot completed.
153      *
154      * Note, this callback will only be received if boot complete occurs after registering with
155      * KeyguardUpdateMonitor.
156      */
onBootCompleted()157     public void onBootCompleted() { }
158 
159     /**
160      * Called when the emergency call button is pressed.
161      */
onEmergencyCallAction()162     public void onEmergencyCallAction() { }
163 
164     /**
165      * Called when the transport background changes.
166      * @param bitmap
167      */
onSetBackground(Bitmap bitmap)168     public void onSetBackground(Bitmap bitmap) {
169     }
170 
171     /**
172      * Called when the device has started waking up.
173      *
174      * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}.
175      */
176     @Deprecated
onStartedWakingUp()177     public void onStartedWakingUp() { }
178 
179     /**
180      * Called when the device has started going to sleep.
181      * @param why see {@link #onFinishedGoingToSleep(int)}
182      *
183      * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}.
184      */
185     @Deprecated
onStartedGoingToSleep(int why)186     public void onStartedGoingToSleep(int why) { }
187 
188     /**
189      * Called when the device has finished going to sleep.
190      * @param why either {@link WindowManagerPolicyConstants#OFF_BECAUSE_OF_ADMIN},
191      * {@link WindowManagerPolicyConstants#OFF_BECAUSE_OF_USER}, or
192      * {@link WindowManagerPolicyConstants#OFF_BECAUSE_OF_TIMEOUT}.
193      *
194      * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}.
195      */
196     @Deprecated
onFinishedGoingToSleep(int why)197     public void onFinishedGoingToSleep(int why) { }
198 
199     /**
200      * Called when the screen has been turned on.
201      *
202      * @deprecated use {@link com.android.systemui.keyguard.ScreenLifecycle}.
203      */
204     @Deprecated
onScreenTurnedOn()205     public void onScreenTurnedOn() { }
206 
207     /**
208      * Called when the screen has been turned off.
209      *
210      * @deprecated use {@link com.android.systemui.keyguard.ScreenLifecycle}.
211      */
212     @Deprecated
onScreenTurnedOff()213     public void onScreenTurnedOff() { }
214 
215     /**
216      * Called when trust changes for a user.
217      */
onTrustChanged(int userId)218     public void onTrustChanged(int userId) { }
219 
220     /**
221      * Called when trust being managed changes for a user.
222      */
onTrustManagedChanged(int userId)223     public void onTrustManagedChanged(int userId) { }
224 
225     /**
226      * Called after trust was granted with non-zero flags.
227      */
onTrustGrantedWithFlags(int flags, int userId)228     public void onTrustGrantedWithFlags(int flags, int userId) { }
229 
230     /**
231      * Called when a biometric has been acquired.
232      * <p>
233      * It is guaranteed that either {@link #onBiometricAuthenticated} or
234      * {@link #onBiometricAuthFailed(BiometricSourceType)} is called after this method eventually.
235      * @param biometricSourceType
236      */
onBiometricAcquired(BiometricSourceType biometricSourceType)237     public void onBiometricAcquired(BiometricSourceType biometricSourceType) { }
238 
239     /**
240      * Called when a biometric couldn't be authenticated.
241      * @param biometricSourceType
242      */
onBiometricAuthFailed(BiometricSourceType biometricSourceType)243     public void onBiometricAuthFailed(BiometricSourceType biometricSourceType) { }
244 
245     /**
246      * Called when a biometric is recognized.
247      * @param userId the user id for which the biometric sample was authenticated
248      * @param biometricSourceType
249      */
onBiometricAuthenticated(int userId, BiometricSourceType biometricSourceType)250     public void onBiometricAuthenticated(int userId, BiometricSourceType biometricSourceType) { }
251 
252     /**
253      * Called when biometric authentication provides help string (e.g. "Try again")
254      * @param msgId
255      * @param helpString
256      * @param biometricSourceType
257      */
onBiometricHelp(int msgId, String helpString, BiometricSourceType biometricSourceType)258     public void onBiometricHelp(int msgId, String helpString,
259             BiometricSourceType biometricSourceType) { }
260 
261     /**
262      * 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}
266      * @param errString
267      * @param biometricSourceType
268      */
onBiometricError(int msgId, String errString, BiometricSourceType biometricSourceType)269     public void onBiometricError(int msgId, String errString,
270             BiometricSourceType biometricSourceType) { }
271 
272     /**
273      * Called when the state of face unlock changed.
274      */
onFaceUnlockStateChanged(boolean running, int userId)275     public void onFaceUnlockStateChanged(boolean running, int userId) { }
276 
277     /**
278      * Called when biometric running state changed.
279      */
onBiometricRunningStateChanged(boolean running, BiometricSourceType biometricSourceType)280     public void onBiometricRunningStateChanged(boolean running,
281             BiometricSourceType biometricSourceType) { }
282 
283     /**
284      * Called when the state that the user hasn't used strong authentication since quite some time
285      * has changed.
286      */
onStrongAuthStateChanged(int userId)287     public void onStrongAuthStateChanged(int userId) { }
288 
289     /**
290      * Called when the state whether we have a lockscreen wallpaper has changed.
291      */
onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper)292     public void onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper) { }
293 
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      */
onDreamingStateChanged(boolean dreaming)298     public void onDreamingStateChanged(boolean dreaming) { }
299 
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      */
onTrustAgentErrorMessage(CharSequence message)309     public void onTrustAgentErrorMessage(CharSequence message) { }
310 
311 
312     /**
313      * Called when a value of logout enabled is change.
314      */
onLogoutEnabledChanged()315     public void onLogoutEnabledChanged() { }
316 
317     /**
318      * Called when authenticated biometrics are cleared.
319      */
onBiometricsCleared()320     public void onBiometricsCleared() { }
321 
322 }
323