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.media.AudioManager;
21 import android.os.SystemClock;
22 import android.hardware.fingerprint.FingerprintManager;
23 import android.telephony.TelephonyManager;
24 import android.view.WindowManagerPolicy;
25 
26 import com.android.internal.telephony.IccCardConstants;
27 
28 /**
29  * Callback for general information relevant to lock screen.
30  */
31 public class KeyguardUpdateMonitorCallback {
32 
33     private static final long VISIBILITY_CHANGED_COLLAPSE_MS = 1000;
34     private long mVisibilityChangedCalled;
35     private boolean mShowing;
36 
37     /**
38      * Called when the battery status changes, e.g. when plugged in or unplugged, charge
39      * level, etc. changes.
40      *
41      * @param status current battery status
42      */
onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status)43     public void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) { }
44 
45     /**
46      * Called once per minute or when the time changes.
47      */
onTimeChanged()48     public void onTimeChanged() { }
49 
50     /**
51      * Called when the carrier PLMN or SPN changes.
52      */
onRefreshCarrierInfo()53     public void onRefreshCarrierInfo() { }
54 
55     /**
56      * Called when the ringer mode changes.
57      * @param state the current ringer state, as defined in
58      * {@link AudioManager#RINGER_MODE_CHANGED_ACTION}
59      */
onRingerModeChanged(int state)60     public void onRingerModeChanged(int state) { }
61 
62     /**
63      * Called when the phone state changes. String will be one of:
64      * {@link TelephonyManager#EXTRA_STATE_IDLE}
65      * {@link TelephonyManager@EXTRA_STATE_RINGING}
66      * {@link TelephonyManager#EXTRA_STATE_OFFHOOK
67      */
onPhoneStateChanged(int phoneState)68     public void onPhoneStateChanged(int phoneState) { }
69 
70     /**
71      * Called when the visibility of the keyguard changes.
72      * @param showing Indicates if the keyguard is now visible.
73      */
onKeyguardVisibilityChanged(boolean showing)74     public void onKeyguardVisibilityChanged(boolean showing) { }
75 
onKeyguardVisibilityChangedRaw(boolean showing)76     public void onKeyguardVisibilityChangedRaw(boolean showing) {
77         final long now = SystemClock.elapsedRealtime();
78         if (showing == mShowing
79                 && (now - mVisibilityChangedCalled) < VISIBILITY_CHANGED_COLLAPSE_MS) return;
80         onKeyguardVisibilityChanged(showing);
81         mVisibilityChangedCalled = now;
82         mShowing = showing;
83     }
84 
85     /**
86      * Called when the keyguard enters or leaves bouncer mode.
87      * @param bouncer if true, keyguard is now in bouncer mode.
88      */
onKeyguardBouncerChanged(boolean bouncer)89     public void onKeyguardBouncerChanged(boolean bouncer) { }
90 
91     /**
92      * Called when visibility of lockscreen clock changes, such as when
93      * obscured by a widget.
94      */
onClockVisibilityChanged()95     public void onClockVisibilityChanged() { }
96 
97     /**
98      * Called when the device becomes provisioned
99      */
onDeviceProvisioned()100     public void onDeviceProvisioned() { }
101 
102     /**
103      * Called when the device policy changes.
104      * See {@link DevicePolicyManager#ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED}
105      */
onDevicePolicyManagerStateChanged()106     public void onDevicePolicyManagerStateChanged() { }
107 
108     /**
109      * Called when the user change begins.
110      */
onUserSwitching(int userId)111     public void onUserSwitching(int userId) { }
112 
113     /**
114      * Called when the user change is complete.
115      */
onUserSwitchComplete(int userId)116     public void onUserSwitchComplete(int userId) { }
117 
118     /**
119      * Called when the SIM state changes.
120      * @param slotId
121      * @param simState
122      */
onSimStateChanged(int subId, int slotId, IccCardConstants.State simState)123     public void onSimStateChanged(int subId, int slotId, IccCardConstants.State simState) { }
124 
125     /**
126      * Called when the user's info changed.
127      */
onUserInfoChanged(int userId)128     public void onUserInfoChanged(int userId) { }
129 
130     /**
131      * Called when boot completed.
132      *
133      * Note, this callback will only be received if boot complete occurs after registering with
134      * KeyguardUpdateMonitor.
135      */
onBootCompleted()136     public void onBootCompleted() { }
137 
138     /**
139      * Called when the emergency call button is pressed.
140      */
onEmergencyCallAction()141     public void onEmergencyCallAction() { }
142 
143     /**
144      * Called when the transport background changes.
145      * @param bitmap
146      */
onSetBackground(Bitmap bitmap)147     public void onSetBackground(Bitmap bitmap) {
148     }
149 
150     /**
151      * Called when the device has started waking up.
152      */
onStartedWakingUp()153     public void onStartedWakingUp() { }
154 
155     /**
156      * Called when the device has finished going to sleep.
157      * @param why either {@link WindowManagerPolicy#OFF_BECAUSE_OF_ADMIN},
158      * {@link WindowManagerPolicy#OFF_BECAUSE_OF_USER}, or
159      * {@link WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT}.
160      */
onFinishedGoingToSleep(int why)161     public void onFinishedGoingToSleep(int why) { }
162 
163     /**
164      * Called when trust changes for a user.
165      */
onTrustChanged(int userId)166     public void onTrustChanged(int userId) { }
167 
168     /**
169      * Called when trust being managed changes for a user.
170      */
onTrustManagedChanged(int userId)171     public void onTrustManagedChanged(int userId) { }
172 
173     /**
174      * Called after trust was granted with non-zero flags.
175      */
onTrustGrantedWithFlags(int flags, int userId)176     public void onTrustGrantedWithFlags(int flags, int userId) { }
177 
178     /**
179      * Called when a fingerprint is recognized.
180      * @param userId the user id for which the fingerprint was authenticated
181      * @param wakeAndUnlocking whether the authentication woke the device up and thus we'd like to
182      *                         dismiss the lockscreen before turning on the screen
183      */
onFingerprintAuthenticated(int userId, boolean wakeAndUnlocking)184     public void onFingerprintAuthenticated(int userId, boolean wakeAndUnlocking) { }
185 
186     /**
187      * Called when fingerprint provides help string (e.g. "Try again")
188      * @param msgId
189      * @param helpString
190      */
onFingerprintHelp(int msgId, String helpString)191     public void onFingerprintHelp(int msgId, String helpString) { }
192 
193     /**
194      * Called when fingerprint provides an semi-permanent error message
195      * (e.g. "Hardware not available").
196      * @param msgId one of the error messages listed in {@link FingerprintManager}
197      * @param errString
198      */
onFingerprintError(int msgId, String errString)199     public void onFingerprintError(int msgId, String errString) { }
200 
201     /**
202      * Called when the state of face unlock changed.
203      */
onFaceUnlockStateChanged(boolean running, int userId)204     public void onFaceUnlockStateChanged(boolean running, int userId) { }
205 
206     /**
207      * Called when the fingerprint running state changed.
208      */
onFingerprintRunningStateChanged(boolean running)209     public void onFingerprintRunningStateChanged(boolean running) { }
210 }
211