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