Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 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 | */ |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 16 | package com.android.keyguard; |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 17 | |
Jim Miller | 8f09fd2 | 2013-03-14 19:04:28 -0700 | [diff] [blame] | 18 | import android.app.PendingIntent; |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 19 | import android.app.admin.DevicePolicyManager; |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 20 | import android.graphics.Bitmap; |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 21 | import android.media.AudioManager; |
John Spurlock | 385a63d | 2013-10-30 19:40:48 -0400 | [diff] [blame] | 22 | import android.os.SystemClock; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 23 | import android.telephony.TelephonyManager; |
Jim Miller | 20daffd | 2013-10-07 14:59:53 -0700 | [diff] [blame] | 24 | import android.view.WindowManagerPolicy; |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 25 | |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 26 | import com.android.internal.telephony.IccCardConstants; |
| 27 | |
| 28 | /** |
| 29 | * Callback for general information relevant to lock screen. |
| 30 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 31 | public class KeyguardUpdateMonitorCallback { |
John Spurlock | 385a63d | 2013-10-30 19:40:48 -0400 | [diff] [blame] | 32 | |
| 33 | private static final long VISIBILITY_CHANGED_COLLAPSE_MS = 1000; |
| 34 | private long mVisibilityChangedCalled; |
| 35 | private boolean mShowing; |
| 36 | |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 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 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 43 | public void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 44 | |
| 45 | /** |
| 46 | * Called once per minute or when the time changes. |
| 47 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 48 | public void onTimeChanged() { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 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 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 57 | public void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 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 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 64 | public void onRingerModeChanged(int state) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 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 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 72 | public void onPhoneStateChanged(int phoneState) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 73 | |
| 74 | /** |
Danielle Millett | f6d0fc1 | 2012-10-23 16:16:52 -0400 | [diff] [blame] | 75 | * Called when the visibility of the keyguard changes. |
| 76 | * @param showing Indicates if the keyguard is now visible. |
| 77 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 78 | public void onKeyguardVisibilityChanged(boolean showing) { } |
Danielle Millett | f6d0fc1 | 2012-10-23 16:16:52 -0400 | [diff] [blame] | 79 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 80 | public void onKeyguardVisibilityChangedRaw(boolean showing) { |
John Spurlock | 385a63d | 2013-10-30 19:40:48 -0400 | [diff] [blame] | 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 Millett | f6d0fc1 | 2012-10-23 16:16:52 -0400 | [diff] [blame] | 89 | /** |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 90 | * Called when visibility of lockscreen clock changes, such as when |
| 91 | * obscured by a widget. |
| 92 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 93 | public void onClockVisibilityChanged() { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 94 | |
| 95 | /** |
| 96 | * Called when the device becomes provisioned |
| 97 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 98 | public void onDeviceProvisioned() { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 99 | |
| 100 | /** |
| 101 | * Called when the device policy changes. |
| 102 | * See {@link DevicePolicyManager#ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED} |
| 103 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 104 | public void onDevicePolicyManagerStateChanged() { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 105 | |
| 106 | /** |
Chris Wren | f41c61b | 2012-11-29 15:19:54 -0500 | [diff] [blame] | 107 | * Called when the user change begins. |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 108 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 109 | public void onUserSwitching(int userId) { } |
Chris Wren | f41c61b | 2012-11-29 15:19:54 -0500 | [diff] [blame] | 110 | |
| 111 | /** |
| 112 | * Called when the user change is complete. |
| 113 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 114 | public void onUserSwitchComplete(int userId) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 115 | |
| 116 | /** |
| 117 | * Called when the SIM state changes. |
| 118 | * @param simState |
| 119 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 120 | public void onSimStateChanged(IccCardConstants.State simState) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 121 | |
| 122 | /** |
| 123 | * Called when a user is removed. |
| 124 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 125 | public void onUserRemoved(int userId) { } |
Adam Cohen | efb3ffb | 2012-11-06 16:55:32 -0800 | [diff] [blame] | 126 | |
| 127 | /** |
Amith Yamasani | 6fc1d4e | 2013-05-08 16:43:58 -0700 | [diff] [blame] | 128 | * Called when the user's info changed. |
| 129 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 130 | public void onUserInfoChanged(int userId) { } |
Amith Yamasani | 6fc1d4e | 2013-05-08 16:43:58 -0700 | [diff] [blame] | 131 | |
| 132 | /** |
Adam Cohen | efb3ffb | 2012-11-06 16:55:32 -0800 | [diff] [blame] | 133 | * Called when boot completed. |
| 134 | * |
| 135 | * Note, this callback will only be received if boot complete occurs after registering with |
| 136 | * KeyguardUpdateMonitor. |
| 137 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 138 | public void onBootCompleted() { } |
Jim Miller | 8f09fd2 | 2013-03-14 19:04:28 -0700 | [diff] [blame] | 139 | |
| 140 | /** |
| 141 | * Called when audio client attaches or detaches from AudioManager. |
| 142 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 143 | public void onMusicClientIdChanged(int clientGeneration, boolean clearing, PendingIntent intent) { } |
Jim Miller | 8f09fd2 | 2013-03-14 19:04:28 -0700 | [diff] [blame] | 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 Colonna | 7fce380 | 2013-09-17 15:51:32 -0400 | [diff] [blame] | 152 | /** |
| 153 | * Called when the emergency call button is pressed. |
| 154 | */ |
| 155 | void onEmergencyCallAction() { } |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 156 | |
Jim Miller | 20daffd | 2013-10-07 14:59:53 -0700 | [diff] [blame] | 157 | /** |
| 158 | * Called when the transport background changes. |
| 159 | * @param bitmap |
| 160 | */ |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 161 | public void onSetBackground(Bitmap bitmap) { |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 162 | } |
Jim Miller | 20daffd | 2013-10-07 14:59:53 -0700 | [diff] [blame] | 163 | |
| 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 Morales | 38a7ed0 | 2013-11-14 19:02:56 -0800 | [diff] [blame] | 176 | |
| 177 | /** |
| 178 | * Called when the NFC Service has found a tag that is registered for NFC unlock. |
| 179 | */ |
| 180 | public void onNfcUnlock() { } |
Adrian Roos | 46842d9 | 2014-03-27 14:58:03 +0100 | [diff] [blame] | 181 | |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 182 | } |