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 | |
| 18 | import android.app.admin.DevicePolicyManager; |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 19 | import android.graphics.Bitmap; |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 20 | import android.media.AudioManager; |
John Spurlock | 385a63d | 2013-10-30 19:40:48 -0400 | [diff] [blame] | 21 | import android.os.SystemClock; |
Jim Miller | ebbf205 | 2015-03-31 17:24:34 -0700 | [diff] [blame] | 22 | import android.hardware.fingerprint.FingerprintManager; |
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. |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 52 | */ |
Jason Monk | 9ff69bd | 2014-12-02 16:43:17 -0500 | [diff] [blame] | 53 | public void onRefreshCarrierInfo() { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 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 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 60 | public void onRingerModeChanged(int state) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 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 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 68 | public void onPhoneStateChanged(int phoneState) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 69 | |
| 70 | /** |
Danielle Millett | f6d0fc1 | 2012-10-23 16:16:52 -0400 | [diff] [blame] | 71 | * Called when the visibility of the keyguard changes. |
| 72 | * @param showing Indicates if the keyguard is now visible. |
| 73 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 74 | public void onKeyguardVisibilityChanged(boolean showing) { } |
Danielle Millett | f6d0fc1 | 2012-10-23 16:16:52 -0400 | [diff] [blame] | 75 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 76 | public void onKeyguardVisibilityChangedRaw(boolean showing) { |
John Spurlock | 385a63d | 2013-10-30 19:40:48 -0400 | [diff] [blame] | 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 | |
Danielle Millett | f6d0fc1 | 2012-10-23 16:16:52 -0400 | [diff] [blame] | 85 | /** |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 86 | * Called when the keyguard enters or leaves bouncer mode. |
| 87 | * @param bouncer if true, keyguard is now in bouncer mode. |
| 88 | */ |
| 89 | public void onKeyguardBouncerChanged(boolean bouncer) { } |
| 90 | |
| 91 | /** |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 92 | * Called when visibility of lockscreen clock changes, such as when |
| 93 | * obscured by a widget. |
| 94 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 95 | public void onClockVisibilityChanged() { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 96 | |
| 97 | /** |
| 98 | * Called when the device becomes provisioned |
| 99 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 100 | public void onDeviceProvisioned() { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 101 | |
| 102 | /** |
| 103 | * Called when the device policy changes. |
| 104 | * See {@link DevicePolicyManager#ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED} |
| 105 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 106 | public void onDevicePolicyManagerStateChanged() { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 107 | |
| 108 | /** |
Chris Wren | f41c61b | 2012-11-29 15:19:54 -0500 | [diff] [blame] | 109 | * Called when the user change begins. |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 110 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 111 | public void onUserSwitching(int userId) { } |
Chris Wren | f41c61b | 2012-11-29 15:19:54 -0500 | [diff] [blame] | 112 | |
| 113 | /** |
| 114 | * Called when the user change is complete. |
| 115 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 116 | public void onUserSwitchComplete(int userId) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 117 | |
| 118 | /** |
| 119 | * Called when the SIM state changes. |
Jim Miller | 52a6133 | 2014-11-12 19:29:51 -0800 | [diff] [blame] | 120 | * @param slotId |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 121 | * @param simState |
| 122 | */ |
Jim Miller | 52a6133 | 2014-11-12 19:29:51 -0800 | [diff] [blame] | 123 | public void onSimStateChanged(int subId, int slotId, IccCardConstants.State simState) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 124 | |
| 125 | /** |
Amith Yamasani | 6fc1d4e | 2013-05-08 16:43:58 -0700 | [diff] [blame] | 126 | * Called when the user's info changed. |
| 127 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 128 | public void onUserInfoChanged(int userId) { } |
Amith Yamasani | 6fc1d4e | 2013-05-08 16:43:58 -0700 | [diff] [blame] | 129 | |
| 130 | /** |
Adam Cohen | efb3ffb | 2012-11-06 16:55:32 -0800 | [diff] [blame] | 131 | * Called when boot completed. |
| 132 | * |
| 133 | * Note, this callback will only be received if boot complete occurs after registering with |
| 134 | * KeyguardUpdateMonitor. |
| 135 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 136 | public void onBootCompleted() { } |
Jim Miller | 8f09fd2 | 2013-03-14 19:04:28 -0700 | [diff] [blame] | 137 | |
| 138 | /** |
Brian Colonna | 7fce380 | 2013-09-17 15:51:32 -0400 | [diff] [blame] | 139 | * Called when the emergency call button is pressed. |
| 140 | */ |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 141 | public void onEmergencyCallAction() { } |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 142 | |
Jim Miller | 20daffd | 2013-10-07 14:59:53 -0700 | [diff] [blame] | 143 | /** |
| 144 | * Called when the transport background changes. |
| 145 | * @param bitmap |
| 146 | */ |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 147 | public void onSetBackground(Bitmap bitmap) { |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 148 | } |
Jim Miller | 20daffd | 2013-10-07 14:59:53 -0700 | [diff] [blame] | 149 | |
| 150 | /** |
| 151 | * Called when the screen turns on |
| 152 | */ |
| 153 | public void onScreenTurnedOn() { } |
| 154 | |
| 155 | /** |
| 156 | * Called when the screen turns off |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 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}. |
Jim Miller | 20daffd | 2013-10-07 14:59:53 -0700 | [diff] [blame] | 160 | */ |
| 161 | public void onScreenTurnedOff(int why) { } |
Adrian Roos | 2fe592d | 2014-05-17 03:11:59 +0200 | [diff] [blame] | 162 | |
| 163 | /** |
| 164 | * Called when trust changes for a user. |
| 165 | */ |
| 166 | public void onTrustChanged(int userId) { } |
Jim Miller | f41fc96 | 2014-06-18 16:33:51 -0700 | [diff] [blame] | 167 | |
| 168 | /** |
Adrian Roos | 7861c66 | 2014-07-25 15:37:28 +0200 | [diff] [blame] | 169 | * Called when trust being managed changes for a user. |
| 170 | */ |
| 171 | public void onTrustManagedChanged(int userId) { } |
| 172 | |
| 173 | /** |
Adrian Roos | 3c9a350 | 2014-08-06 19:09:45 +0200 | [diff] [blame] | 174 | * Called when the user has proved to a trust agent that they want to use the device. |
| 175 | */ |
| 176 | public void onTrustInitiatedByUser(int userId) { } |
| 177 | |
| 178 | /** |
Jim Miller | f41fc96 | 2014-06-18 16:33:51 -0700 | [diff] [blame] | 179 | * Called when a fingerprint is recognized. |
Jim Miller | 9f0753f | 2015-03-23 23:59:22 -0700 | [diff] [blame] | 180 | * @param userId the user id for which the fingerprint was authenticated |
Jim Miller | f41fc96 | 2014-06-18 16:33:51 -0700 | [diff] [blame] | 181 | */ |
Jim Miller | 9f0753f | 2015-03-23 23:59:22 -0700 | [diff] [blame] | 182 | public void onFingerprintAuthenticated(int userId) { } |
Jim Miller | f41fc96 | 2014-06-18 16:33:51 -0700 | [diff] [blame] | 183 | |
| 184 | /** |
Jim Miller | 9f0753f | 2015-03-23 23:59:22 -0700 | [diff] [blame] | 185 | * Called when fingerprint provides help string (e.g. "Try again") |
| 186 | * @param msgId |
| 187 | * @param helpString |
Jim Miller | f41fc96 | 2014-06-18 16:33:51 -0700 | [diff] [blame] | 188 | */ |
Jim Miller | 9f0753f | 2015-03-23 23:59:22 -0700 | [diff] [blame] | 189 | public void onFingerprintHelp(int msgId, String helpString) { } |
| 190 | |
| 191 | /** |
| 192 | * Called when fingerprint provides an semi-permanent error message |
| 193 | * (e.g. "Hardware not available"). |
| 194 | * @param msgId one of the error messages listed in {@link FingerprintManager} |
| 195 | * @param errString |
| 196 | */ |
| 197 | public void onFingerprintError(int msgId, String errString) { } |
Jorim Jaggi | e7b1252 | 2014-08-06 16:41:21 +0200 | [diff] [blame] | 198 | |
| 199 | /** |
| 200 | * Called when the state of face unlock changed. |
| 201 | */ |
Adrian Roos | 4a41017 | 2014-08-20 17:41:44 +0200 | [diff] [blame] | 202 | public void onFaceUnlockStateChanged(boolean running, int userId) { } |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 203 | |
| 204 | /** |
| 205 | * Called when the fingerprint running state changed. |
| 206 | */ |
| 207 | public void onFingerprintRunningStateChanged(boolean running) { } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 208 | } |