blob: 481d13285cee964dacf32ef8322326832c5f7f60 [file] [log] [blame]
Jim Millerbbf1a742012-07-17 18:30:30 -07001/*
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 Miller5ecd8112013-01-09 18:50:26 -080016package com.android.keyguard;
Jim Millerbbf1a742012-07-17 18:30:30 -070017
Jim Miller8f09fd22013-03-14 19:04:28 -070018import android.app.PendingIntent;
Jim Millerbbf1a742012-07-17 18:30:30 -070019import android.app.admin.DevicePolicyManager;
Adam Powell43a372f2013-09-27 17:43:53 -070020import android.graphics.Bitmap;
Jim Millerbbf1a742012-07-17 18:30:30 -070021import android.media.AudioManager;
John Spurlock385a63d2013-10-30 19:40:48 -040022import android.os.SystemClock;
Andres Morales38a7ed02013-11-14 19:02:56 -080023import android.util.Log;
Jim Miller20daffd2013-10-07 14:59:53 -070024import android.view.WindowManagerPolicy;
Jim Millerbbf1a742012-07-17 18:30:30 -070025
Jim Millerbbf1a742012-07-17 18:30:30 -070026import com.android.internal.telephony.IccCardConstants;
27
28/**
29 * Callback for general information relevant to lock screen.
30 */
31class KeyguardUpdateMonitorCallback {
John Spurlock385a63d2013-10-30 19:40:48 -040032
33 private static final long VISIBILITY_CHANGED_COLLAPSE_MS = 1000;
34 private long mVisibilityChangedCalled;
35 private boolean mShowing;
36
Jim Millerbbf1a742012-07-17 18:30:30 -070037 /**
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 */
Jim Millerdcb3d842012-08-23 19:18:12 -070043 void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) { }
Jim Millerbbf1a742012-07-17 18:30:30 -070044
45 /**
46 * Called once per minute or when the time changes.
47 */
48 void onTimeChanged() { }
49
50 /**
51 * Called when the carrier PLMN or SPN changes.
52 *
53 * @param plmn The operator name of the registered network. May be null if it shouldn't
54 * be displayed.
55 * @param spn The service provider name. May be null if it shouldn't be displayed.
56 */
57 void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn) { }
58
59 /**
60 * Called when the ringer mode changes.
61 * @param state the current ringer state, as defined in
62 * {@link AudioManager#RINGER_MODE_CHANGED_ACTION}
63 */
64 void onRingerModeChanged(int state) { }
65
66 /**
67 * Called when the phone state changes. String will be one of:
68 * {@link TelephonyManager#EXTRA_STATE_IDLE}
69 * {@link TelephonyManager@EXTRA_STATE_RINGING}
70 * {@link TelephonyManager#EXTRA_STATE_OFFHOOK
71 */
72 void onPhoneStateChanged(int phoneState) { }
73
74 /**
Danielle Millettf6d0fc12012-10-23 16:16:52 -040075 * Called when the visibility of the keyguard changes.
76 * @param showing Indicates if the keyguard is now visible.
77 */
78 void onKeyguardVisibilityChanged(boolean showing) { }
79
John Spurlock385a63d2013-10-30 19:40:48 -040080 void onKeyguardVisibilityChangedRaw(boolean showing) {
81 final long now = SystemClock.elapsedRealtime();
82 if (showing == mShowing
83 && (now - mVisibilityChangedCalled) < VISIBILITY_CHANGED_COLLAPSE_MS) return;
84 onKeyguardVisibilityChanged(showing);
85 mVisibilityChangedCalled = now;
86 mShowing = showing;
87 }
88
Danielle Millettf6d0fc12012-10-23 16:16:52 -040089 /**
Jim Millerbbf1a742012-07-17 18:30:30 -070090 * Called when visibility of lockscreen clock changes, such as when
91 * obscured by a widget.
92 */
93 void onClockVisibilityChanged() { }
94
95 /**
96 * Called when the device becomes provisioned
97 */
98 void onDeviceProvisioned() { }
99
100 /**
101 * Called when the device policy changes.
102 * See {@link DevicePolicyManager#ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED}
103 */
104 void onDevicePolicyManagerStateChanged() { }
105
106 /**
Chris Wrenf41c61b2012-11-29 15:19:54 -0500107 * Called when the user change begins.
Jim Millerbbf1a742012-07-17 18:30:30 -0700108 */
Chris Wrenf41c61b2012-11-29 15:19:54 -0500109 void onUserSwitching(int userId) { }
110
111 /**
112 * Called when the user change is complete.
113 */
114 void onUserSwitchComplete(int userId) { }
Jim Millerbbf1a742012-07-17 18:30:30 -0700115
116 /**
117 * Called when the SIM state changes.
118 * @param simState
119 */
120 void onSimStateChanged(IccCardConstants.State simState) { }
121
122 /**
123 * Called when a user is removed.
124 */
125 void onUserRemoved(int userId) { }
Adam Cohenefb3ffb2012-11-06 16:55:32 -0800126
127 /**
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -0700128 * Called when the user's info changed.
129 */
130 void onUserInfoChanged(int userId) { }
131
132 /**
Adam Cohenefb3ffb2012-11-06 16:55:32 -0800133 * Called when boot completed.
134 *
135 * Note, this callback will only be received if boot complete occurs after registering with
136 * KeyguardUpdateMonitor.
137 */
138 void onBootCompleted() { }
Jim Miller8f09fd22013-03-14 19:04:28 -0700139
140 /**
141 * Called when audio client attaches or detaches from AudioManager.
142 */
143 void onMusicClientIdChanged(int clientGeneration, boolean clearing, PendingIntent intent) { }
144
145 /**
146 * Called when the audio playback state changes.
147 * @param playbackState
148 * @param eventTime
149 */
150 public void onMusicPlaybackStateChanged(int playbackState, long eventTime) { }
151
Brian Colonna7fce3802013-09-17 15:51:32 -0400152 /**
153 * Called when the emergency call button is pressed.
154 */
155 void onEmergencyCallAction() { }
Adam Powell43a372f2013-09-27 17:43:53 -0700156
Jim Miller20daffd2013-10-07 14:59:53 -0700157 /**
158 * Called when the transport background changes.
159 * @param bitmap
160 */
Adam Powell43a372f2013-09-27 17:43:53 -0700161 public void onSetBackground(Bitmap bitmap) {
Adam Powell43a372f2013-09-27 17:43:53 -0700162 }
Jim Miller20daffd2013-10-07 14:59:53 -0700163
164 /**
165 * Called when the screen turns on
166 */
167 public void onScreenTurnedOn() { }
168
169 /**
170 * Called when the screen turns off
171 * @param why {@link WindowManagerPolicy#OFF_BECAUSE_OF_USER},
172 * {@link WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT} or
173 * {@link WindowManagerPolicy#OFF_BECAUSE_OF_PROX_SENSOR}.
174 */
175 public void onScreenTurnedOff(int why) { }
Andres Morales38a7ed02013-11-14 19:02:56 -0800176
177 /**
178 * Called when the NFC Service has found a tag that is registered for NFC unlock.
179 */
180 public void onNfcUnlock() { }
Jim Millerbbf1a742012-07-17 18:30:30 -0700181}