The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1 | /* |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 2 | * Copyright (C) 2014 The Android Open Source Project |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 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 |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 14 | * limitations under the License |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 15 | */ |
| 16 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 17 | package com.android.systemui.keyguard; |
Jim Miller | bc4603b | 2010-08-30 21:21:34 -0700 | [diff] [blame] | 18 | |
Jorim Jaggi | d11d1a9 | 2016-08-16 16:02:32 -0700 | [diff] [blame] | 19 | import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT; |
Adrian Roos | e92de95 | 2016-12-13 12:07:09 -0800 | [diff] [blame] | 20 | |
| 21 | import static com.android.internal.telephony.IccCardConstants.State.ABSENT; |
Lucas Dupin | 6d48eab | 2018-09-17 17:17:14 -0700 | [diff] [blame] | 22 | import static com.android.internal.telephony.IccCardConstants.State.PIN_REQUIRED; |
| 23 | import static com.android.internal.telephony.IccCardConstants.State.PUK_REQUIRED; |
Jorim Jaggi | d11d1a9 | 2016-08-16 16:02:32 -0700 | [diff] [blame] | 24 | import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_USER_REQUEST; |
| 25 | import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW; |
| 26 | import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT; |
Michal Karpinski | c52f867 | 2016-11-18 11:32:45 +0000 | [diff] [blame] | 27 | import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_TIMEOUT; |
Jorim Jaggi | d11d1a9 | 2016-08-16 16:02:32 -0700 | [diff] [blame] | 28 | |
Adrian Roos | b60d47c | 2014-09-08 19:23:00 +0200 | [diff] [blame] | 29 | import android.app.ActivityManager; |
Wale Ogunwale | 04d9cb5 | 2018-04-30 13:55:07 -0700 | [diff] [blame] | 30 | import android.app.ActivityTaskManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 31 | import android.app.AlarmManager; |
| 32 | import android.app.PendingIntent; |
Mike Lockwood | 5f892c1 | 2009-11-19 23:39:13 -0500 | [diff] [blame] | 33 | import android.app.StatusBarManager; |
Adrian Roos | 481a6df | 2014-11-20 19:48:56 +0100 | [diff] [blame] | 34 | import android.app.trust.TrustManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 35 | import android.content.BroadcastReceiver; |
Daniel Sandler | db783bd | 2010-02-11 15:27:37 -0500 | [diff] [blame] | 36 | import android.content.ContentResolver; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 37 | import android.content.Context; |
| 38 | import android.content.Intent; |
| 39 | import android.content.IntentFilter; |
Adrian Roos | be47b07 | 2014-09-03 00:08:56 +0200 | [diff] [blame] | 40 | import android.content.pm.UserInfo; |
Lucas Dupin | 6d48eab | 2018-09-17 17:17:14 -0700 | [diff] [blame] | 41 | import android.hardware.biometrics.BiometricSourceType; |
Jean-Michel Trivi | 0616db4 | 2019-01-28 10:57:21 -0800 | [diff] [blame] | 42 | import android.media.AudioAttributes; |
Daniel Sandler | aec967a | 2010-02-20 01:05:22 -0500 | [diff] [blame] | 43 | import android.media.AudioManager; |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 44 | import android.media.SoundPool; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 45 | import android.os.Bundle; |
dooyoung.hwang | 328472e | 2015-05-21 16:09:43 +0900 | [diff] [blame] | 46 | import android.os.DeadObjectException; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 47 | import android.os.Handler; |
Jeff Brown | 109025d | 2012-08-14 20:41:30 -0700 | [diff] [blame] | 48 | import android.os.Looper; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 49 | import android.os.Message; |
| 50 | import android.os.PowerManager; |
Dianne Hackborn | 4994c66 | 2009-09-23 22:21:23 -0700 | [diff] [blame] | 51 | import android.os.RemoteException; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 52 | import android.os.SystemClock; |
Jim Miller | 1b15202 | 2009-10-28 16:08:15 -0700 | [diff] [blame] | 53 | import android.os.SystemProperties; |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 54 | import android.os.Trace; |
Jeff Sharkey | 6a25cbd | 2012-08-23 12:14:26 -0700 | [diff] [blame] | 55 | import android.os.UserHandle; |
Amith Yamasani | b70ff9a | 2012-09-07 18:28:11 -0700 | [diff] [blame] | 56 | import android.os.UserManager; |
Daniel Sandler | db783bd | 2010-02-11 15:27:37 -0500 | [diff] [blame] | 57 | import android.provider.Settings; |
Jim Miller | 52a6133 | 2014-11-12 19:29:51 -0800 | [diff] [blame] | 58 | import android.telephony.SubscriptionManager; |
Karl Rosaen | ab10008 | 2009-03-24 22:35:17 -0700 | [diff] [blame] | 59 | import android.telephony.TelephonyManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 60 | import android.util.EventLog; |
Karl Rosaen | ab10008 | 2009-03-24 22:35:17 -0700 | [diff] [blame] | 61 | import android.util.Log; |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 62 | import android.util.Slog; |
Lucas Dupin | 6d48eab | 2018-09-17 17:17:14 -0700 | [diff] [blame] | 63 | import android.util.SparseArray; |
Selim Cinek | 06c12d6 | 2019-07-01 19:44:18 -0700 | [diff] [blame] | 64 | import android.view.View; |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 65 | import android.view.ViewGroup; |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 66 | import android.view.WindowManagerPolicyConstants; |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 67 | import android.view.animation.Animation; |
| 68 | import android.view.animation.AnimationUtils; |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 69 | |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 70 | import com.android.internal.policy.IKeyguardDismissCallback; |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 71 | import com.android.internal.policy.IKeyguardDrawnCallback; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 72 | import com.android.internal.policy.IKeyguardExitCallback; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 73 | import com.android.internal.policy.IKeyguardStateCallback; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 74 | import com.android.internal.telephony.IccCardConstants; |
Lucas Dupin | 6d48eab | 2018-09-17 17:17:14 -0700 | [diff] [blame] | 75 | import com.android.internal.util.LatencyTracker; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 76 | import com.android.internal.widget.LockPatternUtils; |
Jim Miller | 52a6133 | 2014-11-12 19:29:51 -0800 | [diff] [blame] | 77 | import com.android.keyguard.KeyguardConstants; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 78 | import com.android.keyguard.KeyguardDisplayManager; |
Selim Cinek | 3122fa8 | 2015-06-18 01:38:59 -0700 | [diff] [blame] | 79 | import com.android.keyguard.KeyguardSecurityView; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 80 | import com.android.keyguard.KeyguardUpdateMonitor; |
| 81 | import com.android.keyguard.KeyguardUpdateMonitorCallback; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 82 | import com.android.keyguard.ViewMediatorCallback; |
Jorim Jaggi | e549a8d | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 83 | import com.android.systemui.Dependency; |
Sunny Goyal | 87fccf0 | 2019-08-13 17:39:10 -0700 | [diff] [blame] | 84 | import com.android.systemui.R; |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 85 | import com.android.systemui.SystemUI; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 86 | import com.android.systemui.SystemUIFactory; |
Jorim Jaggi | e549a8d | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 87 | import com.android.systemui.UiOffloadThread; |
Dave Mankoff | 2339f59 | 2019-06-28 16:33:25 -0400 | [diff] [blame] | 88 | import com.android.systemui.plugins.FalsingManager; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 89 | import com.android.systemui.statusbar.phone.BiometricUnlockController; |
Selim Cinek | 06c12d6 | 2019-07-01 19:44:18 -0700 | [diff] [blame] | 90 | import com.android.systemui.statusbar.phone.KeyguardBypassController; |
Lucas Dupin | 6d48eab | 2018-09-17 17:17:14 -0700 | [diff] [blame] | 91 | import com.android.systemui.statusbar.phone.NotificationPanelView; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 92 | import com.android.systemui.statusbar.phone.StatusBar; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 93 | import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; |
Lucas Dupin | e25c487 | 2019-07-29 13:51:35 -0700 | [diff] [blame] | 94 | import com.android.systemui.statusbar.phone.StatusBarWindowController; |
Robert Snoeberger | be35b76 | 2019-03-15 14:33:02 -0400 | [diff] [blame] | 95 | import com.android.systemui.util.InjectionInflationController; |
Adrian Roos | 58b58fe | 2014-01-31 16:00:39 -0800 | [diff] [blame] | 96 | |
Jorim Jaggi | 84dc08a | 2015-09-11 17:45:22 -0700 | [diff] [blame] | 97 | import java.io.FileDescriptor; |
| 98 | import java.io.PrintWriter; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 99 | import java.util.ArrayList; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 100 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 101 | /** |
| 102 | * Mediates requests related to the keyguard. This includes queries about the |
| 103 | * state of the keyguard, power management events that effect whether the keyguard |
| 104 | * should be shown or reset, callbacks to the phone window manager to notify |
| 105 | * it of when the keyguard is showing, and events from the keyguard view itself |
| 106 | * stating that the keyguard was succesfully unlocked. |
| 107 | * |
| 108 | * Note that the keyguard view is shown when the screen is off (as appropriate) |
| 109 | * so that once the screen comes on, it will be ready immediately. |
| 110 | * |
| 111 | * Example queries about the keyguard: |
| 112 | * - is {movement, key} one that should wake the keygaurd? |
| 113 | * - is the keyguard showing? |
| 114 | * - are input events restricted due to the state of the keyguard? |
| 115 | * |
| 116 | * Callbacks to the phone window manager: |
| 117 | * - the keyguard is showing |
| 118 | * |
| 119 | * Example external events that translate to keyguard view changes: |
| 120 | * - screen turned off -> reset the keyguard, and show it so it will be ready |
| 121 | * next time the screen turns on |
| 122 | * - keyboard is slid open -> if the keyguard is not secure, hide it |
| 123 | * |
| 124 | * Events from the keyguard view: |
| 125 | * - user succesfully unlocked keyguard -> hide keyguard view, and no longer |
| 126 | * restrict input events. |
| 127 | * |
| 128 | * Note: in addition to normal power managment events that effect the state of |
| 129 | * whether the keyguard should be showing, external apps and services may request |
| 130 | * that the keyguard be disabled via {@link #setKeyguardEnabled(boolean)}. When |
| 131 | * false, this will override all other conditions for turning on the keyguard. |
| 132 | * |
| 133 | * Threading and synchronization: |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 134 | * This class is created by the initialization routine of the {@link WindowManagerPolicyConstants}, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 135 | * and runs on its thread. The keyguard UI is created from that thread in the |
| 136 | * constructor of this class. The apis may be called from other threads, including the |
Jeff Brown | 4532e61 | 2012-04-05 14:27:12 -0700 | [diff] [blame] | 137 | * {@link com.android.server.input.InputManagerService}'s and {@link android.view.WindowManager}'s. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 138 | * Therefore, methods on this class are synchronized, and any action that is pointed |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 139 | * directly to the keyguard UI is posted to a {@link android.os.Handler} to ensure it is taken on the UI |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 140 | * thread of the keyguard. |
| 141 | */ |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 142 | public class KeyguardViewMediator extends SystemUI { |
Jim Miller | bc4603b | 2010-08-30 21:21:34 -0700 | [diff] [blame] | 143 | private static final int KEYGUARD_DISPLAY_TIMEOUT_DELAY_DEFAULT = 30000; |
Jorim Jaggi | f8d77da | 2014-11-11 16:59:12 +0100 | [diff] [blame] | 144 | private static final long KEYGUARD_DONE_PENDING_TIMEOUT_MS = 3000; |
| 145 | |
Jim Miller | 52a6133 | 2014-11-12 19:29:51 -0800 | [diff] [blame] | 146 | private static final boolean DEBUG = KeyguardConstants.DEBUG; |
| 147 | private static final boolean DEBUG_SIM_STATES = KeyguardConstants.DEBUG_SIM_STATES; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 148 | |
| 149 | private final static String TAG = "KeyguardViewMediator"; |
| 150 | |
Jim Miller | 9c20d0e | 2010-01-20 15:00:23 -0800 | [diff] [blame] | 151 | private static final String DELAYED_KEYGUARD_ACTION = |
Wink Saville | 37c124c | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 152 | "com.android.internal.policy.impl.PhoneWindowManager.DELAYED_KEYGUARD"; |
Clara Bayarri | 56878a9 | 2015-10-29 15:43:55 +0000 | [diff] [blame] | 153 | private static final String DELAYED_LOCK_PROFILE_ACTION = |
| 154 | "com.android.internal.policy.impl.PhoneWindowManager.DELAYED_LOCK"; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 155 | |
Kevin Chyn | 18e91aa | 2018-04-11 12:55:45 -0700 | [diff] [blame] | 156 | private static final String SYSTEMUI_PERMISSION = "com.android.systemui.permission.SELF"; |
| 157 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 158 | // used for handler messages |
Jorim Jaggi | 8d78693 | 2016-10-26 19:08:36 -0700 | [diff] [blame] | 159 | private static final int SHOW = 1; |
| 160 | private static final int HIDE = 2; |
| 161 | private static final int RESET = 3; |
| 162 | private static final int VERIFY_UNLOCK = 4; |
| 163 | private static final int NOTIFY_FINISHED_GOING_TO_SLEEP = 5; |
| 164 | private static final int NOTIFY_SCREEN_TURNING_ON = 6; |
| 165 | private static final int KEYGUARD_DONE = 7; |
| 166 | private static final int KEYGUARD_DONE_DRAWING = 8; |
| 167 | private static final int SET_OCCLUDED = 9; |
| 168 | private static final int KEYGUARD_TIMEOUT = 10; |
| 169 | private static final int DISMISS = 11; |
| 170 | private static final int START_KEYGUARD_EXIT_ANIM = 12; |
| 171 | private static final int KEYGUARD_DONE_PENDING_TIMEOUT = 13; |
| 172 | private static final int NOTIFY_STARTED_WAKING_UP = 14; |
| 173 | private static final int NOTIFY_SCREEN_TURNED_ON = 15; |
| 174 | private static final int NOTIFY_SCREEN_TURNED_OFF = 16; |
| 175 | private static final int NOTIFY_STARTED_GOING_TO_SLEEP = 17; |
Adrian Roos | 30a2ae6 | 2018-04-25 19:09:50 +0200 | [diff] [blame] | 176 | private static final int SYSTEM_READY = 18; |
Jim Miller | 9c20d0e | 2010-01-20 15:00:23 -0800 | [diff] [blame] | 177 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 178 | /** |
| 179 | * The default amount of time we stay awake (used for all key input) |
| 180 | */ |
Lucas Dupin | e90fead | 2019-06-12 16:22:41 -0700 | [diff] [blame] | 181 | public static final int AWAKE_INTERVAL_BOUNCER_MS = 10000; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 182 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 183 | /** |
| 184 | * How long to wait after the screen turns off due to timeout before |
| 185 | * turning on the keyguard (i.e, the user has this much time to turn |
| 186 | * the screen back on without having to face the keyguard). |
| 187 | */ |
Jim Miller | bc4603b | 2010-08-30 21:21:34 -0700 | [diff] [blame] | 188 | private static final int KEYGUARD_LOCK_AFTER_DELAY_DEFAULT = 5000; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 189 | |
| 190 | /** |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 191 | * How long we'll wait for the {@link ViewMediatorCallback#keyguardDoneDrawing()} |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 192 | * callback before unblocking a call to {@link #setKeyguardEnabled(boolean)} |
| 193 | * that is reenabling the keyguard. |
| 194 | */ |
| 195 | private static final int KEYGUARD_DONE_DRAWING_TIMEOUT_MS = 2000; |
Jim Miller | 9c20d0e | 2010-01-20 15:00:23 -0800 | [diff] [blame] | 196 | |
Daniel Sandler | 74d188c | 2011-08-10 00:00:31 -0400 | [diff] [blame] | 197 | /** |
Evan Rosky | 13a58a9 | 2016-07-27 15:51:09 -0700 | [diff] [blame] | 198 | * Boolean option for doKeyguardLocked/doKeyguardTimeout which, when set to true, forces the |
| 199 | * keyguard to show even if it is disabled for the current user. |
| 200 | */ |
| 201 | public static final String OPTION_FORCE_SHOW = "force_show"; |
| 202 | |
Amith Yamasani | 8cb751b | 2011-09-30 15:39:41 -0700 | [diff] [blame] | 203 | /** The stream type that the lock sounds are tied to. */ |
John Spurlock | ee5ad72 | 2015-03-03 16:17:21 -0500 | [diff] [blame] | 204 | private int mUiSoundsStreamType; |
Amith Yamasani | 8cb751b | 2011-09-30 15:39:41 -0700 | [diff] [blame] | 205 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 206 | private AlarmManager mAlarmManager; |
Amith Yamasani | 8cb751b | 2011-09-30 15:39:41 -0700 | [diff] [blame] | 207 | private AudioManager mAudioManager; |
Mike Lockwood | 5f892c1 | 2009-11-19 23:39:13 -0500 | [diff] [blame] | 208 | private StatusBarManager mStatusBarManager; |
Lucas Dupin | e25c487 | 2019-07-29 13:51:35 -0700 | [diff] [blame] | 209 | private final StatusBarWindowController mStatusBarWindowController = |
| 210 | Dependency.get(StatusBarWindowController.class); |
Jorim Jaggi | e549a8d | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 211 | private final UiOffloadThread mUiOffloadThread = Dependency.get(UiOffloadThread.class); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 212 | |
| 213 | private boolean mSystemReady; |
Jason Monk | cf5a953 | 2014-09-17 16:22:19 -0400 | [diff] [blame] | 214 | private boolean mBootCompleted; |
| 215 | private boolean mBootSendUserPresent; |
Adrian Roos | 1f8025a | 2016-12-27 10:12:13 -0800 | [diff] [blame] | 216 | private boolean mShuttingDown; |
Lucas Dupin | b3455e6 | 2019-07-11 11:47:13 +0900 | [diff] [blame] | 217 | private boolean mDozing; |
Daniel Sandler | 0060a9b | 2010-03-15 23:09:57 -0400 | [diff] [blame] | 218 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 219 | /** High level access to the power manager for WakeLocks */ |
| 220 | private PowerManager mPM; |
| 221 | |
Adrian Roos | 481a6df | 2014-11-20 19:48:56 +0100 | [diff] [blame] | 222 | /** TrustManager for letting it know when we change visibility */ |
| 223 | private TrustManager mTrustManager; |
Amith Yamasani | b70ff9a | 2012-09-07 18:28:11 -0700 | [diff] [blame] | 224 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 225 | /** |
Mike Lockwood | 674d3e4 | 2009-10-06 09:28:54 -0400 | [diff] [blame] | 226 | * Used to keep the device awake while to ensure the keyguard finishes opening before |
| 227 | * we sleep. |
| 228 | */ |
| 229 | private PowerManager.WakeLock mShowKeyguardWakeLock; |
| 230 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 231 | private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 232 | |
| 233 | // these are protected by synchronized (this) |
| 234 | |
| 235 | /** |
Mike Lockwood | 5d258b6 | 2009-12-02 13:50:45 -0500 | [diff] [blame] | 236 | * External apps (like the phone app) can tell us to disable the keygaurd. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 237 | */ |
| 238 | private boolean mExternallyEnabled = true; |
| 239 | |
| 240 | /** |
| 241 | * Remember if an external call to {@link #setKeyguardEnabled} with value |
| 242 | * false caused us to hide the keyguard, so that we need to reshow it once |
| 243 | * the keygaurd is reenabled with another call with value true. |
| 244 | */ |
| 245 | private boolean mNeedToReshowWhenReenabled = false; |
| 246 | |
| 247 | // cached value of whether we are showing (need to know this to quickly |
| 248 | // answer whether the input should be restricted) |
Jim Miller | e5f17ab | 2013-11-13 15:40:48 -0800 | [diff] [blame] | 249 | private boolean mShowing; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 250 | |
Lucas Dupin | 47a65c7 | 2018-02-15 14:16:18 -0800 | [diff] [blame] | 251 | // AOD is enabled and status bar is in AOD state. |
| 252 | private boolean mAodShowing; |
| 253 | |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 254 | /** Cached value of #isInputRestricted */ |
| 255 | private boolean mInputRestricted; |
| 256 | |
Mike Lockwood | 09a4040 | 2009-11-08 00:33:23 -0500 | [diff] [blame] | 257 | // true if the keyguard is hidden by another window |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 258 | private boolean mOccluded = false; |
Mike Lockwood | 09a4040 | 2009-11-08 00:33:23 -0500 | [diff] [blame] | 259 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 260 | /** |
| 261 | * Helps remember whether the screen has turned on since the last time |
| 262 | * it turned off due to timeout. see {@link #onScreenTurnedOff(int)} |
| 263 | */ |
| 264 | private int mDelayedShowingSequence; |
| 265 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 266 | /** |
Tony Mak | 9c6e8ce | 2016-03-21 12:07:16 +0000 | [diff] [blame] | 267 | * Simiar to {@link #mDelayedProfileShowingSequence}, but it is for profile case. |
| 268 | */ |
| 269 | private int mDelayedProfileShowingSequence; |
| 270 | |
| 271 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 272 | * If the user has disabled the keyguard, then requests to exit, this is |
| 273 | * how we'll ultimately let them know whether it was successful. We use this |
| 274 | * var being non-null as an indicator that there is an in progress request. |
| 275 | */ |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 276 | private IKeyguardExitCallback mExitSecureCallback; |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 277 | private final DismissCallbackRegistry mDismissCallbackRegistry = new DismissCallbackRegistry(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 278 | |
| 279 | // the properties of the keyguard |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 280 | |
| 281 | private KeyguardUpdateMonitor mUpdateMonitor; |
| 282 | |
Lucas Dupin | 6d48eab | 2018-09-17 17:17:14 -0700 | [diff] [blame] | 283 | /** |
| 284 | * Last SIM state reported by the telephony system. |
| 285 | * Index is the slotId - in case of multiple SIM cards. |
| 286 | */ |
| 287 | private final SparseArray<IccCardConstants.State> mLastSimStates = new SparseArray<>(); |
| 288 | |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 289 | private boolean mDeviceInteractive; |
Jorim Jaggi | 4474f54 | 2015-07-09 16:08:02 -0700 | [diff] [blame] | 290 | private boolean mGoingToSleep; |
Karl Rosaen | ab10008 | 2009-03-24 22:35:17 -0700 | [diff] [blame] | 291 | |
Daniel Sandler | f2d8e74 | 2010-02-22 13:09:48 -0500 | [diff] [blame] | 292 | // last known state of the cellular connection |
| 293 | private String mPhoneState = TelephonyManager.EXTRA_STATE_IDLE; |
| 294 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 295 | /** |
Jorim Jaggi | 53c68a4 | 2014-06-17 15:04:47 -0700 | [diff] [blame] | 296 | * Whether a hide is pending an we are just waiting for #startKeyguardExitAnimation to be |
| 297 | * called. |
| 298 | * */ |
| 299 | private boolean mHiding; |
| 300 | |
| 301 | /** |
The Android Open Source Project | c84bf28 | 2009-03-09 11:52:14 -0700 | [diff] [blame] | 302 | * we send this intent when the keyguard is dismissed. |
| 303 | */ |
Jim Miller | 17f509a | 2013-02-28 18:36:12 -0800 | [diff] [blame] | 304 | private static final Intent USER_PRESENT_INTENT = new Intent(Intent.ACTION_USER_PRESENT) |
| 305 | .addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING |
Chad Brubaker | 291df4f | 2017-03-14 10:23:02 -0700 | [diff] [blame] | 306 | | Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT |
| 307 | | Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS); |
The Android Open Source Project | c84bf28 | 2009-03-09 11:52:14 -0700 | [diff] [blame] | 308 | |
| 309 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 310 | * {@link #setKeyguardEnabled} waits on this condition when it reenables |
| 311 | * the keyguard. |
| 312 | */ |
| 313 | private boolean mWaitingUntilKeyguardVisible = false; |
Jim Miller | bc4603b | 2010-08-30 21:21:34 -0700 | [diff] [blame] | 314 | private LockPatternUtils mLockPatternUtils; |
John Spurlock | 34c4fe5 | 2012-11-07 10:12:29 -0500 | [diff] [blame] | 315 | private boolean mKeyguardDonePending = false; |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 316 | private boolean mHideAnimationRun = false; |
Jorim Jaggi | 8d5a6e7 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 317 | private boolean mHideAnimationRunning = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 318 | |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 319 | private SoundPool mLockSounds; |
| 320 | private int mLockSoundId; |
| 321 | private int mUnlockSoundId; |
Adrian Roos | 49e057d | 2014-08-13 17:14:51 +0200 | [diff] [blame] | 322 | private int mTrustedSoundId; |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 323 | private int mLockSoundStreamId; |
Jean-Michel Trivi | c55b393 | 2012-06-05 11:57:59 -0700 | [diff] [blame] | 324 | |
| 325 | /** |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 326 | * The animation used for hiding keyguard. This is used to fetch the animation timings if |
| 327 | * WindowManager is not providing us with them. |
| 328 | */ |
| 329 | private Animation mHideAnimation; |
| 330 | |
| 331 | /** |
Jean-Michel Trivi | c55b393 | 2012-06-05 11:57:59 -0700 | [diff] [blame] | 332 | * The volume applied to the lock/unlock sounds. |
| 333 | */ |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 334 | private float mLockSoundVolume; |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 335 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 336 | /** |
Jim Miller | 3192148 | 2013-11-06 20:43:55 -0800 | [diff] [blame] | 337 | * For managing external displays |
| 338 | */ |
| 339 | private KeyguardDisplayManager mKeyguardDisplayManager; |
| 340 | |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 341 | private final ArrayList<IKeyguardStateCallback> mKeyguardStateCallbacks = new ArrayList<>(); |
| 342 | |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 343 | /** |
| 344 | * When starting going to sleep, we figured out that we need to reset Keyguard state and this |
| 345 | * should be committed when finished going to sleep. |
| 346 | */ |
| 347 | private boolean mPendingReset; |
| 348 | |
| 349 | /** |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 350 | * When starting going to sleep, we figured out that we need to lock Keyguard and this should be |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 351 | * committed when finished going to sleep. |
| 352 | */ |
| 353 | private boolean mPendingLock; |
| 354 | |
Robin Lee | c41f6ec | 2017-01-10 17:02:34 +0000 | [diff] [blame] | 355 | /** |
| 356 | * Controller for showing individual "work challenge" lock screen windows inside managed profile |
| 357 | * tasks when the current user has been unlocked but the profile is still locked. |
| 358 | */ |
| 359 | private WorkLockActivityController mWorkLockController; |
| 360 | |
Lucas Dupin | d35502f | 2018-06-27 13:35:52 -0700 | [diff] [blame] | 361 | /** |
| 362 | * @see #setPulsing(boolean) |
| 363 | */ |
| 364 | private boolean mPulsing; |
| 365 | |
Tony Mak | 9c6e8ce | 2016-03-21 12:07:16 +0000 | [diff] [blame] | 366 | private boolean mLockLater; |
| 367 | |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 368 | private boolean mWakeAndUnlocking; |
| 369 | private IKeyguardDrawnCallback mDrawnCallback; |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 370 | private CharSequence mCustomMessage; |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 371 | |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 372 | KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() { |
| 373 | |
| 374 | @Override |
Chris Wren | f41c61b | 2012-11-29 15:19:54 -0500 | [diff] [blame] | 375 | public void onUserSwitching(int userId) { |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 376 | // Note that the mLockPatternUtils user has already been updated from setCurrentUser. |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 377 | // We need to force a reset of the views, since lockNow (called by |
| 378 | // ActivityManagerService) will not reconstruct the keyguard if it is already showing. |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 379 | synchronized (KeyguardViewMediator.this) { |
Jorim Jaggi | f8d77da | 2014-11-11 16:59:12 +0100 | [diff] [blame] | 380 | resetKeyguardDonePendingLocked(); |
Alex Chau | 77ef9fc | 2018-04-11 15:41:32 +0100 | [diff] [blame] | 381 | if (mLockPatternUtils.isLockScreenDisabled(userId)) { |
| 382 | // If we switching to a user that has keyguard disabled, dismiss keyguard. |
| 383 | dismiss(null /* callback */, null /* message */); |
| 384 | } else { |
| 385 | resetStateLocked(); |
| 386 | } |
John Spurlock | 4e6922d | 2012-10-04 14:51:51 -0400 | [diff] [blame] | 387 | adjustStatusBarLocked(); |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 388 | } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | @Override |
Chris Wren | f41c61b | 2012-11-29 15:19:54 -0500 | [diff] [blame] | 392 | public void onUserSwitchComplete(int userId) { |
Xiaohui Chen | 87d0e25 | 2015-07-30 15:38:16 -0700 | [diff] [blame] | 393 | if (userId != UserHandle.USER_SYSTEM) { |
Adrian Roos | be47b07 | 2014-09-03 00:08:56 +0200 | [diff] [blame] | 394 | UserInfo info = UserManager.get(mContext).getUserInfo(userId); |
Kevin Chyn | f2c0a64 | 2017-05-25 11:29:08 -0700 | [diff] [blame] | 395 | // Don't try to dismiss if the user has Pin/Patter/Password set |
| 396 | if (info == null || mLockPatternUtils.isSecure(userId)) { |
| 397 | return; |
| 398 | } else if (info.isGuest() || info.isDemo()) { |
Adrian Roos | be47b07 | 2014-09-03 00:08:56 +0200 | [diff] [blame] | 399 | // If we just switched to a guest, try to dismiss keyguard. |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 400 | dismiss(null /* callback */, null /* message */); |
Adrian Roos | be47b07 | 2014-09-03 00:08:56 +0200 | [diff] [blame] | 401 | } |
| 402 | } |
Chris Wren | f41c61b | 2012-11-29 15:19:54 -0500 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | @Override |
Amith Yamasani | 6fc1d4e | 2013-05-08 16:43:58 -0700 | [diff] [blame] | 406 | public void onUserInfoChanged(int userId) { |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | @Override |
Jim Miller | b030476 | 2012-03-13 20:01:25 -0700 | [diff] [blame] | 410 | public void onClockVisibilityChanged() { |
| 411 | adjustStatusBarLocked(); |
| 412 | } |
| 413 | |
| 414 | @Override |
| 415 | public void onDeviceProvisioned() { |
Jim Miller | 3fd47af | 2012-09-21 19:55:27 -0700 | [diff] [blame] | 416 | sendUserPresentBroadcast(); |
Amith Yamasani | cb15d66 | 2015-11-10 11:11:15 -0800 | [diff] [blame] | 417 | synchronized (KeyguardViewMediator.this) { |
| 418 | // If system user is provisioned, we might want to lock now to avoid showing launcher |
Amith Yamasani | eb437d4 | 2016-04-29 09:31:25 -0700 | [diff] [blame] | 419 | if (mustNotUnlockCurrentUser()) { |
Amith Yamasani | cb15d66 | 2015-11-10 11:11:15 -0800 | [diff] [blame] | 420 | doKeyguardLocked(null); |
| 421 | } |
| 422 | } |
Jim Miller | b030476 | 2012-03-13 20:01:25 -0700 | [diff] [blame] | 423 | } |
| 424 | |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 425 | @Override |
Jim Miller | 52a6133 | 2014-11-12 19:29:51 -0800 | [diff] [blame] | 426 | public void onSimStateChanged(int subId, int slotId, IccCardConstants.State simState) { |
| 427 | |
| 428 | if (DEBUG_SIM_STATES) { |
| 429 | Log.d(TAG, "onSimStateChanged(subId=" + subId + ", slotId=" + slotId |
| 430 | + ",state=" + simState + ")"); |
| 431 | } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 432 | |
dooyoung.hwang | 328472e | 2015-05-21 16:09:43 +0900 | [diff] [blame] | 433 | int size = mKeyguardStateCallbacks.size(); |
| 434 | boolean simPinSecure = mUpdateMonitor.isSimPinSecure(); |
| 435 | for (int i = size - 1; i >= 0; i--) { |
| 436 | try { |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 437 | mKeyguardStateCallbacks.get(i).onSimSecureStateChanged(simPinSecure); |
dooyoung.hwang | 328472e | 2015-05-21 16:09:43 +0900 | [diff] [blame] | 438 | } catch (RemoteException e) { |
| 439 | Slog.w(TAG, "Failed to call onSimSecureStateChanged", e); |
| 440 | if (e instanceof DeadObjectException) { |
| 441 | mKeyguardStateCallbacks.remove(i); |
| 442 | } |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 443 | } |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 444 | } |
| 445 | |
Lucas Dupin | 6d48eab | 2018-09-17 17:17:14 -0700 | [diff] [blame] | 446 | boolean simWasLocked; |
| 447 | synchronized (KeyguardViewMediator.this) { |
| 448 | IccCardConstants.State lastState = mLastSimStates.get(slotId); |
Brad Ebinger | e6c6f72 | 2018-12-20 21:11:44 -0800 | [diff] [blame] | 449 | simWasLocked = (lastState == PIN_REQUIRED || lastState == PUK_REQUIRED); |
Lucas Dupin | 6d48eab | 2018-09-17 17:17:14 -0700 | [diff] [blame] | 450 | mLastSimStates.append(slotId, simState); |
| 451 | } |
| 452 | |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 453 | switch (simState) { |
| 454 | case NOT_READY: |
| 455 | case ABSENT: |
| 456 | // only force lock screen in case of missing sim if user hasn't |
| 457 | // gone through setup wizard |
Adrian Roos | 1cffe3c | 2016-11-28 15:46:06 -0800 | [diff] [blame] | 458 | synchronized (KeyguardViewMediator.this) { |
Jim Miller | b256e4e2 | 2014-10-31 17:27:13 -0700 | [diff] [blame] | 459 | if (shouldWaitForProvisioning()) { |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 460 | if (!mShowing) { |
Jim Miller | 52a6133 | 2014-11-12 19:29:51 -0800 | [diff] [blame] | 461 | if (DEBUG_SIM_STATES) Log.d(TAG, "ICC_ABSENT isn't showing," |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 462 | + " we need to show the keyguard since the " |
| 463 | + "device isn't provisioned yet."); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 464 | doKeyguardLocked(null); |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 465 | } else { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 466 | resetStateLocked(); |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 467 | } |
| 468 | } |
Adrian Roos | e92de95 | 2016-12-13 12:07:09 -0800 | [diff] [blame] | 469 | if (simState == ABSENT) { |
| 470 | // MVNO SIMs can become transiently NOT_READY when switching networks, |
| 471 | // so we should only lock when they are ABSENT. |
Lucas Dupin | 2e0d495 | 2018-12-05 20:03:53 -0800 | [diff] [blame] | 472 | if (simWasLocked) { |
Brad Ebinger | e6c6f72 | 2018-12-20 21:11:44 -0800 | [diff] [blame] | 473 | if (DEBUG_SIM_STATES) Log.d(TAG, "SIM moved to ABSENT when the " |
| 474 | + "previous state was locked. Reset the state."); |
Lucas Dupin | 2e0d495 | 2018-12-05 20:03:53 -0800 | [diff] [blame] | 475 | resetStateLocked(); |
| 476 | } |
Adrian Roos | e92de95 | 2016-12-13 12:07:09 -0800 | [diff] [blame] | 477 | } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 478 | } |
| 479 | break; |
| 480 | case PIN_REQUIRED: |
| 481 | case PUK_REQUIRED: |
Adrian Roos | 1cffe3c | 2016-11-28 15:46:06 -0800 | [diff] [blame] | 482 | synchronized (KeyguardViewMediator.this) { |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 483 | if (!mShowing) { |
Jim Miller | 52a6133 | 2014-11-12 19:29:51 -0800 | [diff] [blame] | 484 | if (DEBUG_SIM_STATES) Log.d(TAG, |
| 485 | "INTENT_VALUE_ICC_LOCKED and keygaurd isn't " |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 486 | + "showing; need to show keyguard so user can enter sim pin"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 487 | doKeyguardLocked(null); |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 488 | } else { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 489 | resetStateLocked(); |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 490 | } |
| 491 | } |
| 492 | break; |
| 493 | case PERM_DISABLED: |
Adrian Roos | 1cffe3c | 2016-11-28 15:46:06 -0800 | [diff] [blame] | 494 | synchronized (KeyguardViewMediator.this) { |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 495 | if (!mShowing) { |
Jim Miller | 52a6133 | 2014-11-12 19:29:51 -0800 | [diff] [blame] | 496 | if (DEBUG_SIM_STATES) Log.d(TAG, "PERM_DISABLED and " |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 497 | + "keygaurd isn't showing."); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 498 | doKeyguardLocked(null); |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 499 | } else { |
Jim Miller | 52a6133 | 2014-11-12 19:29:51 -0800 | [diff] [blame] | 500 | if (DEBUG_SIM_STATES) Log.d(TAG, "PERM_DISABLED, resetStateLocked to" |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 501 | + "show permanently disabled message in lockscreen."); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 502 | resetStateLocked(); |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 503 | } |
| 504 | } |
| 505 | break; |
| 506 | case READY: |
Adrian Roos | 1cffe3c | 2016-11-28 15:46:06 -0800 | [diff] [blame] | 507 | synchronized (KeyguardViewMediator.this) { |
Lucas Dupin | ab3079d | 2018-06-07 09:41:18 -0700 | [diff] [blame] | 508 | if (DEBUG_SIM_STATES) Log.d(TAG, "READY, reset state? " + mShowing); |
Lucas Dupin | 6d48eab | 2018-09-17 17:17:14 -0700 | [diff] [blame] | 509 | if (mShowing && simWasLocked) { |
Brad Ebinger | e6c6f72 | 2018-12-20 21:11:44 -0800 | [diff] [blame] | 510 | if (DEBUG_SIM_STATES) Log.d(TAG, "SIM moved to READY when the " |
| 511 | + "previous state was locked. Reset the state."); |
Lucas Dupin | 6d48eab | 2018-09-17 17:17:14 -0700 | [diff] [blame] | 512 | resetStateLocked(); |
| 513 | } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 514 | } |
| 515 | break; |
Jim Miller | 52a6133 | 2014-11-12 19:29:51 -0800 | [diff] [blame] | 516 | default: |
Adrian Roos | 1cffe3c | 2016-11-28 15:46:06 -0800 | [diff] [blame] | 517 | if (DEBUG_SIM_STATES) Log.v(TAG, "Unspecific state: " + simState); |
Jim Miller | 52a6133 | 2014-11-12 19:29:51 -0800 | [diff] [blame] | 518 | break; |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 519 | } |
| 520 | } |
Michal Karpinski | ed5c8f0 | 2016-02-09 15:43:41 +0000 | [diff] [blame] | 521 | |
| 522 | @Override |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 523 | public void onBiometricAuthFailed(BiometricSourceType biometricSourceType) { |
Michal Karpinski | ed5c8f0 | 2016-02-09 15:43:41 +0000 | [diff] [blame] | 524 | final int currentUser = KeyguardUpdateMonitor.getCurrentUser(); |
| 525 | if (mLockPatternUtils.isSecure(currentUser)) { |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 526 | mLockPatternUtils.getDevicePolicyManager().reportFailedBiometricAttempt( |
Michal Karpinski | ed5c8f0 | 2016-02-09 15:43:41 +0000 | [diff] [blame] | 527 | currentUser); |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | @Override |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 532 | public void onBiometricAuthenticated(int userId, BiometricSourceType biometricSourceType) { |
Michal Karpinski | ed5c8f0 | 2016-02-09 15:43:41 +0000 | [diff] [blame] | 533 | if (mLockPatternUtils.isSecure(userId)) { |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 534 | mLockPatternUtils.getDevicePolicyManager().reportSuccessfulBiometricAttempt( |
Michal Karpinski | ed5c8f0 | 2016-02-09 15:43:41 +0000 | [diff] [blame] | 535 | userId); |
| 536 | } |
| 537 | } |
Adrian Roos | d88eb26 | 2016-08-04 14:50:48 -0700 | [diff] [blame] | 538 | |
| 539 | @Override |
| 540 | public void onTrustChanged(int userId) { |
| 541 | if (userId == KeyguardUpdateMonitor.getCurrentUser()) { |
| 542 | synchronized (KeyguardViewMediator.this) { |
| 543 | notifyTrustedChangedLocked(mUpdateMonitor.getUserHasTrust(userId)); |
| 544 | } |
| 545 | } |
| 546 | } |
| 547 | |
Jorim Jaggi | d11d1a9 | 2016-08-16 16:02:32 -0700 | [diff] [blame] | 548 | @Override |
| 549 | public void onHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper) { |
| 550 | synchronized (KeyguardViewMediator.this) { |
| 551 | notifyHasLockscreenWallpaperChanged(hasLockscreenWallpaper); |
| 552 | } |
| 553 | } |
Jim Miller | b030476 | 2012-03-13 20:01:25 -0700 | [diff] [blame] | 554 | }; |
| 555 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 556 | ViewMediatorCallback mViewMediatorCallback = new ViewMediatorCallback() { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 557 | |
Jim Miller | 2967f48 | 2016-01-07 15:05:32 -0800 | [diff] [blame] | 558 | @Override |
Jeff Brown | c7505bc | 2012-10-05 21:58:15 -0700 | [diff] [blame] | 559 | public void userActivity() { |
| 560 | KeyguardViewMediator.this.userActivity(); |
| 561 | } |
| 562 | |
Jim Miller | 2967f48 | 2016-01-07 15:05:32 -0800 | [diff] [blame] | 563 | @Override |
Vadim Tryshev | 8702ca7 | 2016-04-22 08:14:12 -0700 | [diff] [blame] | 564 | public void keyguardDone(boolean strongAuth, int targetUserId) { |
| 565 | if (targetUserId != ActivityManager.getCurrentUser()) { |
| 566 | return; |
| 567 | } |
| 568 | |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 569 | tryKeyguardDone(); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 570 | } |
| 571 | |
Jim Miller | 2967f48 | 2016-01-07 15:05:32 -0800 | [diff] [blame] | 572 | @Override |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 573 | public void keyguardDoneDrawing() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 574 | Trace.beginSection("KeyguardViewMediator.mViewMediatorCallback#keyguardDoneDrawing"); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 575 | mHandler.sendEmptyMessage(KEYGUARD_DONE_DRAWING); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 576 | Trace.endSection(); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | @Override |
| 580 | public void setNeedsInput(boolean needsInput) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 581 | mStatusBarKeyguardViewManager.setNeedsInput(needsInput); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 582 | } |
Jeff Brown | c7505bc | 2012-10-05 21:58:15 -0700 | [diff] [blame] | 583 | |
| 584 | @Override |
Vadim Tryshev | 8702ca7 | 2016-04-22 08:14:12 -0700 | [diff] [blame] | 585 | public void keyguardDonePending(boolean strongAuth, int targetUserId) { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 586 | Trace.beginSection("KeyguardViewMediator.mViewMediatorCallback#keyguardDonePending"); |
Vadim Tryshev | 8702ca7 | 2016-04-22 08:14:12 -0700 | [diff] [blame] | 587 | if (targetUserId != ActivityManager.getCurrentUser()) { |
Nick Desaulniers | aeb2e1e | 2016-07-27 15:36:01 -0700 | [diff] [blame] | 588 | Trace.endSection(); |
Vadim Tryshev | 8702ca7 | 2016-04-22 08:14:12 -0700 | [diff] [blame] | 589 | return; |
| 590 | } |
| 591 | |
John Spurlock | 34c4fe5 | 2012-11-07 10:12:29 -0500 | [diff] [blame] | 592 | mKeyguardDonePending = true; |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 593 | mHideAnimationRun = true; |
Jorim Jaggi | 8d5a6e7 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 594 | mHideAnimationRunning = true; |
| 595 | mStatusBarKeyguardViewManager.startPreHideAnimation(mHideAnimationFinishedRunnable); |
Jorim Jaggi | f8d77da | 2014-11-11 16:59:12 +0100 | [diff] [blame] | 596 | mHandler.sendEmptyMessageDelayed(KEYGUARD_DONE_PENDING_TIMEOUT, |
| 597 | KEYGUARD_DONE_PENDING_TIMEOUT_MS); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 598 | Trace.endSection(); |
John Spurlock | 34c4fe5 | 2012-11-07 10:12:29 -0500 | [diff] [blame] | 599 | } |
Jim Miller | 0b9d8ac | 2013-11-07 19:15:49 -0800 | [diff] [blame] | 600 | |
| 601 | @Override |
| 602 | public void keyguardGone() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 603 | Trace.beginSection("KeyguardViewMediator.mViewMediatorCallback#keyguardGone"); |
Jim Miller | 0b9d8ac | 2013-11-07 19:15:49 -0800 | [diff] [blame] | 604 | mKeyguardDisplayManager.hide(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 605 | Trace.endSection(); |
Jim Miller | 0b9d8ac | 2013-11-07 19:15:49 -0800 | [diff] [blame] | 606 | } |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 607 | |
| 608 | @Override |
| 609 | public void readyForKeyguardDone() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 610 | Trace.beginSection("KeyguardViewMediator.mViewMediatorCallback#readyForKeyguardDone"); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 611 | if (mKeyguardDonePending) { |
Jorim Jaggi | 8d5a6e7 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 612 | mKeyguardDonePending = false; |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 613 | tryKeyguardDone(); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 614 | } |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 615 | Trace.endSection(); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 616 | } |
Adrian Roos | 49e057d | 2014-08-13 17:14:51 +0200 | [diff] [blame] | 617 | |
| 618 | @Override |
Andrew Lee | 72b46d4 | 2015-01-30 13:23:21 -0800 | [diff] [blame] | 619 | public void resetKeyguard() { |
| 620 | resetStateLocked(); |
| 621 | } |
| 622 | |
| 623 | @Override |
Aarthi Balachander | 0a427ef | 2018-07-13 15:00:58 -0700 | [diff] [blame] | 624 | public void onCancelClicked() { |
| 625 | mStatusBarKeyguardViewManager.onCancelClicked(); |
| 626 | } |
| 627 | |
| 628 | @Override |
Matthew Ng | 66f0b70 | 2017-12-08 12:58:42 -0800 | [diff] [blame] | 629 | public void onBouncerVisiblityChanged(boolean shown) { |
| 630 | synchronized (KeyguardViewMediator.this) { |
| 631 | adjustStatusBarLocked(shown); |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | @Override |
Adrian Roos | 49e057d | 2014-08-13 17:14:51 +0200 | [diff] [blame] | 636 | public void playTrustedSound() { |
| 637 | KeyguardViewMediator.this.playTrustedSound(); |
| 638 | } |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 639 | |
| 640 | @Override |
Adrian Roos | 94e15a5 | 2015-04-16 12:23:18 -0700 | [diff] [blame] | 641 | public boolean isScreenOn() { |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 642 | return mDeviceInteractive; |
Adrian Roos | 94e15a5 | 2015-04-16 12:23:18 -0700 | [diff] [blame] | 643 | } |
Selim Cinek | 3122fa8 | 2015-06-18 01:38:59 -0700 | [diff] [blame] | 644 | |
| 645 | @Override |
| 646 | public int getBouncerPromptReason() { |
| 647 | int currentUser = ActivityManager.getCurrentUser(); |
Adrian Roos | c13723f | 2016-01-12 20:29:03 +0100 | [diff] [blame] | 648 | boolean trust = mTrustManager.isTrustUsuallyManaged(currentUser); |
Lucas Dupin | 8d48fc4 | 2019-04-25 14:34:12 -0700 | [diff] [blame] | 649 | boolean biometrics = mUpdateMonitor.isUnlockingWithBiometricsPossible(currentUser); |
| 650 | boolean any = trust || biometrics; |
Adrian Roos | c13723f | 2016-01-12 20:29:03 +0100 | [diff] [blame] | 651 | KeyguardUpdateMonitor.StrongAuthTracker strongAuthTracker = |
| 652 | mUpdateMonitor.getStrongAuthTracker(); |
| 653 | int strongAuth = strongAuthTracker.getStrongAuthForUser(currentUser); |
| 654 | |
| 655 | if (any && !strongAuthTracker.hasUserAuthenticatedSinceBoot()) { |
Selim Cinek | 3122fa8 | 2015-06-18 01:38:59 -0700 | [diff] [blame] | 656 | return KeyguardSecurityView.PROMPT_REASON_RESTART; |
Michal Karpinski | c52f867 | 2016-11-18 11:32:45 +0000 | [diff] [blame] | 657 | } else if (any && (strongAuth & STRONG_AUTH_REQUIRED_AFTER_TIMEOUT) != 0) { |
Jorim Jaggi | 25b4d4b | 2015-08-11 15:54:06 -0700 | [diff] [blame] | 658 | return KeyguardSecurityView.PROMPT_REASON_TIMEOUT; |
Adrian Roos | c13723f | 2016-01-12 20:29:03 +0100 | [diff] [blame] | 659 | } else if (any && (strongAuth & STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW) != 0) { |
| 660 | return KeyguardSecurityView.PROMPT_REASON_DEVICE_ADMIN; |
| 661 | } else if (trust && (strongAuth & SOME_AUTH_REQUIRED_AFTER_USER_REQUEST) != 0) { |
| 662 | return KeyguardSecurityView.PROMPT_REASON_USER_REQUEST; |
| 663 | } else if (any && (strongAuth & STRONG_AUTH_REQUIRED_AFTER_LOCKOUT) != 0) { |
| 664 | return KeyguardSecurityView.PROMPT_REASON_AFTER_LOCKOUT; |
Selim Cinek | 3122fa8 | 2015-06-18 01:38:59 -0700 | [diff] [blame] | 665 | } |
| 666 | return KeyguardSecurityView.PROMPT_REASON_NONE; |
| 667 | } |
David Stevens | 53a39ea | 2017-08-23 18:41:49 -0700 | [diff] [blame] | 668 | |
| 669 | @Override |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 670 | public CharSequence consumeCustomMessage() { |
| 671 | final CharSequence message = mCustomMessage; |
| 672 | mCustomMessage = null; |
| 673 | return message; |
| 674 | } |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 675 | }; |
| 676 | |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 677 | public void userActivity() { |
Jeff Brown | 3dc524b | 2012-09-30 19:49:11 -0700 | [diff] [blame] | 678 | mPM.userActivity(SystemClock.uptimeMillis(), false); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 679 | } |
| 680 | |
Amith Yamasani | eb437d4 | 2016-04-29 09:31:25 -0700 | [diff] [blame] | 681 | boolean mustNotUnlockCurrentUser() { |
Christine Franks | 338c6ed | 2017-08-08 09:39:16 -0700 | [diff] [blame] | 682 | return UserManager.isSplitSystemUser() |
Amith Yamasani | eb437d4 | 2016-04-29 09:31:25 -0700 | [diff] [blame] | 683 | && KeyguardUpdateMonitor.getCurrentUser() == UserHandle.USER_SYSTEM; |
| 684 | } |
| 685 | |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 686 | private void setupLocked() { |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 687 | mPM = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); |
Adrian Roos | 481a6df | 2014-11-20 19:48:56 +0100 | [diff] [blame] | 688 | mTrustManager = (TrustManager) mContext.getSystemService(Context.TRUST_SERVICE); |
| 689 | |
Mike Lockwood | 674d3e4 | 2009-10-06 09:28:54 -0400 | [diff] [blame] | 690 | mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard"); |
| 691 | mShowKeyguardWakeLock.setReferenceCounted(false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 692 | |
Adrian Roos | 1f8025a | 2016-12-27 10:12:13 -0800 | [diff] [blame] | 693 | IntentFilter filter = new IntentFilter(); |
Adrian Roos | 1f8025a | 2016-12-27 10:12:13 -0800 | [diff] [blame] | 694 | filter.addAction(Intent.ACTION_SHUTDOWN); |
| 695 | mContext.registerReceiver(mBroadcastReceiver, filter); |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 696 | |
Kevin Chyn | 18e91aa | 2018-04-11 12:55:45 -0700 | [diff] [blame] | 697 | final IntentFilter delayedActionFilter = new IntentFilter(); |
| 698 | delayedActionFilter.addAction(DELAYED_KEYGUARD_ACTION); |
| 699 | delayedActionFilter.addAction(DELAYED_LOCK_PROFILE_ACTION); |
| 700 | mContext.registerReceiver(mDelayedLockBroadcastReceiver, delayedActionFilter, |
| 701 | SYSTEMUI_PERMISSION, null /* scheduler */); |
| 702 | |
Robert Snoeberger | be35b76 | 2019-03-15 14:33:02 -0400 | [diff] [blame] | 703 | InjectionInflationController injectionInflationController = |
| 704 | new InjectionInflationController(SystemUIFactory.getInstance().getRootComponent()); |
| 705 | mKeyguardDisplayManager = new KeyguardDisplayManager(mContext, |
| 706 | injectionInflationController); |
Jim Miller | 3192148 | 2013-11-06 20:43:55 -0800 | [diff] [blame] | 707 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 708 | mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 709 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 710 | mUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 711 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 712 | mLockPatternUtils = new LockPatternUtils(mContext); |
Adrian Roos | d6aa6cb | 2015-04-16 19:31:29 -0700 | [diff] [blame] | 713 | KeyguardUpdateMonitor.setCurrentUser(ActivityManager.getCurrentUser()); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 714 | |
Jorim Jaggi | 7687aaa9 | 2017-05-12 00:21:06 +0200 | [diff] [blame] | 715 | // Assume keyguard is showing (unless it's disabled) until we know for sure, unless Keyguard |
| 716 | // is disabled. |
Sunny Goyal | 87fccf0 | 2019-08-13 17:39:10 -0700 | [diff] [blame] | 717 | if (mContext.getResources().getBoolean(R.bool.config_enableKeyguardService)) { |
Jorim Jaggi | 7687aaa9 | 2017-05-12 00:21:06 +0200 | [diff] [blame] | 718 | setShowingLocked(!shouldWaitForProvisioning() |
| 719 | && !mLockPatternUtils.isLockScreenDisabled( |
Lucas Dupin | b3455e6 | 2019-07-11 11:47:13 +0900 | [diff] [blame] | 720 | KeyguardUpdateMonitor.getCurrentUser()), true /* forceCallbacks */); |
Leif Hendrik Wilden | c6dc1c9 | 2018-02-01 10:54:15 -0800 | [diff] [blame] | 721 | } else { |
| 722 | // The system's keyguard is disabled or missing. |
Lucas Dupin | b3455e6 | 2019-07-11 11:47:13 +0900 | [diff] [blame] | 723 | setShowingLocked(false /* showing */, true /* forceCallbacks */); |
Jorim Jaggi | 7687aaa9 | 2017-05-12 00:21:06 +0200 | [diff] [blame] | 724 | } |
Jim Miller | e5f17ab | 2013-11-13 15:40:48 -0800 | [diff] [blame] | 725 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 726 | mStatusBarKeyguardViewManager = |
| 727 | SystemUIFactory.getInstance().createStatusBarKeyguardViewManager(mContext, |
| 728 | mViewMediatorCallback, mLockPatternUtils); |
Daniel Sandler | 687a327 | 2010-03-13 15:44:47 -0500 | [diff] [blame] | 729 | final ContentResolver cr = mContext.getContentResolver(); |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 730 | |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 731 | mDeviceInteractive = mPM.isInteractive(); |
Daniel Hansson | 4b71686 | 2012-03-29 11:02:05 +0200 | [diff] [blame] | 732 | |
Jean-Michel Trivi | 0616db4 | 2019-01-28 10:57:21 -0800 | [diff] [blame] | 733 | mLockSounds = new SoundPool.Builder() |
| 734 | .setMaxStreams(1) |
| 735 | .setAudioAttributes( |
| 736 | new AudioAttributes.Builder() |
| 737 | .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) |
| 738 | .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) |
| 739 | .build()) |
| 740 | .build(); |
Jim Miller | b14288d | 2012-09-30 18:25:05 -0700 | [diff] [blame] | 741 | String soundPath = Settings.Global.getString(cr, Settings.Global.LOCK_SOUND); |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 742 | if (soundPath != null) { |
| 743 | mLockSoundId = mLockSounds.load(soundPath, 1); |
| 744 | } |
| 745 | if (soundPath == null || mLockSoundId == 0) { |
Jim Miller | b14288d | 2012-09-30 18:25:05 -0700 | [diff] [blame] | 746 | Log.w(TAG, "failed to load lock sound from " + soundPath); |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 747 | } |
Jim Miller | b14288d | 2012-09-30 18:25:05 -0700 | [diff] [blame] | 748 | soundPath = Settings.Global.getString(cr, Settings.Global.UNLOCK_SOUND); |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 749 | if (soundPath != null) { |
| 750 | mUnlockSoundId = mLockSounds.load(soundPath, 1); |
| 751 | } |
| 752 | if (soundPath == null || mUnlockSoundId == 0) { |
Jim Miller | b14288d | 2012-09-30 18:25:05 -0700 | [diff] [blame] | 753 | Log.w(TAG, "failed to load unlock sound from " + soundPath); |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 754 | } |
Adrian Roos | 49e057d | 2014-08-13 17:14:51 +0200 | [diff] [blame] | 755 | soundPath = Settings.Global.getString(cr, Settings.Global.TRUSTED_SOUND); |
| 756 | if (soundPath != null) { |
| 757 | mTrustedSoundId = mLockSounds.load(soundPath, 1); |
| 758 | } |
| 759 | if (soundPath == null || mTrustedSoundId == 0) { |
| 760 | Log.w(TAG, "failed to load trusted sound from " + soundPath); |
| 761 | } |
| 762 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 763 | int lockSoundDefaultAttenuation = mContext.getResources().getInteger( |
Jean-Michel Trivi | c55b393 | 2012-06-05 11:57:59 -0700 | [diff] [blame] | 764 | com.android.internal.R.integer.config_lockSoundVolumeDb); |
Jean-Michel Trivi | f2b0c11 | 2012-07-09 11:59:11 -0700 | [diff] [blame] | 765 | mLockSoundVolume = (float)Math.pow(10, (float)lockSoundDefaultAttenuation/20); |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 766 | |
| 767 | mHideAnimation = AnimationUtils.loadAnimation(mContext, |
| 768 | com.android.internal.R.anim.lock_screen_behind_enter); |
Robin Lee | c41f6ec | 2017-01-10 17:02:34 +0000 | [diff] [blame] | 769 | |
| 770 | mWorkLockController = new WorkLockActivityController(mContext); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 771 | } |
| 772 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 773 | @Override |
| 774 | public void start() { |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 775 | synchronized (this) { |
| 776 | setupLocked(); |
| 777 | } |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 778 | putComponent(KeyguardViewMediator.class, this); |
| 779 | } |
| 780 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 781 | /** |
| 782 | * Let us know that the system is ready after startup. |
| 783 | */ |
| 784 | public void onSystemReady() { |
Adrian Roos | 30a2ae6 | 2018-04-25 19:09:50 +0200 | [diff] [blame] | 785 | mHandler.obtainMessage(SYSTEM_READY).sendToTarget(); |
| 786 | } |
| 787 | |
| 788 | private void handleSystemReady() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 789 | synchronized (this) { |
| 790 | if (DEBUG) Log.d(TAG, "onSystemReady"); |
| 791 | mSystemReady = true; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 792 | doKeyguardLocked(null); |
Selim Cinek | edd32b8 | 2015-06-23 22:05:58 -0400 | [diff] [blame] | 793 | mUpdateMonitor.registerCallback(mUpdateCallback); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 794 | } |
Jim Miller | 3fd47af | 2012-09-21 19:55:27 -0700 | [diff] [blame] | 795 | // Most services aren't available until the system reaches the ready state, so we |
| 796 | // send it here when the device first boots. |
| 797 | maybeSendUserPresentBroadcast(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 798 | } |
| 799 | |
| 800 | /** |
| 801 | * Called to let us know the screen was turned off. |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 802 | * @param why either {@link WindowManagerPolicyConstants#OFF_BECAUSE_OF_USER} or |
| 803 | * {@link WindowManagerPolicyConstants#OFF_BECAUSE_OF_TIMEOUT}. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 804 | */ |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 805 | public void onStartedGoingToSleep(int why) { |
| 806 | if (DEBUG) Log.d(TAG, "onStartedGoingToSleep(" + why + ")"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 807 | synchronized (this) { |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 808 | mDeviceInteractive = false; |
Jorim Jaggi | 4474f54 | 2015-07-09 16:08:02 -0700 | [diff] [blame] | 809 | mGoingToSleep = true; |
John Spurlock | 14adfe4 | 2012-11-08 10:29:26 -0500 | [diff] [blame] | 810 | |
Jim Miller | a4edd15 | 2012-01-06 18:24:04 -0800 | [diff] [blame] | 811 | // Lock immediately based on setting if secure (user has a pin/pattern/password). |
| 812 | // This also "locks" the device when not secure to provide easy access to the |
| 813 | // camera while preventing unwanted input. |
Adrian Roos | d6aa6cb | 2015-04-16 19:31:29 -0700 | [diff] [blame] | 814 | int currentUser = KeyguardUpdateMonitor.getCurrentUser(); |
Jim Miller | a4edd15 | 2012-01-06 18:24:04 -0800 | [diff] [blame] | 815 | final boolean lockImmediately = |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 816 | mLockPatternUtils.getPowerButtonInstantlyLocks(currentUser) |
| 817 | || !mLockPatternUtils.isSecure(currentUser); |
Clara Bayarri | 56878a9 | 2015-10-29 15:43:55 +0000 | [diff] [blame] | 818 | long timeout = getLockTimeout(KeyguardUpdateMonitor.getCurrentUser()); |
Tony Mak | 9c6e8ce | 2016-03-21 12:07:16 +0000 | [diff] [blame] | 819 | mLockLater = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 820 | if (mExitSecureCallback != null) { |
| 821 | if (DEBUG) Log.d(TAG, "pending exit secure callback cancelled"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 822 | try { |
| 823 | mExitSecureCallback.onKeyguardExitResult(false); |
| 824 | } catch (RemoteException e) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 825 | Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 826 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 827 | mExitSecureCallback = null; |
| 828 | if (!mExternallyEnabled) { |
Jim Miller | 9c20d0e | 2010-01-20 15:00:23 -0800 | [diff] [blame] | 829 | hideLocked(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 830 | } |
| 831 | } else if (mShowing) { |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 832 | mPendingReset = true; |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 833 | } else if ((why == WindowManagerPolicyConstants.OFF_BECAUSE_OF_TIMEOUT && timeout > 0) |
| 834 | || (why == WindowManagerPolicyConstants.OFF_BECAUSE_OF_USER && !lockImmediately)) { |
Jorim Jaggi | 5c0c5ac8 | 2015-09-16 14:53:48 -0700 | [diff] [blame] | 835 | doKeyguardLaterLocked(timeout); |
Tony Mak | 9c6e8ce | 2016-03-21 12:07:16 +0000 | [diff] [blame] | 836 | mLockLater = true; |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 837 | } else if (!mLockPatternUtils.isLockScreenDisabled(currentUser)) { |
| 838 | mPendingLock = true; |
| 839 | } |
| 840 | |
Jorim Jaggi | 853cbe3 | 2015-06-04 16:31:54 -0700 | [diff] [blame] | 841 | if (mPendingLock) { |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 842 | playSounds(true); |
| 843 | } |
| 844 | } |
Jorim Jaggi | 95e4038 | 2015-09-16 15:53:42 -0700 | [diff] [blame] | 845 | KeyguardUpdateMonitor.getInstance(mContext).dispatchStartedGoingToSleep(why); |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 846 | notifyStartedGoingToSleep(); |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 847 | } |
| 848 | |
Jorim Jaggi | f1cdf95 | 2016-04-05 21:41:06 -0700 | [diff] [blame] | 849 | public void onFinishedGoingToSleep(int why, boolean cameraGestureTriggered) { |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 850 | if (DEBUG) Log.d(TAG, "onFinishedGoingToSleep(" + why + ")"); |
| 851 | synchronized (this) { |
| 852 | mDeviceInteractive = false; |
Jorim Jaggi | 4474f54 | 2015-07-09 16:08:02 -0700 | [diff] [blame] | 853 | mGoingToSleep = false; |
Adrian Roos | e4cb6c8a | 2017-07-19 18:08:07 +0200 | [diff] [blame] | 854 | mWakeAndUnlocking = false; |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 855 | |
| 856 | resetKeyguardDonePendingLocked(); |
| 857 | mHideAnimationRun = false; |
| 858 | |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 859 | notifyFinishedGoingToSleep(); |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 860 | |
Jorim Jaggi | f1cdf95 | 2016-04-05 21:41:06 -0700 | [diff] [blame] | 861 | if (cameraGestureTriggered) { |
| 862 | Log.i(TAG, "Camera gesture was triggered, preventing Keyguard locking."); |
| 863 | |
| 864 | // Just to make sure, make sure the device is awake. |
| 865 | mContext.getSystemService(PowerManager.class).wakeUp(SystemClock.uptimeMillis(), |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 866 | PowerManager.WAKE_REASON_CAMERA_LAUNCH, |
Jorim Jaggi | f1cdf95 | 2016-04-05 21:41:06 -0700 | [diff] [blame] | 867 | "com.android.systemui:CAMERA_GESTURE_PREVENT_LOCK"); |
| 868 | mPendingLock = false; |
| 869 | mPendingReset = false; |
| 870 | } |
| 871 | |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 872 | if (mPendingReset) { |
| 873 | resetStateLocked(); |
| 874 | mPendingReset = false; |
| 875 | } |
Tony Mak | 9c6e8ce | 2016-03-21 12:07:16 +0000 | [diff] [blame] | 876 | |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 877 | if (mPendingLock) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 878 | doKeyguardLocked(null); |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 879 | mPendingLock = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 880 | } |
Tony Mak | 9c6e8ce | 2016-03-21 12:07:16 +0000 | [diff] [blame] | 881 | |
| 882 | // We do not have timeout and power button instant lock setting for profile lock. |
| 883 | // So we use the personal setting if there is any. But if there is no device |
| 884 | // we need to make sure we lock it immediately when the screen is off. |
Jorim Jaggi | f1cdf95 | 2016-04-05 21:41:06 -0700 | [diff] [blame] | 885 | if (!mLockLater && !cameraGestureTriggered) { |
Tony Mak | 9c6e8ce | 2016-03-21 12:07:16 +0000 | [diff] [blame] | 886 | doKeyguardForChildProfilesLocked(); |
| 887 | } |
| 888 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 889 | } |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 890 | KeyguardUpdateMonitor.getInstance(mContext).dispatchFinishedGoingToSleep(why); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 891 | } |
| 892 | |
Clara Bayarri | 56878a9 | 2015-10-29 15:43:55 +0000 | [diff] [blame] | 893 | private long getLockTimeout(int userId) { |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 894 | // if the screen turned off because of timeout or the user hit the power button |
| 895 | // and we don't need to lock immediately, set an alarm |
| 896 | // to enable it a little bit later (i.e, give the user a chance |
| 897 | // to turn the screen back on within a certain window without |
| 898 | // having to unlock the screen) |
| 899 | final ContentResolver cr = mContext.getContentResolver(); |
| 900 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 901 | // From SecuritySettings |
| 902 | final long lockAfterTimeout = Settings.Secure.getInt(cr, |
| 903 | Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, |
| 904 | KEYGUARD_LOCK_AFTER_DELAY_DEFAULT); |
| 905 | |
| 906 | // From DevicePolicyAdmin |
| 907 | final long policyTimeout = mLockPatternUtils.getDevicePolicyManager() |
Pavel Grafov | 2893998 | 2017-10-03 15:11:52 +0100 | [diff] [blame] | 908 | .getMaximumTimeToLock(null, userId); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 909 | |
| 910 | long timeout; |
Clara Bayarri | 56878a9 | 2015-10-29 15:43:55 +0000 | [diff] [blame] | 911 | |
Clara Bayarri | 3dc575f | 2016-02-17 15:17:14 +0000 | [diff] [blame] | 912 | if (policyTimeout <= 0) { |
Clara Bayarri | 56878a9 | 2015-10-29 15:43:55 +0000 | [diff] [blame] | 913 | timeout = lockAfterTimeout; |
| 914 | } else { |
| 915 | // From DisplaySettings |
| 916 | long displayTimeout = Settings.System.getInt(cr, SCREEN_OFF_TIMEOUT, |
| 917 | KEYGUARD_DISPLAY_TIMEOUT_DELAY_DEFAULT); |
| 918 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 919 | // policy in effect. Make sure we don't go beyond policy limit. |
| 920 | displayTimeout = Math.max(displayTimeout, 0); // ignore negative values |
| 921 | timeout = Math.min(policyTimeout - displayTimeout, lockAfterTimeout); |
Tony Mak | 9c6e8ce | 2016-03-21 12:07:16 +0000 | [diff] [blame] | 922 | timeout = Math.max(timeout, 0); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 923 | } |
Jorim Jaggi | 5c0c5ac8 | 2015-09-16 14:53:48 -0700 | [diff] [blame] | 924 | return timeout; |
| 925 | } |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 926 | |
Jorim Jaggi | 5c0c5ac8 | 2015-09-16 14:53:48 -0700 | [diff] [blame] | 927 | private void doKeyguardLaterLocked() { |
Clara Bayarri | 56878a9 | 2015-10-29 15:43:55 +0000 | [diff] [blame] | 928 | long timeout = getLockTimeout(KeyguardUpdateMonitor.getCurrentUser()); |
Jorim Jaggi | 5c0c5ac8 | 2015-09-16 14:53:48 -0700 | [diff] [blame] | 929 | if (timeout == 0) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 930 | doKeyguardLocked(null); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 931 | } else { |
Jorim Jaggi | 5c0c5ac8 | 2015-09-16 14:53:48 -0700 | [diff] [blame] | 932 | doKeyguardLaterLocked(timeout); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 933 | } |
| 934 | } |
| 935 | |
Jorim Jaggi | 5c0c5ac8 | 2015-09-16 14:53:48 -0700 | [diff] [blame] | 936 | private void doKeyguardLaterLocked(long timeout) { |
| 937 | // Lock in the future |
| 938 | long when = SystemClock.elapsedRealtime() + timeout; |
| 939 | Intent intent = new Intent(DELAYED_KEYGUARD_ACTION); |
| 940 | intent.putExtra("seq", mDelayedShowingSequence); |
Jorim Jaggi | ad0ce3a | 2016-04-27 13:15:41 -0700 | [diff] [blame] | 941 | intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); |
Jorim Jaggi | 5c0c5ac8 | 2015-09-16 14:53:48 -0700 | [diff] [blame] | 942 | PendingIntent sender = PendingIntent.getBroadcast(mContext, |
| 943 | 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); |
Jim Miller | a622d3cc | 2016-03-02 16:02:24 -0800 | [diff] [blame] | 944 | mAlarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, when, sender); |
Jorim Jaggi | 5c0c5ac8 | 2015-09-16 14:53:48 -0700 | [diff] [blame] | 945 | if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = " |
| 946 | + mDelayedShowingSequence); |
Clara Bayarri | 3dc575f | 2016-02-17 15:17:14 +0000 | [diff] [blame] | 947 | doKeyguardLaterForChildProfilesLocked(); |
Clara Bayarri | 56878a9 | 2015-10-29 15:43:55 +0000 | [diff] [blame] | 948 | } |
Clara Bayarri | 10ad84a | 2015-12-01 17:38:05 +0000 | [diff] [blame] | 949 | |
Clara Bayarri | 3dc575f | 2016-02-17 15:17:14 +0000 | [diff] [blame] | 950 | private void doKeyguardLaterForChildProfilesLocked() { |
Clara Bayarri | 56878a9 | 2015-10-29 15:43:55 +0000 | [diff] [blame] | 951 | UserManager um = UserManager.get(mContext); |
Fyodor Kupolov | 7f98aa4 | 2016-04-07 14:56:25 -0700 | [diff] [blame] | 952 | for (int profileId : um.getEnabledProfileIds(UserHandle.myUserId())) { |
| 953 | if (mLockPatternUtils.isSeparateProfileChallengeEnabled(profileId)) { |
| 954 | long userTimeout = getLockTimeout(profileId); |
Tony Mak | 9c6e8ce | 2016-03-21 12:07:16 +0000 | [diff] [blame] | 955 | if (userTimeout == 0) { |
| 956 | doKeyguardForChildProfilesLocked(); |
| 957 | } else { |
| 958 | long userWhen = SystemClock.elapsedRealtime() + userTimeout; |
| 959 | Intent lockIntent = new Intent(DELAYED_LOCK_PROFILE_ACTION); |
| 960 | lockIntent.putExtra("seq", mDelayedProfileShowingSequence); |
Fyodor Kupolov | 7f98aa4 | 2016-04-07 14:56:25 -0700 | [diff] [blame] | 961 | lockIntent.putExtra(Intent.EXTRA_USER_ID, profileId); |
Jorim Jaggi | ad0ce3a | 2016-04-27 13:15:41 -0700 | [diff] [blame] | 962 | lockIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); |
Tony Mak | 9c6e8ce | 2016-03-21 12:07:16 +0000 | [diff] [blame] | 963 | PendingIntent lockSender = PendingIntent.getBroadcast( |
| 964 | mContext, 0, lockIntent, PendingIntent.FLAG_CANCEL_CURRENT); |
| 965 | mAlarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, |
| 966 | userWhen, lockSender); |
| 967 | } |
Clara Bayarri | 3dc575f | 2016-02-17 15:17:14 +0000 | [diff] [blame] | 968 | } |
| 969 | } |
| 970 | } |
| 971 | |
| 972 | private void doKeyguardForChildProfilesLocked() { |
| 973 | UserManager um = UserManager.get(mContext); |
Fyodor Kupolov | 7f98aa4 | 2016-04-07 14:56:25 -0700 | [diff] [blame] | 974 | for (int profileId : um.getEnabledProfileIds(UserHandle.myUserId())) { |
| 975 | if (mLockPatternUtils.isSeparateProfileChallengeEnabled(profileId)) { |
| 976 | lockProfile(profileId); |
Clara Bayarri | 56878a9 | 2015-10-29 15:43:55 +0000 | [diff] [blame] | 977 | } |
| 978 | } |
Jorim Jaggi | 5c0c5ac8 | 2015-09-16 14:53:48 -0700 | [diff] [blame] | 979 | } |
| 980 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 981 | private void cancelDoKeyguardLaterLocked() { |
| 982 | mDelayedShowingSequence++; |
| 983 | } |
| 984 | |
Tony Mak | 9c6e8ce | 2016-03-21 12:07:16 +0000 | [diff] [blame] | 985 | private void cancelDoKeyguardForChildProfilesLocked() { |
| 986 | mDelayedProfileShowingSequence++; |
| 987 | } |
| 988 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 989 | /** |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 990 | * Let's us know when the device is waking up. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 991 | */ |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 992 | public void onStartedWakingUp() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 993 | Trace.beginSection("KeyguardViewMediator#onStartedWakingUp"); |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 994 | |
| 995 | // TODO: Rename all screen off/on references to interactive/sleeping |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 996 | synchronized (this) { |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 997 | mDeviceInteractive = true; |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 998 | cancelDoKeyguardLaterLocked(); |
Tony Mak | 9c6e8ce | 2016-03-21 12:07:16 +0000 | [diff] [blame] | 999 | cancelDoKeyguardForChildProfilesLocked(); |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 1000 | if (DEBUG) Log.d(TAG, "onStartedWakingUp, seq = " + mDelayedShowingSequence); |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 1001 | notifyStartedWakingUp(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1002 | } |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 1003 | KeyguardUpdateMonitor.getInstance(mContext).dispatchStartedWakingUp(); |
Jim Miller | 3fd47af | 2012-09-21 19:55:27 -0700 | [diff] [blame] | 1004 | maybeSendUserPresentBroadcast(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1005 | Trace.endSection(); |
Jim Miller | 3fd47af | 2012-09-21 19:55:27 -0700 | [diff] [blame] | 1006 | } |
| 1007 | |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 1008 | public void onScreenTurningOn(IKeyguardDrawnCallback callback) { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1009 | Trace.beginSection("KeyguardViewMediator#onScreenTurningOn"); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 1010 | notifyScreenOn(callback); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1011 | Trace.endSection(); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 1012 | } |
| 1013 | |
| 1014 | public void onScreenTurnedOn() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1015 | Trace.beginSection("KeyguardViewMediator#onScreenTurnedOn"); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 1016 | notifyScreenTurnedOn(); |
| 1017 | mUpdateMonitor.dispatchScreenTurnedOn(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1018 | Trace.endSection(); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 1019 | } |
| 1020 | |
| 1021 | public void onScreenTurnedOff() { |
| 1022 | notifyScreenTurnedOff(); |
| 1023 | mUpdateMonitor.dispatchScreenTurnedOff(); |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 1024 | } |
| 1025 | |
Jim Miller | 3fd47af | 2012-09-21 19:55:27 -0700 | [diff] [blame] | 1026 | private void maybeSendUserPresentBroadcast() { |
Adrian Roos | 8150d2a | 2015-04-16 17:11:20 -0700 | [diff] [blame] | 1027 | if (mSystemReady && mLockPatternUtils.isLockScreenDisabled( |
Adrian Roos | d6aa6cb | 2015-04-16 19:31:29 -0700 | [diff] [blame] | 1028 | KeyguardUpdateMonitor.getCurrentUser())) { |
Jim Miller | 3fd47af | 2012-09-21 19:55:27 -0700 | [diff] [blame] | 1029 | // Lock screen is disabled because the user has set the preference to "None". |
| 1030 | // In this case, send out ACTION_USER_PRESENT here instead of in |
| 1031 | // handleKeyguardDone() |
| 1032 | sendUserPresentBroadcast(); |
Adrian Roos | fb95a81 | 2016-06-20 14:58:59 -0700 | [diff] [blame] | 1033 | } else if (mSystemReady && shouldWaitForProvisioning()) { |
| 1034 | // Skipping the lockscreen because we're not yet provisioned, but we still need to |
| 1035 | // notify the StrongAuthTracker that it's now safe to run trust agents, in case the |
| 1036 | // user sets a credential later. |
| 1037 | getLockPatternUtils().userPresent(KeyguardUpdateMonitor.getCurrentUser()); |
Jim Miller | 3fd47af | 2012-09-21 19:55:27 -0700 | [diff] [blame] | 1038 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1039 | } |
| 1040 | |
| 1041 | /** |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 1042 | * A dream started. We should lock after the usual screen-off lock timeout but only |
| 1043 | * if there is a secure lock pattern. |
| 1044 | */ |
| 1045 | public void onDreamingStarted() { |
Selim Cinek | 9941539 | 2016-09-09 14:58:41 -0700 | [diff] [blame] | 1046 | KeyguardUpdateMonitor.getInstance(mContext).dispatchDreamingStarted(); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 1047 | synchronized (this) { |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 1048 | if (mDeviceInteractive |
| 1049 | && mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser())) { |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 1050 | doKeyguardLaterLocked(); |
| 1051 | } |
| 1052 | } |
| 1053 | } |
| 1054 | |
| 1055 | /** |
| 1056 | * A dream stopped. |
| 1057 | */ |
| 1058 | public void onDreamingStopped() { |
Selim Cinek | 9941539 | 2016-09-09 14:58:41 -0700 | [diff] [blame] | 1059 | KeyguardUpdateMonitor.getInstance(mContext).dispatchDreamingStopped(); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 1060 | synchronized (this) { |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 1061 | if (mDeviceInteractive) { |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 1062 | cancelDoKeyguardLaterLocked(); |
| 1063 | } |
| 1064 | } |
| 1065 | } |
| 1066 | |
| 1067 | /** |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 1068 | * Same semantics as {@link WindowManagerPolicyConstants#enableKeyguard}; provide |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1069 | * a way for external stuff to override normal keyguard behavior. For instance |
| 1070 | * the phone app disables the keyguard when it receives incoming calls. |
| 1071 | */ |
| 1072 | public void setKeyguardEnabled(boolean enabled) { |
| 1073 | synchronized (this) { |
| 1074 | if (DEBUG) Log.d(TAG, "setKeyguardEnabled(" + enabled + ")"); |
| 1075 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1076 | mExternallyEnabled = enabled; |
| 1077 | |
| 1078 | if (!enabled && mShowing) { |
| 1079 | if (mExitSecureCallback != null) { |
| 1080 | if (DEBUG) Log.d(TAG, "in process of verifyUnlock request, ignoring"); |
| 1081 | // we're in the process of handling a request to verify the user |
| 1082 | // can get past the keyguard. ignore extraneous requests to disable / reenable |
| 1083 | return; |
| 1084 | } |
| 1085 | |
| 1086 | // hiding keyguard that is showing, remember to reshow later |
| 1087 | if (DEBUG) Log.d(TAG, "remembering to reshow, hiding keyguard, " |
| 1088 | + "disabling status bar expansion"); |
| 1089 | mNeedToReshowWhenReenabled = true; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 1090 | updateInputRestrictedLocked(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1091 | hideLocked(); |
| 1092 | } else if (enabled && mNeedToReshowWhenReenabled) { |
| 1093 | // reenabled after previously hidden, reshow |
| 1094 | if (DEBUG) Log.d(TAG, "previously hidden, reshowing, reenabling " |
| 1095 | + "status bar expansion"); |
| 1096 | mNeedToReshowWhenReenabled = false; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 1097 | updateInputRestrictedLocked(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1098 | |
| 1099 | if (mExitSecureCallback != null) { |
| 1100 | if (DEBUG) Log.d(TAG, "onKeyguardExitResult(false), resetting"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1101 | try { |
| 1102 | mExitSecureCallback.onKeyguardExitResult(false); |
| 1103 | } catch (RemoteException e) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 1104 | Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1105 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1106 | mExitSecureCallback = null; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1107 | resetStateLocked(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1108 | } else { |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 1109 | showLocked(null); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1110 | |
| 1111 | // block until we know the keygaurd is done drawing (and post a message |
| 1112 | // to unblock us after a timeout so we don't risk blocking too long |
| 1113 | // and causing an ANR). |
| 1114 | mWaitingUntilKeyguardVisible = true; |
| 1115 | mHandler.sendEmptyMessageDelayed(KEYGUARD_DONE_DRAWING, KEYGUARD_DONE_DRAWING_TIMEOUT_MS); |
| 1116 | if (DEBUG) Log.d(TAG, "waiting until mWaitingUntilKeyguardVisible is false"); |
| 1117 | while (mWaitingUntilKeyguardVisible) { |
| 1118 | try { |
| 1119 | wait(); |
| 1120 | } catch (InterruptedException e) { |
| 1121 | Thread.currentThread().interrupt(); |
| 1122 | } |
| 1123 | } |
| 1124 | if (DEBUG) Log.d(TAG, "done waiting for mWaitingUntilKeyguardVisible"); |
| 1125 | } |
| 1126 | } |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | /** |
| 1131 | * @see android.app.KeyguardManager#exitKeyguardSecurely |
| 1132 | */ |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 1133 | public void verifyUnlock(IKeyguardExitCallback callback) { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1134 | Trace.beginSection("KeyguardViewMediator#verifyUnlock"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1135 | synchronized (this) { |
| 1136 | if (DEBUG) Log.d(TAG, "verifyUnlock"); |
Jim Miller | b256e4e2 | 2014-10-31 17:27:13 -0700 | [diff] [blame] | 1137 | if (shouldWaitForProvisioning()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1138 | // don't allow this api when the device isn't provisioned |
| 1139 | if (DEBUG) Log.d(TAG, "ignoring because device isn't provisioned"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1140 | try { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 1141 | callback.onKeyguardExitResult(false); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1142 | } catch (RemoteException e) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 1143 | Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1144 | } |
Mike Lockwood | 5d258b6 | 2009-12-02 13:50:45 -0500 | [diff] [blame] | 1145 | } else if (mExternallyEnabled) { |
| 1146 | // this only applies when the user has externally disabled the |
| 1147 | // keyguard. this is unexpected and means the user is not |
| 1148 | // using the api properly. |
| 1149 | Log.w(TAG, "verifyUnlock called when not externally disabled"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1150 | try { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 1151 | callback.onKeyguardExitResult(false); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1152 | } catch (RemoteException e) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 1153 | Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1154 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1155 | } else if (mExitSecureCallback != null) { |
| 1156 | // already in progress with someone else |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1157 | try { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 1158 | callback.onKeyguardExitResult(false); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1159 | } catch (RemoteException e) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 1160 | Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1161 | } |
Jorim Jaggi | 302475e | 2015-09-22 12:44:47 -0700 | [diff] [blame] | 1162 | } else if (!isSecure()) { |
| 1163 | |
| 1164 | // Keyguard is not secure, no need to do anything, and we don't need to reshow |
| 1165 | // the Keyguard after the client releases the Keyguard lock. |
| 1166 | mExternallyEnabled = true; |
| 1167 | mNeedToReshowWhenReenabled = false; |
| 1168 | updateInputRestricted(); |
| 1169 | try { |
| 1170 | callback.onKeyguardExitResult(true); |
| 1171 | } catch (RemoteException e) { |
| 1172 | Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); |
| 1173 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1174 | } else { |
Jorim Jaggi | 302475e | 2015-09-22 12:44:47 -0700 | [diff] [blame] | 1175 | |
| 1176 | // Since we prevent apps from hiding the Keyguard if we are secure, this should be |
| 1177 | // a no-op as well. |
| 1178 | try { |
| 1179 | callback.onKeyguardExitResult(false); |
| 1180 | } catch (RemoteException e) { |
| 1181 | Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); |
| 1182 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1183 | } |
| 1184 | } |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1185 | Trace.endSection(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1186 | } |
| 1187 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1188 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1189 | * Is the keyguard currently showing and not being force hidden? |
Mike Lockwood | 09a4040 | 2009-11-08 00:33:23 -0500 | [diff] [blame] | 1190 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1191 | public boolean isShowingAndNotOccluded() { |
| 1192 | return mShowing && !mOccluded; |
| 1193 | } |
| 1194 | |
| 1195 | /** |
| 1196 | * Notify us when the keyguard is occluded by another window |
| 1197 | */ |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 1198 | public void setOccluded(boolean isOccluded, boolean animate) { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1199 | Trace.beginSection("KeyguardViewMediator#setOccluded"); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1200 | if (DEBUG) Log.d(TAG, "setOccluded " + isOccluded); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1201 | mHandler.removeMessages(SET_OCCLUDED); |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 1202 | Message msg = mHandler.obtainMessage(SET_OCCLUDED, isOccluded ? 1 : 0, animate ? 1 : 0); |
Mike Lockwood | 9200a39 | 2009-11-17 20:25:58 -0500 | [diff] [blame] | 1203 | mHandler.sendMessage(msg); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1204 | Trace.endSection(); |
Mike Lockwood | 9200a39 | 2009-11-17 20:25:58 -0500 | [diff] [blame] | 1205 | } |
| 1206 | |
Lucas Dupin | 2986c15 | 2018-04-09 20:49:41 -0700 | [diff] [blame] | 1207 | public boolean isHiding() { |
| 1208 | return mHiding; |
| 1209 | } |
| 1210 | |
Mike Lockwood | 9200a39 | 2009-11-17 20:25:58 -0500 | [diff] [blame] | 1211 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1212 | * Handles SET_OCCLUDED message sent by setOccluded() |
Mike Lockwood | 9200a39 | 2009-11-17 20:25:58 -0500 | [diff] [blame] | 1213 | */ |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 1214 | private void handleSetOccluded(boolean isOccluded, boolean animate) { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1215 | Trace.beginSection("KeyguardViewMediator#handleSetOccluded"); |
Mike Lockwood | 09a4040 | 2009-11-08 00:33:23 -0500 | [diff] [blame] | 1216 | synchronized (KeyguardViewMediator.this) { |
Adrian Roos | f253eeb | 2015-04-15 18:03:08 -0700 | [diff] [blame] | 1217 | if (mHiding && isOccluded) { |
| 1218 | // We're in the process of going away but WindowManager wants to show a |
| 1219 | // SHOW_WHEN_LOCKED activity instead. |
| 1220 | startKeyguardExitAnimation(0, 0); |
| 1221 | } |
| 1222 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1223 | if (mOccluded != isOccluded) { |
| 1224 | mOccluded = isOccluded; |
Kevin Chyn | 2fefd46 | 2017-04-28 12:18:19 -0700 | [diff] [blame] | 1225 | mUpdateMonitor.setKeyguardOccluded(isOccluded); |
Selim Cinek | 2f6272e | 2017-03-15 16:19:10 -0700 | [diff] [blame] | 1226 | mStatusBarKeyguardViewManager.setOccluded(isOccluded, animate |
| 1227 | && mDeviceInteractive); |
Mike Lockwood | 5f892c1 | 2009-11-19 23:39:13 -0500 | [diff] [blame] | 1228 | adjustStatusBarLocked(); |
Mike Lockwood | 9200a39 | 2009-11-17 20:25:58 -0500 | [diff] [blame] | 1229 | } |
Mike Lockwood | 09a4040 | 2009-11-08 00:33:23 -0500 | [diff] [blame] | 1230 | } |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1231 | Trace.endSection(); |
Mike Lockwood | 09a4040 | 2009-11-08 00:33:23 -0500 | [diff] [blame] | 1232 | } |
| 1233 | |
| 1234 | /** |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 1235 | * Used by PhoneWindowManager to enable the keyguard due to a user activity timeout. |
| 1236 | * This must be safe to call from any thread and with any window manager locks held. |
| 1237 | */ |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 1238 | public void doKeyguardTimeout(Bundle options) { |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 1239 | mHandler.removeMessages(KEYGUARD_TIMEOUT); |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 1240 | Message msg = mHandler.obtainMessage(KEYGUARD_TIMEOUT, options); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 1241 | mHandler.sendMessage(msg); |
| 1242 | } |
| 1243 | |
| 1244 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1245 | * Given the state of the keyguard, is the input restricted? |
| 1246 | * Input is restricted when the keyguard is showing, or when the keyguard |
| 1247 | * was suppressed by an app that disabled the keyguard or we haven't been provisioned yet. |
| 1248 | */ |
| 1249 | public boolean isInputRestricted() { |
Adrian Roos | 9f33d6c | 2015-06-15 15:58:35 -0700 | [diff] [blame] | 1250 | return mShowing || mNeedToReshowWhenReenabled; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1251 | } |
| 1252 | |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 1253 | private void updateInputRestricted() { |
| 1254 | synchronized (this) { |
| 1255 | updateInputRestrictedLocked(); |
| 1256 | } |
| 1257 | } |
Jorim Jaggi | e549a8d | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 1258 | |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 1259 | private void updateInputRestrictedLocked() { |
| 1260 | boolean inputRestricted = isInputRestricted(); |
| 1261 | if (mInputRestricted != inputRestricted) { |
| 1262 | mInputRestricted = inputRestricted; |
dooyoung.hwang | 328472e | 2015-05-21 16:09:43 +0900 | [diff] [blame] | 1263 | int size = mKeyguardStateCallbacks.size(); |
| 1264 | for (int i = size - 1; i >= 0; i--) { |
Jorim Jaggi | e549a8d | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 1265 | final IKeyguardStateCallback callback = mKeyguardStateCallbacks.get(i); |
dooyoung.hwang | 328472e | 2015-05-21 16:09:43 +0900 | [diff] [blame] | 1266 | try { |
Jorim Jaggi | e549a8d | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 1267 | callback.onInputRestrictedStateChanged(inputRestricted); |
dooyoung.hwang | 328472e | 2015-05-21 16:09:43 +0900 | [diff] [blame] | 1268 | } catch (RemoteException e) { |
| 1269 | Slog.w(TAG, "Failed to call onDeviceProvisioned", e); |
| 1270 | if (e instanceof DeadObjectException) { |
Jorim Jaggi | e549a8d | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 1271 | mKeyguardStateCallbacks.remove(callback); |
dooyoung.hwang | 328472e | 2015-05-21 16:09:43 +0900 | [diff] [blame] | 1272 | } |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 1273 | } |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 1274 | } |
| 1275 | } |
| 1276 | } |
| 1277 | |
Dianne Hackborn | b446e97 | 2009-09-20 15:23:25 -0700 | [diff] [blame] | 1278 | /** |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 1279 | * Enable the keyguard if the settings are appropriate. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1280 | */ |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 1281 | private void doKeyguardLocked(Bundle options) { |
Adrian Roos | ca8a216 | 2017-08-17 19:00:58 +0200 | [diff] [blame] | 1282 | if (KeyguardUpdateMonitor.CORE_APPS_ONLY) { |
| 1283 | // Don't show keyguard during half-booted cryptkeeper stage. |
| 1284 | if (DEBUG) Log.d(TAG, "doKeyguard: not showing because booting to cryptkeeper"); |
| 1285 | return; |
| 1286 | } |
| 1287 | |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 1288 | // if another app is disabling us, don't show |
| 1289 | if (!mExternallyEnabled) { |
| 1290 | if (DEBUG) Log.d(TAG, "doKeyguard: not showing because externally disabled"); |
Karl Rosaen | ab10008 | 2009-03-24 22:35:17 -0700 | [diff] [blame] | 1291 | |
Adrian Roos | 1c8e3c0 | 2018-11-20 20:07:55 +0100 | [diff] [blame] | 1292 | mNeedToReshowWhenReenabled = true; |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 1293 | return; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1294 | } |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 1295 | |
| 1296 | // if the keyguard is already showing, don't bother |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1297 | if (mStatusBarKeyguardViewManager.isShowing()) { |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 1298 | if (DEBUG) Log.d(TAG, "doKeyguard: not showing because it is already showing"); |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 1299 | resetStateLocked(); |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 1300 | return; |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 1301 | } |
| 1302 | |
Xiaohui Chen | f561d7f | 2015-07-09 16:35:00 -0700 | [diff] [blame] | 1303 | // In split system user mode, we never unlock system user. |
Amith Yamasani | eb437d4 | 2016-04-29 09:31:25 -0700 | [diff] [blame] | 1304 | if (!mustNotUnlockCurrentUser() |
Amith Yamasani | 27e025b | 2015-11-06 10:34:41 -0800 | [diff] [blame] | 1305 | || !mUpdateMonitor.isDeviceProvisioned()) { |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 1306 | |
Xiaohui Chen | f561d7f | 2015-07-09 16:35:00 -0700 | [diff] [blame] | 1307 | // if the setup wizard hasn't run yet, don't show |
| 1308 | final boolean requireSim = !SystemProperties.getBoolean("keyguard.no_require_sim", false); |
| 1309 | final boolean absent = SubscriptionManager.isValidSubscriptionId( |
Adrian Roos | e92de95 | 2016-12-13 12:07:09 -0800 | [diff] [blame] | 1310 | mUpdateMonitor.getNextSubIdForState(ABSENT)); |
Xiaohui Chen | f561d7f | 2015-07-09 16:35:00 -0700 | [diff] [blame] | 1311 | final boolean disabled = SubscriptionManager.isValidSubscriptionId( |
| 1312 | mUpdateMonitor.getNextSubIdForState(IccCardConstants.State.PERM_DISABLED)); |
| 1313 | final boolean lockedOrMissing = mUpdateMonitor.isSimPinSecure() |
| 1314 | || ((absent || disabled) && requireSim); |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 1315 | |
Xiaohui Chen | f561d7f | 2015-07-09 16:35:00 -0700 | [diff] [blame] | 1316 | if (!lockedOrMissing && shouldWaitForProvisioning()) { |
| 1317 | if (DEBUG) Log.d(TAG, "doKeyguard: not showing because device isn't provisioned" |
| 1318 | + " and the sim is not locked or missing"); |
| 1319 | return; |
| 1320 | } |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 1321 | |
Evan Rosky | 13a58a9 | 2016-07-27 15:51:09 -0700 | [diff] [blame] | 1322 | boolean forceShow = options != null && options.getBoolean(OPTION_FORCE_SHOW, false); |
Xiaohui Chen | f561d7f | 2015-07-09 16:35:00 -0700 | [diff] [blame] | 1323 | if (mLockPatternUtils.isLockScreenDisabled(KeyguardUpdateMonitor.getCurrentUser()) |
Evan Rosky | 13a58a9 | 2016-07-27 15:51:09 -0700 | [diff] [blame] | 1324 | && !lockedOrMissing && !forceShow) { |
Xiaohui Chen | f561d7f | 2015-07-09 16:35:00 -0700 | [diff] [blame] | 1325 | if (DEBUG) Log.d(TAG, "doKeyguard: not showing because lockscreen is off"); |
| 1326 | return; |
| 1327 | } |
| 1328 | |
| 1329 | if (mLockPatternUtils.checkVoldPassword(KeyguardUpdateMonitor.getCurrentUser())) { |
| 1330 | if (DEBUG) Log.d(TAG, "Not showing lock screen since just decrypted"); |
| 1331 | // Without this, settings is not enabled until the lock screen first appears |
Lucas Dupin | b3455e6 | 2019-07-11 11:47:13 +0900 | [diff] [blame] | 1332 | setShowingLocked(false); |
Xiaohui Chen | f561d7f | 2015-07-09 16:35:00 -0700 | [diff] [blame] | 1333 | hideLocked(); |
| 1334 | return; |
| 1335 | } |
Paul Lawrence | 945490c | 2014-03-27 16:37:28 +0000 | [diff] [blame] | 1336 | } |
| 1337 | |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 1338 | if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen"); |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 1339 | showLocked(options); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1340 | } |
| 1341 | |
Clara Bayarri | 56878a9 | 2015-10-29 15:43:55 +0000 | [diff] [blame] | 1342 | private void lockProfile(int userId) { |
| 1343 | mTrustManager.setDeviceLockedForUser(userId, true); |
| 1344 | } |
| 1345 | |
Jim Miller | b256e4e2 | 2014-10-31 17:27:13 -0700 | [diff] [blame] | 1346 | private boolean shouldWaitForProvisioning() { |
| 1347 | return !mUpdateMonitor.isDeviceProvisioned() && !isSecure(); |
| 1348 | } |
| 1349 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1350 | /** |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 1351 | * Dismiss the keyguard through the security layers. |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1352 | * @param callback Callback to be informed about the result |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 1353 | * @param message Message that should be displayed on the bouncer. |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 1354 | */ |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 1355 | private void handleDismiss(IKeyguardDismissCallback callback, CharSequence message) { |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1356 | if (mShowing) { |
| 1357 | if (callback != null) { |
| 1358 | mDismissCallbackRegistry.addCallback(callback); |
| 1359 | } |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 1360 | mCustomMessage = message; |
Jorim Jaggi | 8d5a6e7 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1361 | mStatusBarKeyguardViewManager.dismissAndCollapse(); |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1362 | } else if (callback != null) { |
| 1363 | new DismissCallbackWrapper(callback).notifyDismissError(); |
Jim Miller | 87d0366 | 2012-11-05 20:28:09 -0800 | [diff] [blame] | 1364 | } |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 1365 | } |
| 1366 | |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 1367 | public void dismiss(IKeyguardDismissCallback callback, CharSequence message) { |
| 1368 | mHandler.obtainMessage(DISMISS, new DismissMessage(callback, message)).sendToTarget(); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1369 | } |
| 1370 | |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 1371 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1372 | * Send message to keyguard telling it to reset its state. |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1373 | * @see #handleReset |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1374 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1375 | private void resetStateLocked() { |
Jim Miller | 4894a01 | 2013-04-03 15:23:55 -0700 | [diff] [blame] | 1376 | if (DEBUG) Log.e(TAG, "resetStateLocked"); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1377 | Message msg = mHandler.obtainMessage(RESET); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1378 | mHandler.sendMessage(msg); |
| 1379 | } |
| 1380 | |
| 1381 | /** |
| 1382 | * Send message to keyguard telling it to verify unlock |
| 1383 | * @see #handleVerifyUnlock() |
| 1384 | */ |
| 1385 | private void verifyUnlockLocked() { |
| 1386 | if (DEBUG) Log.d(TAG, "verifyUnlockLocked"); |
| 1387 | mHandler.sendEmptyMessage(VERIFY_UNLOCK); |
| 1388 | } |
| 1389 | |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 1390 | private void notifyStartedGoingToSleep() { |
| 1391 | if (DEBUG) Log.d(TAG, "notifyStartedGoingToSleep"); |
| 1392 | mHandler.sendEmptyMessage(NOTIFY_STARTED_GOING_TO_SLEEP); |
| 1393 | } |
| 1394 | |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 1395 | private void notifyFinishedGoingToSleep() { |
| 1396 | if (DEBUG) Log.d(TAG, "notifyFinishedGoingToSleep"); |
| 1397 | mHandler.sendEmptyMessage(NOTIFY_FINISHED_GOING_TO_SLEEP); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1398 | } |
| 1399 | |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 1400 | private void notifyStartedWakingUp() { |
| 1401 | if (DEBUG) Log.d(TAG, "notifyStartedWakingUp"); |
| 1402 | mHandler.sendEmptyMessage(NOTIFY_STARTED_WAKING_UP); |
| 1403 | } |
| 1404 | |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 1405 | private void notifyScreenOn(IKeyguardDrawnCallback callback) { |
| 1406 | if (DEBUG) Log.d(TAG, "notifyScreenOn"); |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 1407 | Message msg = mHandler.obtainMessage(NOTIFY_SCREEN_TURNING_ON, callback); |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 1408 | mHandler.sendMessage(msg); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1409 | } |
| 1410 | |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 1411 | private void notifyScreenTurnedOn() { |
| 1412 | if (DEBUG) Log.d(TAG, "notifyScreenTurnedOn"); |
| 1413 | Message msg = mHandler.obtainMessage(NOTIFY_SCREEN_TURNED_ON); |
| 1414 | mHandler.sendMessage(msg); |
| 1415 | } |
| 1416 | |
| 1417 | private void notifyScreenTurnedOff() { |
| 1418 | if (DEBUG) Log.d(TAG, "notifyScreenTurnedOff"); |
| 1419 | Message msg = mHandler.obtainMessage(NOTIFY_SCREEN_TURNED_OFF); |
| 1420 | mHandler.sendMessage(msg); |
| 1421 | } |
| 1422 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1423 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1424 | * Send message to keyguard telling it to show itself |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1425 | * @see #handleShow |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1426 | */ |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 1427 | private void showLocked(Bundle options) { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1428 | Trace.beginSection("KeyguardViewMediator#showLocked aqcuiring mShowKeyguardWakeLock"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1429 | if (DEBUG) Log.d(TAG, "showLocked"); |
Mike Lockwood | 674d3e4 | 2009-10-06 09:28:54 -0400 | [diff] [blame] | 1430 | // ensure we stay awake until we are finished displaying the keyguard |
| 1431 | mShowKeyguardWakeLock.acquire(); |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 1432 | Message msg = mHandler.obtainMessage(SHOW, options); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1433 | mHandler.sendMessage(msg); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1434 | Trace.endSection(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1435 | } |
| 1436 | |
| 1437 | /** |
| 1438 | * Send message to keyguard telling it to hide itself |
Jim Miller | 9c20d0e | 2010-01-20 15:00:23 -0800 | [diff] [blame] | 1439 | * @see #handleHide() |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1440 | */ |
| 1441 | private void hideLocked() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1442 | Trace.beginSection("KeyguardViewMediator#hideLocked"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1443 | if (DEBUG) Log.d(TAG, "hideLocked"); |
| 1444 | Message msg = mHandler.obtainMessage(HIDE); |
| 1445 | mHandler.sendMessage(msg); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1446 | Trace.endSection(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1447 | } |
| 1448 | |
Dianne Hackborn | b446e97 | 2009-09-20 15:23:25 -0700 | [diff] [blame] | 1449 | public boolean isSecure() { |
Evan Rosky | 13a58a9 | 2016-07-27 15:51:09 -0700 | [diff] [blame] | 1450 | return isSecure(KeyguardUpdateMonitor.getCurrentUser()); |
| 1451 | } |
| 1452 | |
| 1453 | public boolean isSecure(int userId) { |
| 1454 | return mLockPatternUtils.isSecure(userId) |
| 1455 | || KeyguardUpdateMonitor.getInstance(mContext).isSimPinSecure(); |
Dianne Hackborn | b446e97 | 2009-09-20 15:23:25 -0700 | [diff] [blame] | 1456 | } |
Jim Miller | 9c20d0e | 2010-01-20 15:00:23 -0800 | [diff] [blame] | 1457 | |
Evan Rosky | 1839645 | 2016-07-27 15:19:37 -0700 | [diff] [blame] | 1458 | public void setSwitchingUser(boolean switching) { |
Selim Cinek | bbe1924 | 2017-12-08 15:42:08 -0800 | [diff] [blame] | 1459 | KeyguardUpdateMonitor.getInstance(mContext).setSwitchingUser(switching); |
Evan Rosky | 1839645 | 2016-07-27 15:19:37 -0700 | [diff] [blame] | 1460 | } |
| 1461 | |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 1462 | /** |
| 1463 | * Update the newUserId. Call while holding WindowManagerService lock. |
Jim Miller | ee82f8f | 2012-10-01 16:26:18 -0700 | [diff] [blame] | 1464 | * NOTE: Should only be called by KeyguardViewMediator in response to the user id changing. |
| 1465 | * |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 1466 | * @param newUserId The id of the incoming user. |
| 1467 | */ |
| 1468 | public void setCurrentUser(int newUserId) { |
Adrian Roos | d6aa6cb | 2015-04-16 19:31:29 -0700 | [diff] [blame] | 1469 | KeyguardUpdateMonitor.setCurrentUser(newUserId); |
Adrian Roos | d88eb26 | 2016-08-04 14:50:48 -0700 | [diff] [blame] | 1470 | synchronized (this) { |
| 1471 | notifyTrustedChangedLocked(mUpdateMonitor.getUserHasTrust(newUserId)); |
| 1472 | } |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 1473 | } |
| 1474 | |
Kevin Chyn | 18e91aa | 2018-04-11 12:55:45 -0700 | [diff] [blame] | 1475 | /** |
| 1476 | * This broadcast receiver should be registered with the SystemUI permission. |
| 1477 | */ |
| 1478 | private final BroadcastReceiver mDelayedLockBroadcastReceiver = new BroadcastReceiver() { |
Amith Yamasani | 52c489c | 2012-03-28 11:42:42 -0700 | [diff] [blame] | 1479 | @Override |
| 1480 | public void onReceive(Context context, Intent intent) { |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 1481 | if (DELAYED_KEYGUARD_ACTION.equals(intent.getAction())) { |
| 1482 | final int sequence = intent.getIntExtra("seq", 0); |
Jim Miller | f344735 | 2011-08-07 14:00:09 -0700 | [diff] [blame] | 1483 | if (DEBUG) Log.d(TAG, "received DELAYED_KEYGUARD_ACTION with seq = " |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1484 | + sequence + ", mDelayedShowingSequence = " + mDelayedShowingSequence); |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 1485 | synchronized (KeyguardViewMediator.this) { |
Jim Miller | 2967f48 | 2016-01-07 15:05:32 -0800 | [diff] [blame] | 1486 | if (mDelayedShowingSequence == sequence) { |
| 1487 | doKeyguardLocked(null); |
| 1488 | } |
Clara Bayarri | 56878a9 | 2015-10-29 15:43:55 +0000 | [diff] [blame] | 1489 | } |
| 1490 | } else if (DELAYED_LOCK_PROFILE_ACTION.equals(intent.getAction())) { |
Tony Mak | 9c6e8ce | 2016-03-21 12:07:16 +0000 | [diff] [blame] | 1491 | final int sequence = intent.getIntExtra("seq", 0); |
Clara Bayarri | 56878a9 | 2015-10-29 15:43:55 +0000 | [diff] [blame] | 1492 | int userId = intent.getIntExtra(Intent.EXTRA_USER_ID, 0); |
| 1493 | if (userId != 0) { |
| 1494 | synchronized (KeyguardViewMediator.this) { |
Tony Mak | 9c6e8ce | 2016-03-21 12:07:16 +0000 | [diff] [blame] | 1495 | if (mDelayedProfileShowingSequence == sequence) { |
| 1496 | lockProfile(userId); |
| 1497 | } |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 1498 | } |
Daniel Sandler | f2d8e74 | 2010-02-22 13:09:48 -0500 | [diff] [blame] | 1499 | } |
Kevin Chyn | 18e91aa | 2018-04-11 12:55:45 -0700 | [diff] [blame] | 1500 | } |
| 1501 | } |
| 1502 | }; |
| 1503 | |
| 1504 | private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
| 1505 | @Override |
| 1506 | public void onReceive(Context context, Intent intent) { |
| 1507 | if (Intent.ACTION_SHUTDOWN.equals(intent.getAction())) { |
Adrian Roos | 1f8025a | 2016-12-27 10:12:13 -0800 | [diff] [blame] | 1508 | synchronized (KeyguardViewMediator.this){ |
| 1509 | mShuttingDown = true; |
| 1510 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1511 | } |
| 1512 | } |
| 1513 | }; |
| 1514 | |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1515 | public void keyguardDone() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1516 | Trace.beginSection("KeyguardViewMediator#keyguardDone"); |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1517 | if (DEBUG) Log.d(TAG, "keyguardDone()"); |
Jorim Jaggi | b9d0491 | 2016-08-04 17:28:08 +0200 | [diff] [blame] | 1518 | userActivity(); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1519 | EventLog.writeEvent(70000, 2); |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1520 | Message msg = mHandler.obtainMessage(KEYGUARD_DONE); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1521 | mHandler.sendMessage(msg); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1522 | Trace.endSection(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1523 | } |
| 1524 | |
| 1525 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1526 | * This handler will be associated with the policy thread, which will also |
| 1527 | * be the UI thread of the keyguard. Since the apis of the policy, and therefore |
| 1528 | * this class, can be called by other threads, any action that directly |
| 1529 | * interacts with the keyguard ui should be posted to this handler, rather |
| 1530 | * than called directly. |
| 1531 | */ |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 1532 | private Handler mHandler = new Handler(Looper.myLooper(), null, true /*async*/) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1533 | @Override |
Wink Saville | 37c124c | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 1534 | public void handleMessage(Message msg) { |
| 1535 | switch (msg.what) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1536 | case SHOW: |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 1537 | handleShow((Bundle) msg.obj); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1538 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1539 | case HIDE: |
| 1540 | handleHide(); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1541 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1542 | case RESET: |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1543 | handleReset(); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1544 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1545 | case VERIFY_UNLOCK: |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1546 | Trace.beginSection("KeyguardViewMediator#handleMessage VERIFY_UNLOCK"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1547 | handleVerifyUnlock(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1548 | Trace.endSection(); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1549 | break; |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 1550 | case NOTIFY_STARTED_GOING_TO_SLEEP: |
| 1551 | handleNotifyStartedGoingToSleep(); |
| 1552 | break; |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 1553 | case NOTIFY_FINISHED_GOING_TO_SLEEP: |
| 1554 | handleNotifyFinishedGoingToSleep(); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1555 | break; |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 1556 | case NOTIFY_SCREEN_TURNING_ON: |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1557 | Trace.beginSection("KeyguardViewMediator#handleMessage NOTIFY_SCREEN_TURNING_ON"); |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 1558 | handleNotifyScreenTurningOn((IKeyguardDrawnCallback) msg.obj); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1559 | Trace.endSection(); |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 1560 | break; |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 1561 | case NOTIFY_SCREEN_TURNED_ON: |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1562 | Trace.beginSection("KeyguardViewMediator#handleMessage NOTIFY_SCREEN_TURNED_ON"); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 1563 | handleNotifyScreenTurnedOn(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1564 | Trace.endSection(); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 1565 | break; |
| 1566 | case NOTIFY_SCREEN_TURNED_OFF: |
| 1567 | handleNotifyScreenTurnedOff(); |
| 1568 | break; |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 1569 | case NOTIFY_STARTED_WAKING_UP: |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1570 | Trace.beginSection("KeyguardViewMediator#handleMessage NOTIFY_STARTED_WAKING_UP"); |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 1571 | handleNotifyStartedWakingUp(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1572 | Trace.endSection(); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1573 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1574 | case KEYGUARD_DONE: |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1575 | Trace.beginSection("KeyguardViewMediator#handleMessage KEYGUARD_DONE"); |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1576 | handleKeyguardDone(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1577 | Trace.endSection(); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1578 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1579 | case KEYGUARD_DONE_DRAWING: |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1580 | Trace.beginSection("KeyguardViewMediator#handleMessage KEYGUARD_DONE_DRAWING"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1581 | handleKeyguardDoneDrawing(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1582 | Trace.endSection(); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1583 | break; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1584 | case SET_OCCLUDED: |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1585 | Trace.beginSection("KeyguardViewMediator#handleMessage SET_OCCLUDED"); |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 1586 | handleSetOccluded(msg.arg1 != 0, msg.arg2 != 0); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1587 | Trace.endSection(); |
Mike Lockwood | 9200a39 | 2009-11-17 20:25:58 -0500 | [diff] [blame] | 1588 | break; |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 1589 | case KEYGUARD_TIMEOUT: |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 1590 | synchronized (KeyguardViewMediator.this) { |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 1591 | doKeyguardLocked((Bundle) msg.obj); |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 1592 | } |
| 1593 | break; |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1594 | case DISMISS: |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 1595 | final DismissMessage message = (DismissMessage) msg.obj; |
| 1596 | handleDismiss(message.getCallback(), message.getMessage()); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1597 | break; |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1598 | case START_KEYGUARD_EXIT_ANIM: |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1599 | Trace.beginSection("KeyguardViewMediator#handleMessage START_KEYGUARD_EXIT_ANIM"); |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 1600 | StartKeyguardExitAnimParams params = (StartKeyguardExitAnimParams) msg.obj; |
| 1601 | handleStartKeyguardExitAnimation(params.startTime, params.fadeoutDuration); |
Dave Mankoff | 2339f59 | 2019-06-28 16:33:25 -0400 | [diff] [blame] | 1602 | Dependency.get(FalsingManager.class).onSucccessfulUnlock(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1603 | Trace.endSection(); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1604 | break; |
Jorim Jaggi | f8d77da | 2014-11-11 16:59:12 +0100 | [diff] [blame] | 1605 | case KEYGUARD_DONE_PENDING_TIMEOUT: |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1606 | Trace.beginSection("KeyguardViewMediator#handleMessage KEYGUARD_DONE_PENDING_TIMEOUT"); |
Jorim Jaggi | f8d77da | 2014-11-11 16:59:12 +0100 | [diff] [blame] | 1607 | Log.w(TAG, "Timeout while waiting for activity drawn!"); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1608 | Trace.endSection(); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1609 | break; |
Adrian Roos | 30a2ae6 | 2018-04-25 19:09:50 +0200 | [diff] [blame] | 1610 | case SYSTEM_READY: |
| 1611 | handleSystemReady(); |
| 1612 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1613 | } |
| 1614 | } |
| 1615 | }; |
| 1616 | |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1617 | private void tryKeyguardDone() { |
Jorim Jaggi | 8d5a6e7 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1618 | if (!mKeyguardDonePending && mHideAnimationRun && !mHideAnimationRunning) { |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1619 | handleKeyguardDone(); |
Jorim Jaggi | 8d5a6e7 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1620 | } else if (!mHideAnimationRun) { |
| 1621 | mHideAnimationRun = true; |
| 1622 | mHideAnimationRunning = true; |
| 1623 | mStatusBarKeyguardViewManager.startPreHideAnimation(mHideAnimationFinishedRunnable); |
| 1624 | } |
| 1625 | } |
| 1626 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1627 | /** |
| 1628 | * @see #keyguardDone |
| 1629 | * @see #KEYGUARD_DONE |
| 1630 | */ |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1631 | private void handleKeyguardDone() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1632 | Trace.beginSection("KeyguardViewMediator#handleKeyguardDone"); |
Michal Karpinski | ed5c8f0 | 2016-02-09 15:43:41 +0000 | [diff] [blame] | 1633 | final int currentUser = KeyguardUpdateMonitor.getCurrentUser(); |
Jorim Jaggi | e549a8d | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 1634 | mUiOffloadThread.submit(() -> { |
| 1635 | if (mLockPatternUtils.isSecure(currentUser)) { |
| 1636 | mLockPatternUtils.getDevicePolicyManager().reportKeyguardDismissed(currentUser); |
| 1637 | } |
| 1638 | }); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1639 | if (DEBUG) Log.d(TAG, "handleKeyguardDone"); |
Jorim Jaggi | 44f60cc | 2014-11-07 20:33:51 +0100 | [diff] [blame] | 1640 | synchronized (this) { |
Jorim Jaggi | f8d77da | 2014-11-11 16:59:12 +0100 | [diff] [blame] | 1641 | resetKeyguardDonePendingLocked(); |
Jorim Jaggi | 44f60cc | 2014-11-07 20:33:51 +0100 | [diff] [blame] | 1642 | } |
Jim Miller | e51cf7ae | 2013-06-25 18:31:56 -0700 | [diff] [blame] | 1643 | |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 1644 | mUpdateMonitor.clearBiometricRecognized(); |
Jeff Sharkey | 6a25cbd | 2012-08-23 12:14:26 -0700 | [diff] [blame] | 1645 | |
Jorim Jaggi | 4474f54 | 2015-07-09 16:08:02 -0700 | [diff] [blame] | 1646 | if (mGoingToSleep) { |
| 1647 | Log.i(TAG, "Device is going to sleep, aborting keyguardDone"); |
| 1648 | return; |
| 1649 | } |
Jim Miller | e51cf7ae | 2013-06-25 18:31:56 -0700 | [diff] [blame] | 1650 | if (mExitSecureCallback != null) { |
| 1651 | try { |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1652 | mExitSecureCallback.onKeyguardExitResult(true /* authenciated */); |
Jim Miller | e51cf7ae | 2013-06-25 18:31:56 -0700 | [diff] [blame] | 1653 | } catch (RemoteException e) { |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1654 | Slog.w(TAG, "Failed to call onKeyguardExitResult()", e); |
Jim Miller | e51cf7ae | 2013-06-25 18:31:56 -0700 | [diff] [blame] | 1655 | } |
| 1656 | |
| 1657 | mExitSecureCallback = null; |
| 1658 | |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1659 | // after succesfully exiting securely, no need to reshow |
| 1660 | // the keyguard when they've released the lock |
| 1661 | mExternallyEnabled = true; |
| 1662 | mNeedToReshowWhenReenabled = false; |
| 1663 | updateInputRestricted(); |
Jim Miller | e51cf7ae | 2013-06-25 18:31:56 -0700 | [diff] [blame] | 1664 | } |
| 1665 | |
| 1666 | handleHide(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1667 | Trace.endSection(); |
Jim Miller | 3fd47af | 2012-09-21 19:55:27 -0700 | [diff] [blame] | 1668 | } |
| 1669 | |
| 1670 | private void sendUserPresentBroadcast() { |
Jason Monk | cf5a953 | 2014-09-17 16:22:19 -0400 | [diff] [blame] | 1671 | synchronized (this) { |
| 1672 | if (mBootCompleted) { |
Adrian Roos | 4ab7e59 | 2016-04-13 15:38:13 -0700 | [diff] [blame] | 1673 | int currentUserId = KeyguardUpdateMonitor.getCurrentUser(); |
| 1674 | final UserHandle currentUser = new UserHandle(currentUserId); |
Benjamin Franz | 4b9f8ed | 2014-12-01 16:51:48 +0000 | [diff] [blame] | 1675 | final UserManager um = (UserManager) mContext.getSystemService( |
| 1676 | Context.USER_SERVICE); |
Jorim Jaggi | e549a8d | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 1677 | mUiOffloadThread.submit(() -> { |
| 1678 | for (int profileId : um.getProfileIdsWithDisabled(currentUser.getIdentifier())) { |
| 1679 | mContext.sendBroadcastAsUser(USER_PRESENT_INTENT, UserHandle.of(profileId)); |
| 1680 | } |
| 1681 | getLockPatternUtils().userPresent(currentUserId); |
| 1682 | }); |
Jason Monk | cf5a953 | 2014-09-17 16:22:19 -0400 | [diff] [blame] | 1683 | } else { |
| 1684 | mBootSendUserPresent = true; |
| 1685 | } |
| 1686 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1687 | } |
| 1688 | |
| 1689 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1690 | * @see #keyguardDone |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1691 | * @see #KEYGUARD_DONE_DRAWING |
| 1692 | */ |
| 1693 | private void handleKeyguardDoneDrawing() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1694 | Trace.beginSection("KeyguardViewMediator#handleKeyguardDoneDrawing"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1695 | synchronized(this) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1696 | if (DEBUG) Log.d(TAG, "handleKeyguardDoneDrawing"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1697 | if (mWaitingUntilKeyguardVisible) { |
| 1698 | if (DEBUG) Log.d(TAG, "handleKeyguardDoneDrawing: notifying mWaitingUntilKeyguardVisible"); |
| 1699 | mWaitingUntilKeyguardVisible = false; |
| 1700 | notifyAll(); |
| 1701 | |
| 1702 | // there will usually be two of these sent, one as a timeout, and one |
| 1703 | // as a result of the callback, so remove any remaining messages from |
| 1704 | // the queue |
| 1705 | mHandler.removeMessages(KEYGUARD_DONE_DRAWING); |
| 1706 | } |
| 1707 | } |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1708 | Trace.endSection(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1709 | } |
| 1710 | |
Daniel Sandler | db783bd | 2010-02-11 15:27:37 -0500 | [diff] [blame] | 1711 | private void playSounds(boolean locked) { |
Adrian Roos | 49e057d | 2014-08-13 17:14:51 +0200 | [diff] [blame] | 1712 | playSound(locked ? mLockSoundId : mUnlockSoundId); |
| 1713 | } |
| 1714 | |
| 1715 | private void playSound(int soundId) { |
| 1716 | if (soundId == 0) return; |
Daniel Sandler | db783bd | 2010-02-11 15:27:37 -0500 | [diff] [blame] | 1717 | final ContentResolver cr = mContext.getContentResolver(); |
Amith Yamasani | 8cb751b | 2011-09-30 15:39:41 -0700 | [diff] [blame] | 1718 | if (Settings.System.getInt(cr, Settings.System.LOCKSCREEN_SOUNDS_ENABLED, 1) == 1) { |
Adrian Roos | 49e057d | 2014-08-13 17:14:51 +0200 | [diff] [blame] | 1719 | |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 1720 | mLockSounds.stop(mLockSoundStreamId); |
Amith Yamasani | 8cb751b | 2011-09-30 15:39:41 -0700 | [diff] [blame] | 1721 | // Init mAudioManager |
| 1722 | if (mAudioManager == null) { |
| 1723 | mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); |
| 1724 | if (mAudioManager == null) return; |
John Spurlock | ee5ad72 | 2015-03-03 16:17:21 -0500 | [diff] [blame] | 1725 | mUiSoundsStreamType = mAudioManager.getUiSoundsStreamType(); |
Amith Yamasani | 8cb751b | 2011-09-30 15:39:41 -0700 | [diff] [blame] | 1726 | } |
Amith Yamasani | 8cb751b | 2011-09-30 15:39:41 -0700 | [diff] [blame] | 1727 | |
Jorim Jaggi | e549a8d | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 1728 | mUiOffloadThread.submit(() -> { |
| 1729 | // If the stream is muted, don't play the sound |
| 1730 | if (mAudioManager.isStreamMute(mUiSoundsStreamType)) return; |
| 1731 | |
| 1732 | int id = mLockSounds.play(soundId, |
| 1733 | mLockSoundVolume, mLockSoundVolume, 1/*priortiy*/, 0/*loop*/, 1.0f/*rate*/); |
| 1734 | synchronized (this) { |
| 1735 | mLockSoundStreamId = id; |
| 1736 | } |
| 1737 | }); |
| 1738 | |
Daniel Sandler | db783bd | 2010-02-11 15:27:37 -0500 | [diff] [blame] | 1739 | } |
Jim Miller | 2a98a4c | 2010-11-19 18:49:26 -0800 | [diff] [blame] | 1740 | } |
Daniel Sandler | db783bd | 2010-02-11 15:27:37 -0500 | [diff] [blame] | 1741 | |
Adrian Roos | 49e057d | 2014-08-13 17:14:51 +0200 | [diff] [blame] | 1742 | private void playTrustedSound() { |
Adrian Roos | 49e057d | 2014-08-13 17:14:51 +0200 | [diff] [blame] | 1743 | playSound(mTrustedSoundId); |
| 1744 | } |
| 1745 | |
wilsonshih | 177261f | 2019-02-22 12:02:18 +0800 | [diff] [blame] | 1746 | private void updateActivityLockScreenState(boolean showing, boolean aodShowing) { |
Jorim Jaggi | e549a8d | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 1747 | mUiOffloadThread.submit(() -> { |
Lucas Dupin | b3455e6 | 2019-07-11 11:47:13 +0900 | [diff] [blame] | 1748 | if (DEBUG) { |
| 1749 | Log.d(TAG, "updateActivityLockScreenState(" + showing + ", " + aodShowing + ")"); |
| 1750 | } |
Jorim Jaggi | e549a8d | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 1751 | try { |
wilsonshih | 177261f | 2019-02-22 12:02:18 +0800 | [diff] [blame] | 1752 | ActivityTaskManager.getService().setLockScreenShown(showing, aodShowing); |
Jorim Jaggi | e549a8d | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 1753 | } catch (RemoteException e) { |
| 1754 | } |
| 1755 | }); |
Dianne Hackborn | ff5b158 | 2012-04-12 17:24:07 -0700 | [diff] [blame] | 1756 | } |
| 1757 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1758 | /** |
| 1759 | * Handle message sent by {@link #showLocked}. |
| 1760 | * @see #SHOW |
| 1761 | */ |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 1762 | private void handleShow(Bundle options) { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1763 | Trace.beginSection("KeyguardViewMediator#handleShow"); |
Michal Karpinski | ed5c8f0 | 2016-02-09 15:43:41 +0000 | [diff] [blame] | 1764 | final int currentUser = KeyguardUpdateMonitor.getCurrentUser(); |
| 1765 | if (mLockPatternUtils.isSecure(currentUser)) { |
| 1766 | mLockPatternUtils.getDevicePolicyManager().reportKeyguardSecured(currentUser); |
Michal Karpinski | 779aad9 | 2016-01-20 11:56:22 +0000 | [diff] [blame] | 1767 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1768 | synchronized (KeyguardViewMediator.this) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1769 | if (!mSystemReady) { |
| 1770 | if (DEBUG) Log.d(TAG, "ignoring handleShow because system is not ready."); |
| 1771 | return; |
| 1772 | } else { |
| 1773 | if (DEBUG) Log.d(TAG, "handleShow"); |
| 1774 | } |
Jim Miller | 9c20d0e | 2010-01-20 15:00:23 -0800 | [diff] [blame] | 1775 | |
Jorim Jaggi | 53c68a4 | 2014-06-17 15:04:47 -0700 | [diff] [blame] | 1776 | mHiding = false; |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 1777 | mWakeAndUnlocking = false; |
Lucas Dupin | b3455e6 | 2019-07-11 11:47:13 +0900 | [diff] [blame] | 1778 | setShowingLocked(true); |
| 1779 | mStatusBarKeyguardViewManager.show(options); |
Jorim Jaggi | f8d77da | 2014-11-11 16:59:12 +0100 | [diff] [blame] | 1780 | resetKeyguardDonePendingLocked(); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1781 | mHideAnimationRun = false; |
Mike Lockwood | 5f892c1 | 2009-11-19 23:39:13 -0500 | [diff] [blame] | 1782 | adjustStatusBarLocked(); |
Jeff Brown | 3dc524b | 2012-09-30 19:49:11 -0700 | [diff] [blame] | 1783 | userActivity(); |
Kevin Chyn | 8c7968a | 2019-03-01 11:25:23 -0800 | [diff] [blame] | 1784 | mUpdateMonitor.setKeyguardGoingAway(false /* away */); |
Lucas Dupin | e25c487 | 2019-07-29 13:51:35 -0700 | [diff] [blame] | 1785 | mStatusBarWindowController.setKeyguardGoingAway(false /* goingAway */); |
Mike Lockwood | 674d3e4 | 2009-10-06 09:28:54 -0400 | [diff] [blame] | 1786 | mShowKeyguardWakeLock.release(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1787 | } |
Jim Miller | 3192148 | 2013-11-06 20:43:55 -0800 | [diff] [blame] | 1788 | mKeyguardDisplayManager.show(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1789 | Trace.endSection(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1790 | } |
| 1791 | |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1792 | private final Runnable mKeyguardGoingAwayRunnable = new Runnable() { |
| 1793 | @Override |
| 1794 | public void run() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1795 | Trace.beginSection("KeyguardViewMediator.mKeyGuardGoingAwayRunnable"); |
Jorim Jaggi | b9d0491 | 2016-08-04 17:28:08 +0200 | [diff] [blame] | 1796 | if (DEBUG) Log.d(TAG, "keyguardGoingAway"); |
wilsonshih | 2bc846c | 2019-05-02 14:35:21 +0800 | [diff] [blame] | 1797 | mStatusBarKeyguardViewManager.keyguardGoingAway(); |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 1798 | |
wilsonshih | 2bc846c | 2019-05-02 14:35:21 +0800 | [diff] [blame] | 1799 | int flags = 0; |
| 1800 | if (mStatusBarKeyguardViewManager.shouldDisableWindowAnimationsForUnlock() |
| 1801 | || (mWakeAndUnlocking && !mPulsing)) { |
| 1802 | flags |= WindowManagerPolicyConstants |
| 1803 | .KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS; |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1804 | } |
wilsonshih | 2bc846c | 2019-05-02 14:35:21 +0800 | [diff] [blame] | 1805 | if (mStatusBarKeyguardViewManager.isGoingToNotificationShade() |
| 1806 | || (mWakeAndUnlocking && mPulsing)) { |
| 1807 | flags |= WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_TO_SHADE; |
| 1808 | } |
| 1809 | if (mStatusBarKeyguardViewManager.isUnlockWithWallpaper()) { |
| 1810 | flags |= WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER; |
| 1811 | } |
Issei Suzuki | 5609ccb | 2019-06-13 15:04:08 +0200 | [diff] [blame] | 1812 | if (mStatusBarKeyguardViewManager.shouldSubtleWindowAnimationsForUnlock()) { |
| 1813 | flags |= WindowManagerPolicyConstants |
| 1814 | .KEYGUARD_GOING_AWAY_FLAG_SUBTLE_WINDOW_ANIMATIONS; |
| 1815 | } |
wilsonshih | 2bc846c | 2019-05-02 14:35:21 +0800 | [diff] [blame] | 1816 | |
| 1817 | mUpdateMonitor.setKeyguardGoingAway(true /* goingAway */); |
Lucas Dupin | e25c487 | 2019-07-29 13:51:35 -0700 | [diff] [blame] | 1818 | mStatusBarWindowController.setKeyguardGoingAway(true /* goingAway */); |
wilsonshih | 2bc846c | 2019-05-02 14:35:21 +0800 | [diff] [blame] | 1819 | |
| 1820 | // Don't actually hide the Keyguard at the moment, wait for window |
| 1821 | // manager until it tells us it's safe to do so with |
| 1822 | // startKeyguardExitAnimation. |
| 1823 | // Posting to mUiOffloadThread to ensure that calls to ActivityTaskManager will be in |
| 1824 | // order. |
| 1825 | final int keyguardFlag = flags; |
| 1826 | mUiOffloadThread.submit(() -> { |
| 1827 | try { |
| 1828 | ActivityTaskManager.getService().keyguardGoingAway(keyguardFlag); |
| 1829 | } catch (RemoteException e) { |
| 1830 | Log.e(TAG, "Error while calling WindowManager", e); |
| 1831 | } |
| 1832 | }); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1833 | Trace.endSection(); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1834 | } |
| 1835 | }; |
| 1836 | |
Jorim Jaggi | 8d5a6e7 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1837 | private final Runnable mHideAnimationFinishedRunnable = () -> { |
| 1838 | mHideAnimationRunning = false; |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1839 | tryKeyguardDone(); |
Jorim Jaggi | 8d5a6e7 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1840 | }; |
| 1841 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1842 | /** |
| 1843 | * Handle message sent by {@link #hideLocked()} |
| 1844 | * @see #HIDE |
| 1845 | */ |
| 1846 | private void handleHide() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1847 | Trace.beginSection("KeyguardViewMediator#handleHide"); |
Lucas Dupin | 1c32743 | 2019-01-03 13:37:53 -0800 | [diff] [blame] | 1848 | |
| 1849 | // It's possible that the device was unlocked in a dream state. It's time to wake up. |
| 1850 | if (mAodShowing) { |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 1851 | PowerManager pm = mContext.getSystemService(PowerManager.class); |
| 1852 | pm.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_GESTURE, |
| 1853 | "com.android.systemui:BOUNCER_DOZING"); |
Lucas Dupin | 1c32743 | 2019-01-03 13:37:53 -0800 | [diff] [blame] | 1854 | } |
| 1855 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1856 | synchronized (KeyguardViewMediator.this) { |
| 1857 | if (DEBUG) Log.d(TAG, "handleHide"); |
Jorim Jaggi | b9d6079 | 2014-06-03 22:34:22 +0200 | [diff] [blame] | 1858 | |
Amith Yamasani | eb437d4 | 2016-04-29 09:31:25 -0700 | [diff] [blame] | 1859 | if (mustNotUnlockCurrentUser()) { |
Xiaohui Chen | f561d7f | 2015-07-09 16:35:00 -0700 | [diff] [blame] | 1860 | // In split system user mode, we never unlock system user. The end user has to |
| 1861 | // switch to another user. |
| 1862 | // TODO: We should stop it early by disabling the swipe up flow. Right now swipe up |
| 1863 | // still completes and makes the screen blank. |
| 1864 | if (DEBUG) Log.d(TAG, "Split system user, quit unlocking."); |
| 1865 | return; |
| 1866 | } |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 1867 | mHiding = true; |
Jorim Jaggi | b9d6079 | 2014-06-03 22:34:22 +0200 | [diff] [blame] | 1868 | |
Jorim Jaggi | 8d5a6e7 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1869 | if (mShowing && !mOccluded) { |
| 1870 | mKeyguardGoingAwayRunnable.run(); |
| 1871 | } else { |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 1872 | handleStartKeyguardExitAnimation( |
| 1873 | SystemClock.uptimeMillis() + mHideAnimation.getStartOffset(), |
| 1874 | mHideAnimation.getDuration()); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1875 | } |
| 1876 | } |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1877 | Trace.endSection(); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1878 | } |
| 1879 | |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 1880 | private void handleStartKeyguardExitAnimation(long startTime, long fadeoutDuration) { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1881 | Trace.beginSection("KeyguardViewMediator#handleStartKeyguardExitAnimation"); |
Jorim Jaggi | b9d0491 | 2016-08-04 17:28:08 +0200 | [diff] [blame] | 1882 | if (DEBUG) Log.d(TAG, "handleStartKeyguardExitAnimation startTime=" + startTime |
| 1883 | + " fadeoutDuration=" + fadeoutDuration); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1884 | synchronized (KeyguardViewMediator.this) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1885 | |
Jorim Jaggi | 53c68a4 | 2014-06-17 15:04:47 -0700 | [diff] [blame] | 1886 | if (!mHiding) { |
Adrian Roos | 6ec76b7 | 2018-04-25 14:01:11 +0200 | [diff] [blame] | 1887 | // Tell ActivityManager that we canceled the keyguardExitAnimation. |
Lucas Dupin | b3455e6 | 2019-07-11 11:47:13 +0900 | [diff] [blame] | 1888 | setShowingLocked(mShowing, true /* force */); |
Jorim Jaggi | 53c68a4 | 2014-06-17 15:04:47 -0700 | [diff] [blame] | 1889 | return; |
| 1890 | } |
| 1891 | mHiding = false; |
| 1892 | |
Jorim Jaggi | b774e55 | 2015-08-24 14:52:45 -0700 | [diff] [blame] | 1893 | if (mWakeAndUnlocking && mDrawnCallback != null) { |
| 1894 | |
| 1895 | // Hack level over 9000: To speed up wake-and-unlock sequence, force it to report |
| 1896 | // the next draw from here so we don't have to wait for window manager to signal |
| 1897 | // this to our ViewRootImpl. |
| 1898 | mStatusBarKeyguardViewManager.getViewRootImpl().setReportNextDraw(); |
| 1899 | notifyDrawn(mDrawnCallback); |
Jorim Jaggi | e93e6f9 | 2016-08-04 13:55:39 +0200 | [diff] [blame] | 1900 | mDrawnCallback = null; |
Jorim Jaggi | b774e55 | 2015-08-24 14:52:45 -0700 | [diff] [blame] | 1901 | } |
| 1902 | |
Daniel Sandler | f2d8e74 | 2010-02-22 13:09:48 -0500 | [diff] [blame] | 1903 | // only play "unlock" noises if not on a call (since the incall UI |
| 1904 | // disables the keyguard) |
| 1905 | if (TelephonyManager.EXTRA_STATE_IDLE.equals(mPhoneState)) { |
| 1906 | playSounds(false); |
| 1907 | } |
Daniel Sandler | db783bd | 2010-02-11 15:27:37 -0500 | [diff] [blame] | 1908 | |
Lucas Dupin | b3455e6 | 2019-07-11 11:47:13 +0900 | [diff] [blame] | 1909 | setShowingLocked(false); |
Jorim Jaggi | e93e6f9 | 2016-08-04 13:55:39 +0200 | [diff] [blame] | 1910 | mWakeAndUnlocking = false; |
Jorim Jaggi | 5277dea | 2017-05-18 02:05:29 +0200 | [diff] [blame] | 1911 | mDismissCallbackRegistry.notifyDismissSucceeded(); |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 1912 | mStatusBarKeyguardViewManager.hide(startTime, fadeoutDuration); |
Jorim Jaggi | f8d77da | 2014-11-11 16:59:12 +0100 | [diff] [blame] | 1913 | resetKeyguardDonePendingLocked(); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1914 | mHideAnimationRun = false; |
Mike Lockwood | 5f892c1 | 2009-11-19 23:39:13 -0500 | [diff] [blame] | 1915 | adjustStatusBarLocked(); |
Jim Miller | 705004b | 2014-09-04 16:51:20 -0700 | [diff] [blame] | 1916 | sendUserPresentBroadcast(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1917 | } |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1918 | Trace.endSection(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1919 | } |
| 1920 | |
Mike Lockwood | 5f892c1 | 2009-11-19 23:39:13 -0500 | [diff] [blame] | 1921 | private void adjustStatusBarLocked() { |
Matthew Ng | 66f0b70 | 2017-12-08 12:58:42 -0800 | [diff] [blame] | 1922 | adjustStatusBarLocked(false /* forceHideHomeRecentsButtons */); |
| 1923 | } |
| 1924 | |
| 1925 | private void adjustStatusBarLocked(boolean forceHideHomeRecentsButtons) { |
Mike Lockwood | 5f892c1 | 2009-11-19 23:39:13 -0500 | [diff] [blame] | 1926 | if (mStatusBarManager == null) { |
| 1927 | mStatusBarManager = (StatusBarManager) |
| 1928 | mContext.getSystemService(Context.STATUS_BAR_SERVICE); |
| 1929 | } |
Matthew Ng | 78ba6e2 | 2018-09-24 16:55:36 -0700 | [diff] [blame] | 1930 | |
Mike Lockwood | 5f892c1 | 2009-11-19 23:39:13 -0500 | [diff] [blame] | 1931 | if (mStatusBarManager == null) { |
| 1932 | Log.w(TAG, "Could not get status bar manager"); |
| 1933 | } else { |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 1934 | // Disable aspects of the system/status/navigation bars that must not be re-enabled by |
| 1935 | // windows that appear on top, ever |
Jeff Sharkey | f52c70b | 2011-08-30 22:05:47 -0700 | [diff] [blame] | 1936 | int flags = StatusBarManager.DISABLE_NONE; |
Matthew Ng | 66f0b70 | 2017-12-08 12:58:42 -0800 | [diff] [blame] | 1937 | if (forceHideHomeRecentsButtons || isShowingAndNotOccluded()) { |
| 1938 | flags |= StatusBarManager.DISABLE_HOME | StatusBarManager.DISABLE_RECENT; |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 1939 | } |
Jeff Sharkey | f52c70b | 2011-08-30 22:05:47 -0700 | [diff] [blame] | 1940 | |
| 1941 | if (DEBUG) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1942 | Log.d(TAG, "adjustStatusBarLocked: mShowing=" + mShowing + " mOccluded=" + mOccluded |
Matthew Ng | 66f0b70 | 2017-12-08 12:58:42 -0800 | [diff] [blame] | 1943 | + " isSecure=" + isSecure() + " force=" + forceHideHomeRecentsButtons |
| 1944 | + " --> flags=0x" + Integer.toHexString(flags)); |
Jeff Sharkey | f52c70b | 2011-08-30 22:05:47 -0700 | [diff] [blame] | 1945 | } |
| 1946 | |
Jorim Jaggi | e3e0b06 | 2017-06-12 12:18:41 -0700 | [diff] [blame] | 1947 | mStatusBarManager.disable(flags); |
Mike Lockwood | 5f892c1 | 2009-11-19 23:39:13 -0500 | [diff] [blame] | 1948 | } |
| 1949 | } |
| 1950 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1951 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1952 | * Handle message sent by {@link #resetStateLocked} |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1953 | * @see #RESET |
| 1954 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1955 | private void handleReset() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1956 | synchronized (KeyguardViewMediator.this) { |
| 1957 | if (DEBUG) Log.d(TAG, "handleReset"); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1958 | mStatusBarKeyguardViewManager.reset(true /* hideBouncerWhenShowing */); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1959 | } |
| 1960 | } |
| 1961 | |
| 1962 | /** |
| 1963 | * Handle message sent by {@link #verifyUnlock} |
Craig Mautner | 904732c | 2012-10-17 15:20:24 -0700 | [diff] [blame] | 1964 | * @see #VERIFY_UNLOCK |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1965 | */ |
| 1966 | private void handleVerifyUnlock() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1967 | Trace.beginSection("KeyguardViewMediator#handleVerifyUnlock"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1968 | synchronized (KeyguardViewMediator.this) { |
| 1969 | if (DEBUG) Log.d(TAG, "handleVerifyUnlock"); |
Lucas Dupin | b3455e6 | 2019-07-11 11:47:13 +0900 | [diff] [blame] | 1970 | setShowingLocked(true); |
Jorim Jaggi | 8d5a6e7 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1971 | mStatusBarKeyguardViewManager.dismissAndCollapse(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1972 | } |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1973 | Trace.endSection(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1974 | } |
| 1975 | |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 1976 | private void handleNotifyStartedGoingToSleep() { |
| 1977 | synchronized (KeyguardViewMediator.this) { |
| 1978 | if (DEBUG) Log.d(TAG, "handleNotifyStartedGoingToSleep"); |
| 1979 | mStatusBarKeyguardViewManager.onStartedGoingToSleep(); |
| 1980 | } |
| 1981 | } |
| 1982 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1983 | /** |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 1984 | * Handle message sent by {@link #notifyFinishedGoingToSleep()} |
| 1985 | * @see #NOTIFY_FINISHED_GOING_TO_SLEEP |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1986 | */ |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 1987 | private void handleNotifyFinishedGoingToSleep() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1988 | synchronized (KeyguardViewMediator.this) { |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 1989 | if (DEBUG) Log.d(TAG, "handleNotifyFinishedGoingToSleep"); |
| 1990 | mStatusBarKeyguardViewManager.onFinishedGoingToSleep(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1991 | } |
| 1992 | } |
| 1993 | |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 1994 | private void handleNotifyStartedWakingUp() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 1995 | Trace.beginSection("KeyguardViewMediator#handleMotifyStartedWakingUp"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1996 | synchronized (KeyguardViewMediator.this) { |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 1997 | if (DEBUG) Log.d(TAG, "handleNotifyWakingUp"); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 1998 | mStatusBarKeyguardViewManager.onStartedWakingUp(); |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 1999 | } |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2000 | Trace.endSection(); |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 2001 | } |
| 2002 | |
| 2003 | private void handleNotifyScreenTurningOn(IKeyguardDrawnCallback callback) { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2004 | Trace.beginSection("KeyguardViewMediator#handleNotifyScreenTurningOn"); |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 2005 | synchronized (KeyguardViewMediator.this) { |
| 2006 | if (DEBUG) Log.d(TAG, "handleNotifyScreenTurningOn"); |
Jorim Jaggi | 9373911 | 2015-08-13 15:53:14 -0700 | [diff] [blame] | 2007 | mStatusBarKeyguardViewManager.onScreenTurningOn(); |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 2008 | if (callback != null) { |
| 2009 | if (mWakeAndUnlocking) { |
| 2010 | mDrawnCallback = callback; |
| 2011 | } else { |
| 2012 | notifyDrawn(callback); |
| 2013 | } |
| 2014 | } |
| 2015 | } |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2016 | Trace.endSection(); |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 2017 | } |
| 2018 | |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 2019 | private void handleNotifyScreenTurnedOn() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2020 | Trace.beginSection("KeyguardViewMediator#handleNotifyScreenTurnedOn"); |
Jorim Jaggi | c3fe204 | 2016-10-07 18:52:48 +0200 | [diff] [blame] | 2021 | if (LatencyTracker.isEnabled(mContext)) { |
| 2022 | LatencyTracker.getInstance(mContext).onActionEnd(LatencyTracker.ACTION_TURN_ON_SCREEN); |
| 2023 | } |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 2024 | synchronized (this) { |
| 2025 | if (DEBUG) Log.d(TAG, "handleNotifyScreenTurnedOn"); |
| 2026 | mStatusBarKeyguardViewManager.onScreenTurnedOn(); |
| 2027 | } |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2028 | Trace.endSection(); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 2029 | } |
| 2030 | |
| 2031 | private void handleNotifyScreenTurnedOff() { |
| 2032 | synchronized (this) { |
| 2033 | if (DEBUG) Log.d(TAG, "handleNotifyScreenTurnedOff"); |
Jorim Jaggi | e93e6f9 | 2016-08-04 13:55:39 +0200 | [diff] [blame] | 2034 | mDrawnCallback = null; |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 2035 | } |
| 2036 | } |
| 2037 | |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 2038 | private void notifyDrawn(final IKeyguardDrawnCallback callback) { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2039 | Trace.beginSection("KeyguardViewMediator#notifyDrawn"); |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 2040 | try { |
| 2041 | callback.onDrawn(); |
| 2042 | } catch (RemoteException e) { |
| 2043 | Slog.w(TAG, "Exception calling onDrawn():", e); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2044 | } |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2045 | Trace.endSection(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2046 | } |
Jeff Sharkey | 054340d | 2011-09-01 22:28:03 -0700 | [diff] [blame] | 2047 | |
Jorim Jaggi | f8d77da | 2014-11-11 16:59:12 +0100 | [diff] [blame] | 2048 | private void resetKeyguardDonePendingLocked() { |
| 2049 | mKeyguardDonePending = false; |
| 2050 | mHandler.removeMessages(KEYGUARD_DONE_PENDING_TIMEOUT); |
| 2051 | } |
| 2052 | |
Jim Miller | 2967f48 | 2016-01-07 15:05:32 -0800 | [diff] [blame] | 2053 | @Override |
Jim Miller | e5f910a | 2013-10-16 18:15:46 -0700 | [diff] [blame] | 2054 | public void onBootCompleted() { |
| 2055 | mUpdateMonitor.dispatchBootCompleted(); |
Jason Monk | cf5a953 | 2014-09-17 16:22:19 -0400 | [diff] [blame] | 2056 | synchronized (this) { |
| 2057 | mBootCompleted = true; |
| 2058 | if (mBootSendUserPresent) { |
| 2059 | sendUserPresentBroadcast(); |
| 2060 | } |
| 2061 | } |
Jim Miller | e5f910a | 2013-10-16 18:15:46 -0700 | [diff] [blame] | 2062 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 2063 | |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 2064 | public void onWakeAndUnlocking() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2065 | Trace.beginSection("KeyguardViewMediator#onWakeAndUnlocking"); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 2066 | mWakeAndUnlocking = true; |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 2067 | keyguardDone(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2068 | Trace.endSection(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 2069 | } |
| 2070 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 2071 | public StatusBarKeyguardViewManager registerStatusBar(StatusBar statusBar, |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 2072 | ViewGroup container, NotificationPanelView panelView, |
Selim Cinek | 06c12d6 | 2019-07-01 19:44:18 -0700 | [diff] [blame] | 2073 | BiometricUnlockController biometricUnlockController, ViewGroup lockIconContainer, |
Dave Mankoff | 2339f59 | 2019-06-28 16:33:25 -0400 | [diff] [blame] | 2074 | View notificationContainer, KeyguardBypassController bypassController, |
| 2075 | FalsingManager falsingManager) { |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 2076 | mStatusBarKeyguardViewManager.registerStatusBar(statusBar, container, panelView, |
Selim Cinek | 06c12d6 | 2019-07-01 19:44:18 -0700 | [diff] [blame] | 2077 | biometricUnlockController, mDismissCallbackRegistry, lockIconContainer, |
Dave Mankoff | 2339f59 | 2019-06-28 16:33:25 -0400 | [diff] [blame] | 2078 | notificationContainer, bypassController, falsingManager); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 2079 | return mStatusBarKeyguardViewManager; |
| 2080 | } |
| 2081 | |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 2082 | public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2083 | Trace.beginSection("KeyguardViewMediator#startKeyguardExitAnimation"); |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 2084 | Message msg = mHandler.obtainMessage(START_KEYGUARD_EXIT_ANIM, |
| 2085 | new StartKeyguardExitAnimParams(startTime, fadeoutDuration)); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 2086 | mHandler.sendMessage(msg); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 2087 | Trace.endSection(); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 2088 | } |
| 2089 | |
Andrew Zeng | b4045d3 | 2017-03-16 17:25:07 -0700 | [diff] [blame] | 2090 | public void onShortPowerPressedGoHome() { |
| 2091 | // do nothing |
| 2092 | } |
| 2093 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 2094 | public ViewMediatorCallback getViewMediatorCallback() { |
| 2095 | return mViewMediatorCallback; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 2096 | } |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 2097 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 2098 | public LockPatternUtils getLockPatternUtils() { |
| 2099 | return mLockPatternUtils; |
| 2100 | } |
| 2101 | |
Jorim Jaggi | 84dc08a | 2015-09-11 17:45:22 -0700 | [diff] [blame] | 2102 | @Override |
| 2103 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 2104 | pw.print(" mSystemReady: "); pw.println(mSystemReady); |
| 2105 | pw.print(" mBootCompleted: "); pw.println(mBootCompleted); |
| 2106 | pw.print(" mBootSendUserPresent: "); pw.println(mBootSendUserPresent); |
| 2107 | pw.print(" mExternallyEnabled: "); pw.println(mExternallyEnabled); |
Adrian Roos | 1f8025a | 2016-12-27 10:12:13 -0800 | [diff] [blame] | 2108 | pw.print(" mShuttingDown: "); pw.println(mShuttingDown); |
Jorim Jaggi | 84dc08a | 2015-09-11 17:45:22 -0700 | [diff] [blame] | 2109 | pw.print(" mNeedToReshowWhenReenabled: "); pw.println(mNeedToReshowWhenReenabled); |
| 2110 | pw.print(" mShowing: "); pw.println(mShowing); |
| 2111 | pw.print(" mInputRestricted: "); pw.println(mInputRestricted); |
| 2112 | pw.print(" mOccluded: "); pw.println(mOccluded); |
| 2113 | pw.print(" mDelayedShowingSequence: "); pw.println(mDelayedShowingSequence); |
| 2114 | pw.print(" mExitSecureCallback: "); pw.println(mExitSecureCallback); |
| 2115 | pw.print(" mDeviceInteractive: "); pw.println(mDeviceInteractive); |
| 2116 | pw.print(" mGoingToSleep: "); pw.println(mGoingToSleep); |
| 2117 | pw.print(" mHiding: "); pw.println(mHiding); |
Lucas Dupin | b3455e6 | 2019-07-11 11:47:13 +0900 | [diff] [blame] | 2118 | pw.print(" mDozing: "); pw.println(mDozing); |
| 2119 | pw.print(" mAodShowing: "); pw.println(mAodShowing); |
Jorim Jaggi | 84dc08a | 2015-09-11 17:45:22 -0700 | [diff] [blame] | 2120 | pw.print(" mWaitingUntilKeyguardVisible: "); pw.println(mWaitingUntilKeyguardVisible); |
| 2121 | pw.print(" mKeyguardDonePending: "); pw.println(mKeyguardDonePending); |
| 2122 | pw.print(" mHideAnimationRun: "); pw.println(mHideAnimationRun); |
| 2123 | pw.print(" mPendingReset: "); pw.println(mPendingReset); |
| 2124 | pw.print(" mPendingLock: "); pw.println(mPendingLock); |
| 2125 | pw.print(" mWakeAndUnlocking: "); pw.println(mWakeAndUnlocking); |
| 2126 | pw.print(" mDrawnCallback: "); pw.println(mDrawnCallback); |
| 2127 | } |
| 2128 | |
Lucas Dupin | 5a4f92c | 2018-07-02 13:15:23 -0700 | [diff] [blame] | 2129 | /** |
Lucas Dupin | b3455e6 | 2019-07-11 11:47:13 +0900 | [diff] [blame] | 2130 | * @param dozing true when AOD - or ambient mode - is showing. |
Lucas Dupin | 5a4f92c | 2018-07-02 13:15:23 -0700 | [diff] [blame] | 2131 | */ |
Lucas Dupin | b3455e6 | 2019-07-11 11:47:13 +0900 | [diff] [blame] | 2132 | public void setDozing(boolean dozing) { |
| 2133 | if (dozing == mDozing) { |
| 2134 | return; |
| 2135 | } |
| 2136 | mDozing = dozing; |
| 2137 | setShowingLocked(mShowing); |
Lucas Dupin | 47a65c7 | 2018-02-15 14:16:18 -0800 | [diff] [blame] | 2138 | } |
| 2139 | |
Lucas Dupin | d35502f | 2018-06-27 13:35:52 -0700 | [diff] [blame] | 2140 | /** |
| 2141 | * @param pulsing true when device temporarily wakes up to display an incoming notification. |
| 2142 | */ |
| 2143 | public void setPulsing(boolean pulsing) { |
| 2144 | mPulsing = pulsing; |
| 2145 | } |
| 2146 | |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 2147 | private static class StartKeyguardExitAnimParams { |
| 2148 | |
| 2149 | long startTime; |
| 2150 | long fadeoutDuration; |
| 2151 | |
| 2152 | private StartKeyguardExitAnimParams(long startTime, long fadeoutDuration) { |
| 2153 | this.startTime = startTime; |
| 2154 | this.fadeoutDuration = fadeoutDuration; |
| 2155 | } |
| 2156 | } |
Adrian Roos | 481a6df | 2014-11-20 19:48:56 +0100 | [diff] [blame] | 2157 | |
Lucas Dupin | b3455e6 | 2019-07-11 11:47:13 +0900 | [diff] [blame] | 2158 | private void setShowingLocked(boolean showing) { |
| 2159 | setShowingLocked(showing, false /* forceCallbacks */); |
Jorim Jaggi | e8f321e | 2016-11-07 16:48:31 -0800 | [diff] [blame] | 2160 | } |
| 2161 | |
Lucas Dupin | b3455e6 | 2019-07-11 11:47:13 +0900 | [diff] [blame] | 2162 | private void setShowingLocked(boolean showing, boolean forceCallbacks) { |
| 2163 | final boolean aodShowing = mDozing && !mWakeAndUnlocking; |
Lucas Dupin | 47a65c7 | 2018-02-15 14:16:18 -0800 | [diff] [blame] | 2164 | final boolean notifyDefaultDisplayCallbacks = showing != mShowing |
| 2165 | || aodShowing != mAodShowing || forceCallbacks; |
Lucas Dupin | b3455e6 | 2019-07-11 11:47:13 +0900 | [diff] [blame] | 2166 | mShowing = showing; |
| 2167 | mAodShowing = aodShowing; |
wilsonshih | 177261f | 2019-02-22 12:02:18 +0800 | [diff] [blame] | 2168 | if (notifyDefaultDisplayCallbacks) { |
Lucas Dupin | b3455e6 | 2019-07-11 11:47:13 +0900 | [diff] [blame] | 2169 | notifyDefaultDisplayCallbacks(showing); |
wilsonshih | 177261f | 2019-02-22 12:02:18 +0800 | [diff] [blame] | 2170 | updateActivityLockScreenState(showing, aodShowing); |
David Stevens | 53a39ea | 2017-08-23 18:41:49 -0700 | [diff] [blame] | 2171 | } |
| 2172 | } |
| 2173 | |
| 2174 | private void notifyDefaultDisplayCallbacks(boolean showing) { |
| 2175 | int size = mKeyguardStateCallbacks.size(); |
| 2176 | for (int i = size - 1; i >= 0; i--) { |
| 2177 | IKeyguardStateCallback callback = mKeyguardStateCallbacks.get(i); |
| 2178 | try { |
| 2179 | callback.onShowingStateChanged(showing); |
| 2180 | } catch (RemoteException e) { |
| 2181 | Slog.w(TAG, "Failed to call onShowingStateChanged", e); |
| 2182 | if (e instanceof DeadObjectException) { |
| 2183 | mKeyguardStateCallbacks.remove(callback); |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 2184 | } |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 2185 | } |
Adrian Roos | 481a6df | 2014-11-20 19:48:56 +0100 | [diff] [blame] | 2186 | } |
David Stevens | 53a39ea | 2017-08-23 18:41:49 -0700 | [diff] [blame] | 2187 | updateInputRestrictedLocked(); |
| 2188 | mUiOffloadThread.submit(() -> { |
| 2189 | mTrustManager.reportKeyguardShowingChanged(); |
| 2190 | }); |
Adrian Roos | 481a6df | 2014-11-20 19:48:56 +0100 | [diff] [blame] | 2191 | } |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 2192 | |
Adrian Roos | d88eb26 | 2016-08-04 14:50:48 -0700 | [diff] [blame] | 2193 | private void notifyTrustedChangedLocked(boolean trusted) { |
| 2194 | int size = mKeyguardStateCallbacks.size(); |
| 2195 | for (int i = size - 1; i >= 0; i--) { |
| 2196 | try { |
| 2197 | mKeyguardStateCallbacks.get(i).onTrustedChanged(trusted); |
| 2198 | } catch (RemoteException e) { |
| 2199 | Slog.w(TAG, "Failed to call notifyTrustedChangedLocked", e); |
| 2200 | if (e instanceof DeadObjectException) { |
| 2201 | mKeyguardStateCallbacks.remove(i); |
| 2202 | } |
| 2203 | } |
| 2204 | } |
| 2205 | } |
| 2206 | |
Jorim Jaggi | d11d1a9 | 2016-08-16 16:02:32 -0700 | [diff] [blame] | 2207 | private void notifyHasLockscreenWallpaperChanged(boolean hasLockscreenWallpaper) { |
| 2208 | int size = mKeyguardStateCallbacks.size(); |
| 2209 | for (int i = size - 1; i >= 0; i--) { |
| 2210 | try { |
| 2211 | mKeyguardStateCallbacks.get(i).onHasLockscreenWallpaperChanged( |
| 2212 | hasLockscreenWallpaper); |
| 2213 | } catch (RemoteException e) { |
| 2214 | Slog.w(TAG, "Failed to call onHasLockscreenWallpaperChanged", e); |
| 2215 | if (e instanceof DeadObjectException) { |
| 2216 | mKeyguardStateCallbacks.remove(i); |
| 2217 | } |
| 2218 | } |
| 2219 | } |
| 2220 | } |
| 2221 | |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 2222 | public void addStateMonitorCallback(IKeyguardStateCallback callback) { |
| 2223 | synchronized (this) { |
| 2224 | mKeyguardStateCallbacks.add(callback); |
| 2225 | try { |
| 2226 | callback.onSimSecureStateChanged(mUpdateMonitor.isSimPinSecure()); |
| 2227 | callback.onShowingStateChanged(mShowing); |
Adrian Roos | 4a963ac | 2015-04-24 16:04:53 -0700 | [diff] [blame] | 2228 | callback.onInputRestrictedStateChanged(mInputRestricted); |
Adrian Roos | d88eb26 | 2016-08-04 14:50:48 -0700 | [diff] [blame] | 2229 | callback.onTrustedChanged(mUpdateMonitor.getUserHasTrust( |
| 2230 | KeyguardUpdateMonitor.getCurrentUser())); |
Jorim Jaggi | d11d1a9 | 2016-08-16 16:02:32 -0700 | [diff] [blame] | 2231 | callback.onHasLockscreenWallpaperChanged(mUpdateMonitor.hasLockscreenWallpaper()); |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 2232 | } catch (RemoteException e) { |
Adrian Roos | d88eb26 | 2016-08-04 14:50:48 -0700 | [diff] [blame] | 2233 | Slog.w(TAG, "Failed to call to IKeyguardStateCallback", e); |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 2234 | } |
| 2235 | } |
| 2236 | } |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 2237 | |
| 2238 | private static class DismissMessage { |
| 2239 | private final CharSequence mMessage; |
| 2240 | private final IKeyguardDismissCallback mCallback; |
| 2241 | |
| 2242 | DismissMessage(IKeyguardDismissCallback callback, CharSequence message) { |
| 2243 | mCallback = callback; |
| 2244 | mMessage = message; |
| 2245 | } |
| 2246 | |
| 2247 | public IKeyguardDismissCallback getCallback() { |
| 2248 | return mCallback; |
| 2249 | } |
| 2250 | |
| 2251 | public CharSequence getMessage() { |
| 2252 | return mMessage; |
| 2253 | } |
| 2254 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2255 | } |