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; |
Jim Miller | 20daffd | 2013-10-07 14:59:53 -0700 | [diff] [blame] | 23 | import android.view.WindowManagerPolicy; |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 24 | |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 25 | import com.android.internal.telephony.IccCardConstants; |
| 26 | |
| 27 | /** |
| 28 | * Callback for general information relevant to lock screen. |
| 29 | */ |
| 30 | class KeyguardUpdateMonitorCallback { |
John Spurlock | 385a63d | 2013-10-30 19:40:48 -0400 | [diff] [blame] | 31 | |
| 32 | private static final long VISIBILITY_CHANGED_COLLAPSE_MS = 1000; |
| 33 | private long mVisibilityChangedCalled; |
| 34 | private boolean mShowing; |
| 35 | |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 36 | /** |
| 37 | * Called when the battery status changes, e.g. when plugged in or unplugged, charge |
| 38 | * level, etc. changes. |
| 39 | * |
| 40 | * @param status current battery status |
| 41 | */ |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 42 | void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Called once per minute or when the time changes. |
| 46 | */ |
| 47 | void onTimeChanged() { } |
| 48 | |
| 49 | /** |
| 50 | * Called when the carrier PLMN or SPN changes. |
| 51 | * |
| 52 | * @param plmn The operator name of the registered network. May be null if it shouldn't |
| 53 | * be displayed. |
| 54 | * @param spn The service provider name. May be null if it shouldn't be displayed. |
| 55 | */ |
| 56 | void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn) { } |
| 57 | |
| 58 | /** |
| 59 | * Called when the ringer mode changes. |
| 60 | * @param state the current ringer state, as defined in |
| 61 | * {@link AudioManager#RINGER_MODE_CHANGED_ACTION} |
| 62 | */ |
| 63 | void onRingerModeChanged(int state) { } |
| 64 | |
| 65 | /** |
| 66 | * Called when the phone state changes. String will be one of: |
| 67 | * {@link TelephonyManager#EXTRA_STATE_IDLE} |
| 68 | * {@link TelephonyManager@EXTRA_STATE_RINGING} |
| 69 | * {@link TelephonyManager#EXTRA_STATE_OFFHOOK |
| 70 | */ |
| 71 | void onPhoneStateChanged(int phoneState) { } |
| 72 | |
| 73 | /** |
Danielle Millett | f6d0fc1 | 2012-10-23 16:16:52 -0400 | [diff] [blame] | 74 | * Called when the visibility of the keyguard changes. |
| 75 | * @param showing Indicates if the keyguard is now visible. |
| 76 | */ |
| 77 | void onKeyguardVisibilityChanged(boolean showing) { } |
| 78 | |
John Spurlock | 385a63d | 2013-10-30 19:40:48 -0400 | [diff] [blame] | 79 | void onKeyguardVisibilityChangedRaw(boolean showing) { |
| 80 | final long now = SystemClock.elapsedRealtime(); |
| 81 | if (showing == mShowing |
| 82 | && (now - mVisibilityChangedCalled) < VISIBILITY_CHANGED_COLLAPSE_MS) return; |
| 83 | onKeyguardVisibilityChanged(showing); |
| 84 | mVisibilityChangedCalled = now; |
| 85 | mShowing = showing; |
| 86 | } |
| 87 | |
Danielle Millett | f6d0fc1 | 2012-10-23 16:16:52 -0400 | [diff] [blame] | 88 | /** |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 89 | * Called when visibility of lockscreen clock changes, such as when |
| 90 | * obscured by a widget. |
| 91 | */ |
| 92 | void onClockVisibilityChanged() { } |
| 93 | |
| 94 | /** |
| 95 | * Called when the device becomes provisioned |
| 96 | */ |
| 97 | void onDeviceProvisioned() { } |
| 98 | |
| 99 | /** |
| 100 | * Called when the device policy changes. |
| 101 | * See {@link DevicePolicyManager#ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED} |
| 102 | */ |
| 103 | void onDevicePolicyManagerStateChanged() { } |
| 104 | |
| 105 | /** |
Chris Wren | f41c61b | 2012-11-29 15:19:54 -0500 | [diff] [blame] | 106 | * Called when the user change begins. |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 107 | */ |
Chris Wren | f41c61b | 2012-11-29 15:19:54 -0500 | [diff] [blame] | 108 | void onUserSwitching(int userId) { } |
| 109 | |
| 110 | /** |
| 111 | * Called when the user change is complete. |
| 112 | */ |
| 113 | void onUserSwitchComplete(int userId) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 114 | |
| 115 | /** |
| 116 | * Called when the SIM state changes. |
| 117 | * @param simState |
| 118 | */ |
| 119 | void onSimStateChanged(IccCardConstants.State simState) { } |
| 120 | |
| 121 | /** |
| 122 | * Called when a user is removed. |
| 123 | */ |
| 124 | void onUserRemoved(int userId) { } |
Adam Cohen | efb3ffb | 2012-11-06 16:55:32 -0800 | [diff] [blame] | 125 | |
| 126 | /** |
Amith Yamasani | 6fc1d4e | 2013-05-08 16:43:58 -0700 | [diff] [blame] | 127 | * Called when the user's info changed. |
| 128 | */ |
| 129 | void onUserInfoChanged(int userId) { } |
| 130 | |
| 131 | /** |
Adam Cohen | efb3ffb | 2012-11-06 16:55:32 -0800 | [diff] [blame] | 132 | * Called when boot completed. |
| 133 | * |
| 134 | * Note, this callback will only be received if boot complete occurs after registering with |
| 135 | * KeyguardUpdateMonitor. |
| 136 | */ |
| 137 | void onBootCompleted() { } |
Jim Miller | 8f09fd2 | 2013-03-14 19:04:28 -0700 | [diff] [blame] | 138 | |
| 139 | /** |
| 140 | * Called when audio client attaches or detaches from AudioManager. |
| 141 | */ |
| 142 | void onMusicClientIdChanged(int clientGeneration, boolean clearing, PendingIntent intent) { } |
| 143 | |
| 144 | /** |
| 145 | * Called when the audio playback state changes. |
| 146 | * @param playbackState |
| 147 | * @param eventTime |
| 148 | */ |
| 149 | public void onMusicPlaybackStateChanged(int playbackState, long eventTime) { } |
| 150 | |
Brian Colonna | 7fce380 | 2013-09-17 15:51:32 -0400 | [diff] [blame] | 151 | /** |
| 152 | * Called when the emergency call button is pressed. |
| 153 | */ |
| 154 | void onEmergencyCallAction() { } |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 155 | |
Jim Miller | 20daffd | 2013-10-07 14:59:53 -0700 | [diff] [blame] | 156 | /** |
| 157 | * Called when the transport background changes. |
| 158 | * @param bitmap |
| 159 | */ |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 160 | public void onSetBackground(Bitmap bitmap) { |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 161 | } |
Jim Miller | 20daffd | 2013-10-07 14:59:53 -0700 | [diff] [blame] | 162 | |
| 163 | /** |
| 164 | * Called when the screen turns on |
| 165 | */ |
| 166 | public void onScreenTurnedOn() { } |
| 167 | |
| 168 | /** |
| 169 | * Called when the screen turns off |
| 170 | * @param why {@link WindowManagerPolicy#OFF_BECAUSE_OF_USER}, |
| 171 | * {@link WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT} or |
| 172 | * {@link WindowManagerPolicy#OFF_BECAUSE_OF_PROX_SENSOR}. |
| 173 | */ |
| 174 | public void onScreenTurnedOff(int why) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 175 | } |