blob: e207eb079fcfed8157ace7b34063726f68250280 [file] [log] [blame]
Jorim Jaggi5cf17872014-03-26 18:31:48 +01001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
15 */
16
17package com.android.systemui.statusbar.phone;
18
Jorim Jaggif5304ad2017-07-17 18:31:13 +020019import static com.android.keyguard.KeyguardHostView.OnDismissAction;
20import static com.android.systemui.statusbar.phone.FingerprintUnlockController.MODE_WAKE_AND_UNLOCK;
21import static com.android.systemui.statusbar.phone.FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING;
22
Jorim Jaggi786afcb2014-09-25 02:41:29 +020023import android.content.ComponentCallbacks2;
Jorim Jaggi5cf17872014-03-26 18:31:48 +010024import android.content.Context;
25import android.os.Bundle;
Jorim Jaggie29b2db2014-05-30 23:17:03 +020026import android.os.SystemClock;
Tej Singhdd7bd352018-02-09 19:33:15 -080027import android.util.StatsLog;
Jorim Jaggidf993512014-05-13 23:06:35 +020028import android.view.KeyEvent;
Jorim Jaggi5cf17872014-03-26 18:31:48 +010029import android.view.View;
30import android.view.ViewGroup;
Jorim Jaggib774e552015-08-24 14:52:45 -070031import android.view.ViewRootImpl;
Jorim Jaggi786afcb2014-09-25 02:41:29 +020032import android.view.WindowManagerGlobal;
Jorim Jaggi5cf17872014-03-26 18:31:48 +010033
Lucas Dupinbc9aac12018-03-04 20:18:15 -080034import com.android.internal.util.LatencyTracker;
Jorim Jaggi5cf17872014-03-26 18:31:48 +010035import com.android.internal.widget.LockPatternUtils;
Adrian Roosb6011622014-05-14 15:52:53 +020036import com.android.keyguard.KeyguardUpdateMonitor;
Jorim Jaggia9d7fcd2017-05-18 01:08:12 +020037import com.android.keyguard.KeyguardUpdateMonitorCallback;
Jorim Jaggi5cf17872014-03-26 18:31:48 +010038import com.android.keyguard.ViewMediatorCallback;
Jorim Jaggi8adb30c2016-09-13 15:02:22 -070039import com.android.systemui.DejankUtils;
Jason Monk421a9412017-02-06 09:15:21 -080040import com.android.systemui.Dependency;
Xiyuan Xia1b30f792016-01-06 08:50:30 -080041import com.android.systemui.SystemUIFactory;
Jorim Jaggi241ae102016-11-02 21:57:33 -070042import com.android.systemui.keyguard.DismissCallbackRegistry;
Jim Miller25d7e512015-03-03 17:12:09 -080043import com.android.systemui.statusbar.CommandQueue;
Adrian Roosd28ccd72016-01-06 15:23:14 +010044import com.android.systemui.statusbar.RemoteInputController;
Lucas Dupin15a6b6c2018-04-16 14:50:20 +080045import com.android.systemui.statusbar.phone.KeyguardBouncer.BouncerExpansionCallback;
Jorim Jaggi5cf17872014-03-26 18:31:48 +010046
Lucas Dupin15a6b6c2018-04-16 14:50:20 +080047import java.io.PrintWriter;
Jorim Jaggibcbe9482016-11-23 17:37:49 +010048import java.util.ArrayList;
49
Jorim Jaggi5cf17872014-03-26 18:31:48 +010050/**
51 * Manages creating, showing, hiding and resetting the keyguard within the status bar. Calls back
52 * via {@link ViewMediatorCallback} to poke the wake lock and report that the keyguard is done,
53 * which is in turn, reported to this class by the current
54 * {@link com.android.keyguard.KeyguardViewBase}.
55 */
Adrian Roosd28ccd72016-01-06 15:23:14 +010056public class StatusBarKeyguardViewManager implements RemoteInputController.Callback {
Jorim Jaggi76a16232014-08-08 17:00:47 +020057
58 // When hiding the Keyguard with timing supplied from WindowManager, better be early than late.
Jorim Jaggi56fd70c2016-10-27 19:57:08 -070059 private static final long HIDE_TIMING_CORRECTION_MS = - 16 * 3;
Jorim Jaggi76a16232014-08-08 17:00:47 +020060
Jorim Jaggi416493b2014-09-13 03:57:32 +020061 // Delay for showing the navigation bar when the bouncer appears. This should be kept in sync
62 // with the appear animations of the PIN/pattern/password views.
63 private static final long NAV_BAR_SHOW_DELAY_BOUNCER = 320;
64
Jorim Jaggi007f0e82015-08-14 13:56:01 -070065 private static final long WAKE_AND_UNLOCK_SCRIM_FADEOUT_DURATION_MS = 200;
66
Jorim Jaggie8fde5d2016-06-30 23:41:37 -070067 // Duration of the Keyguard dismissal animation in case the user is currently locked. This is to
68 // make everything a bit slower to bridge a gap until the user is unlocked and home screen has
69 // dranw its first frame.
70 private static final long KEYGUARD_DISMISS_DURATION_LOCKED = 2000;
71
Jorim Jaggi5cf17872014-03-26 18:31:48 +010072 private static String TAG = "StatusBarKeyguardViewManager";
73
Xiyuan Xia1b30f792016-01-06 08:50:30 -080074 protected final Context mContext;
Jason Monk421a9412017-02-06 09:15:21 -080075 private final StatusBarWindowManager mStatusBarWindowManager;
Lucas Dupin15a6b6c2018-04-16 14:50:20 +080076 private final BouncerExpansionCallback mExpansionCallback = new BouncerExpansionCallback() {
77 @Override
78 public void onFullyShown() {
79 updateStates();
80 }
81
82 @Override
83 public void onFullyHidden() {
84 updateStates();
85 }
86 };
Jorim Jaggi5cf17872014-03-26 18:31:48 +010087
Xiyuan Xia1b30f792016-01-06 08:50:30 -080088 protected LockPatternUtils mLockPatternUtils;
89 protected ViewMediatorCallback mViewMediatorCallback;
Jason Monk2a6ea9c2017-01-26 11:14:51 -050090 protected StatusBar mStatusBar;
Lucas Dupinbc9aac12018-03-04 20:18:15 -080091 private NotificationPanelView mNotificationPanelView;
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -070092 private FingerprintUnlockController mFingerprintUnlockController;
Jorim Jaggi5cf17872014-03-26 18:31:48 +010093
Jorim Jaggi5cf17872014-03-26 18:31:48 +010094 private ViewGroup mContainer;
Jorim Jaggi5cf17872014-03-26 18:31:48 +010095
Xiyuan Xia1b30f792016-01-06 08:50:30 -080096 protected KeyguardBouncer mBouncer;
97 protected boolean mShowing;
98 protected boolean mOccluded;
99 protected boolean mRemoteInputActive;
Adrian Roos087826a2017-04-19 16:59:09 -0700100 private boolean mDozing;
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100101
Xiyuan Xia1b30f792016-01-06 08:50:30 -0800102 protected boolean mFirstUpdate = true;
103 protected boolean mLastShowing;
104 protected boolean mLastOccluded;
Adrian Roosb6011622014-05-14 15:52:53 +0200105 private boolean mLastBouncerShowing;
106 private boolean mLastBouncerDismissible;
Xiyuan Xia1b30f792016-01-06 08:50:30 -0800107 protected boolean mLastRemoteInputActive;
Adrian Roos087826a2017-04-19 16:59:09 -0700108 private boolean mLastDozing;
Jorim Jaggif5304ad2017-07-17 18:31:13 +0200109 private int mLastFpMode;
Lucas Dupin16cfe452018-02-08 13:14:50 -0800110 private boolean mGoingToSleepVisibleNotOccluded;
Adrian Roosd28ccd72016-01-06 15:23:14 +0100111
Jorim Jaggi746f7fa2014-08-27 17:52:46 +0200112 private OnDismissAction mAfterKeyguardGoneAction;
Jorim Jaggibcbe9482016-11-23 17:37:49 +0100113 private final ArrayList<Runnable> mAfterKeyguardGoneRunnables = new ArrayList<>();
Adrian Roosb6011622014-05-14 15:52:53 +0200114
Adrian Roosfee661c2017-08-04 17:05:45 +0200115 // Dismiss action to be launched when we stop dozing or the keyguard is gone.
Adrian Roos34e65402017-08-07 19:32:45 +0200116 private DismissWithActionRequest mPendingWakeupAction;
Adrian Roosfee661c2017-08-04 17:05:45 +0200117
Jorim Jaggia9d7fcd2017-05-18 01:08:12 +0200118 private final KeyguardUpdateMonitorCallback mUpdateMonitorCallback =
119 new KeyguardUpdateMonitorCallback() {
120 @Override
121 public void onEmergencyCallAction() {
122
123 // Since we won't get a setOccluded call we have to reset the view manually such that
124 // the bouncer goes away.
125 if (mOccluded) {
Lucas Dupin28f90292017-08-08 18:07:49 -0400126 reset(true /* hideBouncerWhenShowing */);
Jorim Jaggia9d7fcd2017-05-18 01:08:12 +0200127 }
128 }
129 };
130
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100131 public StatusBarKeyguardViewManager(Context context, ViewMediatorCallback callback,
132 LockPatternUtils lockPatternUtils) {
133 mContext = context;
134 mViewMediatorCallback = callback;
135 mLockPatternUtils = lockPatternUtils;
Jason Monk421a9412017-02-06 09:15:21 -0800136 mStatusBarWindowManager = Dependency.get(StatusBarWindowManager.class);
Jorim Jaggia9d7fcd2017-05-18 01:08:12 +0200137 KeyguardUpdateMonitor.getInstance(context).registerCallback(mUpdateMonitorCallback);
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100138 }
139
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500140 public void registerStatusBar(StatusBar statusBar,
Jason Monk421a9412017-02-06 09:15:21 -0800141 ViewGroup container,
Lucas Dupinbc9aac12018-03-04 20:18:15 -0800142 NotificationPanelView notificationPanelView,
Jorim Jaggi241ae102016-11-02 21:57:33 -0700143 FingerprintUnlockController fingerprintUnlockController,
144 DismissCallbackRegistry dismissCallbackRegistry) {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500145 mStatusBar = statusBar;
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100146 mContainer = container;
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700147 mFingerprintUnlockController = fingerprintUnlockController;
Xiyuan Xia1b30f792016-01-06 08:50:30 -0800148 mBouncer = SystemUIFactory.getInstance().createKeyguardBouncer(mContext,
Lucas Dupin15a6b6c2018-04-16 14:50:20 +0800149 mViewMediatorCallback, mLockPatternUtils, container, dismissCallbackRegistry,
150 mExpansionCallback);
Lucas Dupin4c2aa392018-03-28 18:00:45 -0700151 mContainer.addOnLayoutChangeListener(this::onContainerLayout);
Lucas Dupinbc9aac12018-03-04 20:18:15 -0800152 mNotificationPanelView = notificationPanelView;
153 notificationPanelView.setExpansionListener(this::onPanelExpansionChanged);
154 }
155
Lucas Dupin4c2aa392018-03-28 18:00:45 -0700156 private void onContainerLayout(View v, int left, int top, int right, int bottom,
157 int oldLeft, int oldTop, int oldRight, int oldBottom) {
158 mNotificationPanelView.setBouncerTop(mBouncer.getTop());
159 }
160
Lucas Dupinbc9aac12018-03-04 20:18:15 -0800161 private void onPanelExpansionChanged(float expansion, boolean tracking) {
Lucas Dupin6f0d71f2018-03-23 17:26:06 -0700162 // We don't want to translate the bounce when:
163 // • Keyguard is occluded, because we're in a FLAG_SHOW_WHEN_LOCKED activity and need to
164 // conserve the original animation.
165 // • The user quickly taps on the display and we show "swipe up to unlock."
166 // • Keyguard will be dismissed by an action. a.k.a: FLAG_DISMISS_KEYGUARD_ACTIVITY
jovanak5f6dc612018-03-27 11:59:22 -0700167 // • Full-screen user switcher is displayed.
Lucas Dupin6f0d71f2018-03-23 17:26:06 -0700168 if (mOccluded || mNotificationPanelView.isUnlockHintRunning()
jovanak5f6dc612018-03-27 11:59:22 -0700169 || mBouncer.willDismissWithAction()
170 || mStatusBar.isFullScreenUserSwitcherState()) {
Lucas Dupinbc9aac12018-03-04 20:18:15 -0800171 mBouncer.setExpansion(0);
172 } else if (mShowing && mStatusBar.isKeyguardCurrentlySecure() && !mDozing) {
173 mBouncer.setExpansion(expansion);
Lucas Dupind2ce46d2018-04-04 17:00:29 -0700174 if (expansion != 1 && tracking && !mBouncer.isShowing()
175 && !mBouncer.isAnimatingAway()) {
Lucas Dupin4c2aa392018-03-28 18:00:45 -0700176 mBouncer.show(false /* resetSecuritySelection */, false /* animated */);
Lucas Dupin3d565fa2018-03-20 15:40:14 -0700177 }
Lucas Dupinbc9aac12018-03-04 20:18:15 -0800178 }
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100179 }
180
181 /**
182 * Show the keyguard. Will handle creating and attaching to the view manager
183 * lazily.
184 */
185 public void show(Bundle options) {
Jorim Jaggi03c701e2014-04-02 12:39:51 +0200186 mShowing = true;
Jorim Jaggicff0acb2014-03-31 16:35:15 +0200187 mStatusBarWindowManager.setKeyguardShowing(true);
Jorim Jaggife762342016-10-13 14:33:27 +0200188 reset(true /* hideBouncerWhenShowing */);
Tej Singhdd7bd352018-02-09 19:33:15 -0800189 StatsLog.write(StatsLog.KEYGUARD_STATE_CHANGED,
190 StatsLog.KEYGUARD_STATE_CHANGED__STATE__SHOWN);
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100191 }
192
Jorim Jaggia005f1b2014-04-16 19:06:10 +0200193 /**
194 * Shows the notification keyguard or the bouncer depending on
195 * {@link KeyguardBouncer#needsFullscreenBouncer()}.
196 */
Jorim Jaggife762342016-10-13 14:33:27 +0200197 protected void showBouncerOrKeyguard(boolean hideBouncerWhenShowing) {
Adrian Roos41eecff2017-06-29 14:09:52 +0200198 if (mBouncer.needsFullscreenBouncer() && !mDozing) {
Jorim Jaggia005f1b2014-04-16 19:06:10 +0200199 // The keyguard might be showing (already). So we need to hide it.
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500200 mStatusBar.hideKeyguard();
Jorim Jaggi95e89ca2014-11-24 20:12:50 +0100201 mBouncer.show(true /* resetSecuritySelection */);
Jorim Jaggia005f1b2014-04-16 19:06:10 +0200202 } else {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500203 mStatusBar.showKeyguard();
Jorim Jaggife762342016-10-13 14:33:27 +0200204 if (hideBouncerWhenShowing) {
Adrian Roosfee661c2017-08-04 17:05:45 +0200205 hideBouncer(false /* destroyView */);
Jorim Jaggife762342016-10-13 14:33:27 +0200206 mBouncer.prepare();
207 }
Jorim Jaggia005f1b2014-04-16 19:06:10 +0200208 }
Adrian Roos61676aa2017-08-03 16:24:32 +0200209 updateStates();
Jorim Jaggia005f1b2014-04-16 19:06:10 +0200210 }
211
Lucas Dupin3c9df5a2018-02-27 11:32:16 -0800212 private void hideBouncer(boolean destroyView) {
Adrian Roosfee661c2017-08-04 17:05:45 +0200213 mBouncer.hide(destroyView);
Adrian Roos34e65402017-08-07 19:32:45 +0200214 cancelPendingWakeupAction();
Adrian Roosfee661c2017-08-04 17:05:45 +0200215 }
216
Lucas Dupin0df9b7a2018-03-15 17:53:17 -0700217 public void showBouncer(boolean animated) {
Adrian Roos0002a452014-07-03 13:46:07 +0200218 if (mShowing) {
Lucas Dupin0df9b7a2018-03-15 17:53:17 -0700219 mBouncer.show(false /* resetSecuritySelection */, animated);
Dan Sandler3806c772014-05-08 14:52:10 -0400220 }
Jorim Jaggi4222d9a2014-04-23 16:13:15 +0200221 updateStates();
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100222 }
223
Jorim Jaggid9449862015-05-29 14:49:08 -0700224 public void dismissWithAction(OnDismissAction r, Runnable cancelAction,
225 boolean afterKeyguardGone) {
Lucas Dupinc80c67e2017-12-04 14:29:10 -0800226 dismissWithAction(r, cancelAction, afterKeyguardGone, null /* message */);
227 }
228
229 public void dismissWithAction(OnDismissAction r, Runnable cancelAction,
230 boolean afterKeyguardGone, String message) {
Adrian Roos0002a452014-07-03 13:46:07 +0200231 if (mShowing) {
Adrian Roos34e65402017-08-07 19:32:45 +0200232 cancelPendingWakeupAction();
Adrian Roosfee661c2017-08-04 17:05:45 +0200233 // If we're dozing, this needs to be delayed until after we wake up - unless we're
234 // wake-and-unlocking, because there dozing will last until the end of the transition.
235 if (mDozing && !isWakeAndUnlocking()) {
Adrian Roos34e65402017-08-07 19:32:45 +0200236 mPendingWakeupAction = new DismissWithActionRequest(
Lucas Dupinc80c67e2017-12-04 14:29:10 -0800237 r, cancelAction, afterKeyguardGone, message);
Adrian Roosfee661c2017-08-04 17:05:45 +0200238 return;
239 }
240
Jorim Jaggi746f7fa2014-08-27 17:52:46 +0200241 if (!afterKeyguardGone) {
Jorim Jaggid9449862015-05-29 14:49:08 -0700242 mBouncer.showWithDismissAction(r, cancelAction);
Jorim Jaggi746f7fa2014-08-27 17:52:46 +0200243 } else {
Jorim Jaggi746f7fa2014-08-27 17:52:46 +0200244 mAfterKeyguardGoneAction = r;
Jorim Jaggi8d5a6e72016-11-02 21:57:33 -0700245 mBouncer.show(false /* resetSecuritySelection */);
Jorim Jaggi746f7fa2014-08-27 17:52:46 +0200246 }
Adrian Roos7d7090d2014-05-21 13:10:23 +0200247 }
248 updateStates();
249 }
250
Adrian Roosfee661c2017-08-04 17:05:45 +0200251 private boolean isWakeAndUnlocking() {
252 int mode = mFingerprintUnlockController.getMode();
253 return mode == MODE_WAKE_AND_UNLOCK || mode == MODE_WAKE_AND_UNLOCK_PULSING;
254 }
255
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100256 /**
Jorim Jaggibcbe9482016-11-23 17:37:49 +0100257 * Adds a {@param runnable} to be executed after Keyguard is gone.
258 */
259 public void addAfterKeyguardGoneRunnable(Runnable runnable) {
260 mAfterKeyguardGoneRunnables.add(runnable);
261 }
262
263 /**
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100264 * Reset the state of the view.
265 */
Jorim Jaggife762342016-10-13 14:33:27 +0200266 public void reset(boolean hideBouncerWhenShowing) {
Jorim Jaggi43bdbbd2014-05-09 16:05:53 +0200267 if (mShowing) {
Adrian Roos7a56d1a2017-08-04 15:04:43 +0200268 if (mOccluded && !mDozing) {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500269 mStatusBar.hideKeyguard();
Adrian Roos91ffdc42017-08-04 18:14:41 +0200270 if (hideBouncerWhenShowing || mBouncer.needsFullscreenBouncer()) {
271 hideBouncer(false /* destroyView */);
272 }
Jorim Jaggi43bdbbd2014-05-09 16:05:53 +0200273 } else {
Jorim Jaggife762342016-10-13 14:33:27 +0200274 showBouncerOrKeyguard(hideBouncerWhenShowing);
Jorim Jaggi43bdbbd2014-05-09 16:05:53 +0200275 }
Selim Cinek1fcafc42015-07-20 14:39:25 -0700276 KeyguardUpdateMonitor.getInstance(mContext).sendKeyguardReset();
Jorim Jaggi43bdbbd2014-05-09 16:05:53 +0200277 updateStates();
Dan Sandler3806c772014-05-08 14:52:10 -0400278 }
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100279 }
280
Lucas Dupin16cfe452018-02-08 13:14:50 -0800281 public boolean isGoingToSleepVisibleNotOccluded() {
282 return mGoingToSleepVisibleNotOccluded;
283 }
284
Jorim Jaggi18f18ae2015-09-10 15:48:21 -0700285 public void onStartedGoingToSleep() {
Lucas Dupin16cfe452018-02-08 13:14:50 -0800286 mGoingToSleepVisibleNotOccluded = isShowing() && !isOccluded();
Jorim Jaggi18f18ae2015-09-10 15:48:21 -0700287 }
288
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700289 public void onFinishedGoingToSleep() {
Lucas Dupin16cfe452018-02-08 13:14:50 -0800290 mGoingToSleepVisibleNotOccluded = false;
Jorim Jaggi03c701e2014-04-02 12:39:51 +0200291 mBouncer.onScreenTurnedOff();
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100292 }
293
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700294 public void onStartedWakingUp() {
Adrian Roos731d4df2017-07-18 15:10:39 +0200295 // TODO: remove
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100296 }
297
Jorim Jaggi93739112015-08-13 15:53:14 -0700298 public void onScreenTurningOn() {
Adrian Roos731d4df2017-07-18 15:10:39 +0200299 // TODO: remove
Selim Cinek372d1bd2015-08-14 13:19:37 -0700300 }
301
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700302 public void onScreenTurnedOn() {
Lucas Dupin9e3fa102017-11-08 17:16:55 -0800303 // TODO: remove
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700304 }
305
Adrian Roosd28ccd72016-01-06 15:23:14 +0100306 @Override
307 public void onRemoteInputActive(boolean active) {
308 mRemoteInputActive = active;
309 updateStates();
310 }
311
Adrian Roos087826a2017-04-19 16:59:09 -0700312 public void setDozing(boolean dozing) {
Adrian Roos41eecff2017-06-29 14:09:52 +0200313 if (mDozing != dozing) {
314 mDozing = dozing;
Adrian Roos61676aa2017-08-03 16:24:32 +0200315 if (dozing || mBouncer.needsFullscreenBouncer() || mOccluded) {
316 reset(dozing /* hideBouncerWhenShowing */);
317 }
Adrian Roos41eecff2017-06-29 14:09:52 +0200318 updateStates();
Adrian Roosfee661c2017-08-04 17:05:45 +0200319
320 if (!dozing) {
Adrian Roos34e65402017-08-07 19:32:45 +0200321 launchPendingWakeupAction();
Adrian Roosfee661c2017-08-04 17:05:45 +0200322 }
Adrian Roos41eecff2017-06-29 14:09:52 +0200323 }
Adrian Roos087826a2017-04-19 16:59:09 -0700324 }
325
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700326 public void onScreenTurnedOff() {
Lucas Dupin9e3fa102017-11-08 17:16:55 -0800327 // TODO: remove
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700328 }
329
330 public void notifyDeviceWakeUpRequested() {
Adrian Roos731d4df2017-07-18 15:10:39 +0200331 // TODO: remove
Selim Cinekf8fbc2a72015-06-22 16:42:07 -0400332 }
333
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100334 public void setNeedsInput(boolean needsInput) {
Jorim Jaggicff0acb2014-03-31 16:35:15 +0200335 mStatusBarWindowManager.setKeyguardNeedsInput(needsInput);
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100336 }
337
Adrian Roosd5c2db62016-03-08 16:11:31 -0800338 public boolean isUnlockWithWallpaper() {
339 return mStatusBarWindowManager.isShowingWallpaper();
340 }
341
Jorim Jaggi6626f542016-08-22 13:08:44 -0700342 public void setOccluded(boolean occluded, boolean animate) {
Selim Cinek3a49ba22017-08-10 11:17:39 -0700343 mStatusBar.setOccluded(occluded);
Selim Cinekbaa23272014-07-08 18:01:07 +0200344 if (occluded && !mOccluded && mShowing) {
Tej Singhdd7bd352018-02-09 19:33:15 -0800345 StatsLog.write(StatsLog.KEYGUARD_STATE_CHANGED,
346 StatsLog.KEYGUARD_STATE_CHANGED__STATE__OCCLUDED);
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500347 if (mStatusBar.isInLaunchTransition()) {
Selim Cinekbaa23272014-07-08 18:01:07 +0200348 mOccluded = true;
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500349 mStatusBar.fadeKeyguardAfterLaunchTransition(null /* beforeFading */,
Selim Cinekbaa23272014-07-08 18:01:07 +0200350 new Runnable() {
351 @Override
352 public void run() {
Jorim Jaggi826730a2014-12-08 21:05:13 +0100353 mStatusBarWindowManager.setKeyguardOccluded(mOccluded);
Jorim Jaggife762342016-10-13 14:33:27 +0200354 reset(true /* hideBouncerWhenShowing */);
Selim Cinekbaa23272014-07-08 18:01:07 +0200355 }
356 });
357 return;
358 }
Tej Singhdd7bd352018-02-09 19:33:15 -0800359 } else if (!occluded && mOccluded && mShowing) {
360 StatsLog.write(StatsLog.KEYGUARD_STATE_CHANGED,
361 StatsLog.KEYGUARD_STATE_CHANGED__STATE__SHOWN);
Selim Cinekbaa23272014-07-08 18:01:07 +0200362 }
Lucas Dupin28f90292017-08-08 18:07:49 -0400363 boolean isOccluding = !mOccluded && occluded;
Jorim Jaggia6310292014-04-16 14:11:52 +0200364 mOccluded = occluded;
Adrian Roos909fe2d2016-10-12 12:03:24 -0700365 if (mShowing) {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500366 mStatusBar.updateMediaMetaData(false, animate && !occluded);
Adrian Roos909fe2d2016-10-12 12:03:24 -0700367 }
Jorim Jaggicff0acb2014-03-31 16:35:15 +0200368 mStatusBarWindowManager.setKeyguardOccluded(occluded);
Jorim Jaggife762342016-10-13 14:33:27 +0200369
Adrian Roos7a56d1a2017-08-04 15:04:43 +0200370 // setDozing(false) will call reset once we stop dozing.
371 if (!mDozing) {
372 // If Keyguard is reshown, don't hide the bouncer as it might just have been requested
373 // by a FLAG_DISMISS_KEYGUARD_ACTIVITY.
Lucas Dupin28f90292017-08-08 18:07:49 -0400374 reset(isOccluding /* hideBouncerWhenShowing*/);
Adrian Roos7a56d1a2017-08-04 15:04:43 +0200375 }
Adrian Roos909fe2d2016-10-12 12:03:24 -0700376 if (animate && !occluded && mShowing) {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500377 mStatusBar.animateKeyguardUnoccluding();
Jorim Jaggi6626f542016-08-22 13:08:44 -0700378 }
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100379 }
380
Dan Sandler4b22bdf2014-06-05 00:58:02 -0400381 public boolean isOccluded() {
382 return mOccluded;
383 }
384
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100385 /**
Jorim Jaggi76a16232014-08-08 17:00:47 +0200386 * Starts the animation before we dismiss Keyguard, i.e. an disappearing animation on the
387 * security view of the bouncer.
388 *
Jorim Jaggi8de4311c2014-08-11 22:36:20 +0200389 * @param finishRunnable the runnable to be run after the animation finished, or {@code null} if
390 * no action should be run
Jorim Jaggi76a16232014-08-08 17:00:47 +0200391 */
392 public void startPreHideAnimation(Runnable finishRunnable) {
393 if (mBouncer.isShowing()) {
394 mBouncer.startPreHideAnimation(finishRunnable);
Lucas Dupin93752552018-03-19 21:32:19 -0700395 mNotificationPanelView.onBouncerPreHideAnimation();
Jorim Jaggi8de4311c2014-08-11 22:36:20 +0200396 } else if (finishRunnable != null) {
Jorim Jaggi76a16232014-08-08 17:00:47 +0200397 finishRunnable.run();
398 }
399 }
400
401 /**
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100402 * Hides the keyguard view
403 */
Jorim Jaggie8fde5d2016-06-30 23:41:37 -0700404 public void hide(long startTime, long fadeoutDuration) {
Jorim Jaggi03c701e2014-04-02 12:39:51 +0200405 mShowing = false;
Adrian Roos34e65402017-08-07 19:32:45 +0200406 launchPendingWakeupAction();
Jorim Jaggi44cf9192014-06-17 19:16:00 -0700407
Jorim Jaggi031f7952016-09-01 16:39:26 -0700408 if (KeyguardUpdateMonitor.getInstance(mContext).needsSlowUnlockTransition()) {
Jorim Jaggie8fde5d2016-06-30 23:41:37 -0700409 fadeoutDuration = KEYGUARD_DISMISS_DURATION_LOCKED;
410 }
Jorim Jaggie29b2db2014-05-30 23:17:03 +0200411 long uptimeMillis = SystemClock.uptimeMillis();
Jorim Jaggi76a16232014-08-08 17:00:47 +0200412 long delay = Math.max(0, startTime + HIDE_TIMING_CORRECTION_MS - uptimeMillis);
Selim Cinekbaa23272014-07-08 18:01:07 +0200413
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500414 if (mStatusBar.isInLaunchTransition() ) {
415 mStatusBar.fadeKeyguardAfterLaunchTransition(new Runnable() {
Selim Cinekbaa23272014-07-08 18:01:07 +0200416 @Override
417 public void run() {
418 mStatusBarWindowManager.setKeyguardShowing(false);
419 mStatusBarWindowManager.setKeyguardFadingAway(true);
Adrian Roosfee661c2017-08-04 17:05:45 +0200420 hideBouncer(true /* destroyView */);
Selim Cinekbaa23272014-07-08 18:01:07 +0200421 updateStates();
Selim Cinekbaa23272014-07-08 18:01:07 +0200422 }
423 }, new Runnable() {
424 @Override
425 public void run() {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500426 mStatusBar.hideKeyguard();
Selim Cinekbaa23272014-07-08 18:01:07 +0200427 mStatusBarWindowManager.setKeyguardFadingAway(false);
428 mViewMediatorCallback.keyguardGone();
Jorim Jaggi746f7fa2014-08-27 17:52:46 +0200429 executeAfterKeyguardGoneAction();
Selim Cinekbaa23272014-07-08 18:01:07 +0200430 }
431 });
432 } else {
Jorim Jaggi8d5a6e72016-11-02 21:57:33 -0700433 executeAfterKeyguardGoneAction();
Jorim Jaggie93698b2016-11-11 18:24:38 -0800434 boolean wakeUnlockPulsing =
435 mFingerprintUnlockController.getMode() == MODE_WAKE_AND_UNLOCK_PULSING;
436 if (wakeUnlockPulsing) {
437 delay = 0;
438 fadeoutDuration = 240;
439 }
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500440 mStatusBar.setKeyguardFadingAway(startTime, delay, fadeoutDuration);
Jorim Jaggie93698b2016-11-11 18:24:38 -0800441 mFingerprintUnlockController.startKeyguardFadingAway();
Adrian Roosfee661c2017-08-04 17:05:45 +0200442 hideBouncer(true /* destroyView */);
Jorim Jaggie93698b2016-11-11 18:24:38 -0800443 if (wakeUnlockPulsing) {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500444 mStatusBar.fadeKeyguardWhilePulsing();
Lucas Dupin9e3fa102017-11-08 17:16:55 -0800445 wakeAndUnlockDejank();
Jorim Jaggidbc3dce2014-08-01 01:16:36 +0200446 } else {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500447 boolean staying = mStatusBar.hideKeyguard();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700448 if (!staying) {
449 mStatusBarWindowManager.setKeyguardFadingAway(true);
Lucas Dupin9e3fa102017-11-08 17:16:55 -0800450 wakeAndUnlockDejank();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700451 } else {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500452 mStatusBar.finishKeyguardFadingAway();
Adrian Roos88e61aa2017-05-23 16:16:50 -0700453 mFingerprintUnlockController.finishKeyguardFadingAway();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700454 }
Jorim Jaggidbc3dce2014-08-01 01:16:36 +0200455 }
Jorim Jaggi67b29d52017-06-09 18:00:00 -0700456 updateStates();
Selim Cinekbaa23272014-07-08 18:01:07 +0200457 mStatusBarWindowManager.setKeyguardShowing(false);
Selim Cinekbaa23272014-07-08 18:01:07 +0200458 mViewMediatorCallback.keyguardGone();
Jorim Jaggie29b2db2014-05-30 23:17:03 +0200459 }
Tej Singhdd7bd352018-02-09 19:33:15 -0800460 StatsLog.write(StatsLog.KEYGUARD_STATE_CHANGED,
461 StatsLog.KEYGUARD_STATE_CHANGED__STATE__HIDDEN);
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100462 }
463
Selim Cinekaa8bbf12016-05-04 14:13:20 -0700464 public void onDensityOrFontScaleChanged() {
Adrian Roosfee661c2017-08-04 17:05:45 +0200465 hideBouncer(true /* destroyView */);
Selim Cinekaa8bbf12016-05-04 14:13:20 -0700466 }
467
Lucas Dupin8c51ce22017-11-21 13:21:05 -0800468 public void onThemeChanged() {
Adrian Roosfee661c2017-08-04 17:05:45 +0200469 hideBouncer(true /* destroyView */);
Lucas Dupinf190a852017-07-31 17:11:26 -0700470 mBouncer.prepare();
Lucas Dupin89516d42017-07-05 13:29:18 -0700471 }
472
Lucas Dupin9e3fa102017-11-08 17:16:55 -0800473 public void onKeyguardFadedAway() {
474 mContainer.postDelayed(() -> mStatusBarWindowManager.setKeyguardFadingAway(false),
475 100);
476 mStatusBar.finishKeyguardFadingAway();
477 mFingerprintUnlockController.finishKeyguardFadingAway();
478 WindowManagerGlobal.getInstance().trimMemory(
479 ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN);
480
Jorim Jaggi90978852015-08-18 19:55:53 -0700481 }
482
Lucas Dupin9e3fa102017-11-08 17:16:55 -0800483 private void wakeAndUnlockDejank() {
Jorim Jaggi8adb30c2016-09-13 15:02:22 -0700484 if (mFingerprintUnlockController.getMode() == MODE_WAKE_AND_UNLOCK
485 && LatencyTracker.isEnabled(mContext)) {
486 DejankUtils.postAfterTraversal(() ->
487 LatencyTracker.getInstance(mContext).onActionEnd(
488 LatencyTracker.ACTION_FINGERPRINT_WAKE_AND_UNLOCK));
489 }
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700490 }
491
Jorim Jaggi746f7fa2014-08-27 17:52:46 +0200492 private void executeAfterKeyguardGoneAction() {
493 if (mAfterKeyguardGoneAction != null) {
494 mAfterKeyguardGoneAction.onDismiss();
495 mAfterKeyguardGoneAction = null;
496 }
Jorim Jaggibcbe9482016-11-23 17:37:49 +0100497 for (int i = 0; i < mAfterKeyguardGoneRunnables.size(); i++) {
498 mAfterKeyguardGoneRunnables.get(i).run();
499 }
500 mAfterKeyguardGoneRunnables.clear();
Jorim Jaggi746f7fa2014-08-27 17:52:46 +0200501 }
502
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100503 /**
504 * Dismisses the keyguard by going to the next screen or making it gone.
505 */
Jorim Jaggi8d5a6e72016-11-02 21:57:33 -0700506 public void dismissAndCollapse() {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500507 mStatusBar.executeRunnableDismissingKeyguard(null, null, true, false, true);
Jorim Jaggi8d5a6e72016-11-02 21:57:33 -0700508 }
509
Christoph Studer2231c6e2014-12-19 12:40:13 +0100510 /**
511 * WARNING: This method might cause Binder calls.
512 */
Jorim Jaggi15682502014-04-23 12:01:36 +0200513 public boolean isSecure() {
514 return mBouncer.isSecure();
515 }
516
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100517 /**
518 * @return Whether the keyguard is showing
519 */
520 public boolean isShowing() {
Jorim Jaggi03c701e2014-04-02 12:39:51 +0200521 return mShowing;
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100522 }
Jorim Jaggie5c7a892014-04-10 20:37:32 +0200523
524 /**
525 * Notifies this manager that the back button has been pressed.
526 *
Lucas Dupin3f54fe22018-04-08 23:17:40 -0700527 * @param hideImmediately Hide bouncer when {@code true}, keep it around otherwise.
528 * Non-scrimmed bouncers have a special animation tied to the expansion
529 * of the notification panel.
Jorim Jaggie5c7a892014-04-10 20:37:32 +0200530 * @return whether the back press has been handled
531 */
Lucas Dupin3f54fe22018-04-08 23:17:40 -0700532 public boolean onBackPressed(boolean hideImmediately) {
Jorim Jaggie5c7a892014-04-10 20:37:32 +0200533 if (mBouncer.isShowing()) {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500534 mStatusBar.endAffordanceLaunch();
Lucas Dupin3f54fe22018-04-08 23:17:40 -0700535 reset(hideImmediately);
Jorim Jaggie5c7a892014-04-10 20:37:32 +0200536 return true;
537 }
538 return false;
539 }
540
Jim Millerf41fc962014-06-18 16:33:51 -0700541 public boolean isBouncerShowing() {
542 return mBouncer.isShowing();
543 }
544
Jorim Jaggi416493b2014-09-13 03:57:32 +0200545 private long getNavBarShowDelay() {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500546 if (mStatusBar.isKeyguardFadingAway()) {
547 return mStatusBar.getKeyguardFadingAwayDelay();
Adrian Roos087826a2017-04-19 16:59:09 -0700548 } else if (mBouncer.isShowing()) {
Jorim Jaggi416493b2014-09-13 03:57:32 +0200549 return NAV_BAR_SHOW_DELAY_BOUNCER;
Adrian Roos087826a2017-04-19 16:59:09 -0700550 } else {
551 // No longer dozing, or remote input is active. No delay.
552 return 0;
Jorim Jaggi416493b2014-09-13 03:57:32 +0200553 }
554 }
555
556 private Runnable mMakeNavigationBarVisibleRunnable = new Runnable() {
557 @Override
558 public void run() {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500559 mStatusBar.getNavigationBarView().getRootView().setVisibility(View.VISIBLE);
Jorim Jaggi416493b2014-09-13 03:57:32 +0200560 }
561 };
562
Xiyuan Xia1b30f792016-01-06 08:50:30 -0800563 protected void updateStates() {
Jorim Jaggie5c7a892014-04-10 20:37:32 +0200564 int vis = mContainer.getSystemUiVisibility();
Adrian Roosb6011622014-05-14 15:52:53 +0200565 boolean showing = mShowing;
566 boolean occluded = mOccluded;
567 boolean bouncerShowing = mBouncer.isShowing();
Jorim Jaggi95e89ca2014-11-24 20:12:50 +0100568 boolean bouncerDismissible = !mBouncer.isFullscreenBouncer();
Adrian Roosd28ccd72016-01-06 15:23:14 +0100569 boolean remoteInputActive = mRemoteInputActive;
Adrian Roosb6011622014-05-14 15:52:53 +0200570
Adrian Roosd28ccd72016-01-06 15:23:14 +0100571 if ((bouncerDismissible || !showing || remoteInputActive) !=
572 (mLastBouncerDismissible || !mLastShowing || mLastRemoteInputActive)
Adrian Roosb6011622014-05-14 15:52:53 +0200573 || mFirstUpdate) {
Adrian Roosd28ccd72016-01-06 15:23:14 +0100574 if (bouncerDismissible || !showing || remoteInputActive) {
Adrian Roosb6011622014-05-14 15:52:53 +0200575 mContainer.setSystemUiVisibility(vis & ~View.STATUS_BAR_DISABLE_BACK);
Jason Monk1e68fb32014-05-02 16:06:20 -0400576 } else {
Adrian Roosb6011622014-05-14 15:52:53 +0200577 mContainer.setSystemUiVisibility(vis | View.STATUS_BAR_DISABLE_BACK);
Jason Monk1e68fb32014-05-02 16:06:20 -0400578 }
Jorim Jaggia6310292014-04-16 14:11:52 +0200579 }
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700580
Xiyuan Xia1b30f792016-01-06 08:50:30 -0800581 boolean navBarVisible = isNavBarVisible();
582 boolean lastNavBarVisible = getLastNavBarVisible();
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700583 if (navBarVisible != lastNavBarVisible || mFirstUpdate) {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500584 if (mStatusBar.getNavigationBarView() != null) {
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700585 if (navBarVisible) {
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700586 long delay = getNavBarShowDelay();
587 if (delay == 0) {
588 mMakeNavigationBarVisibleRunnable.run();
589 } else {
590 mContainer.postOnAnimationDelayed(mMakeNavigationBarVisibleRunnable,
591 delay);
592 }
Adrian Roosb6011622014-05-14 15:52:53 +0200593 } else {
Jorim Jaggi416493b2014-09-13 03:57:32 +0200594 mContainer.removeCallbacks(mMakeNavigationBarVisibleRunnable);
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500595 mStatusBar.getNavigationBarView().getRootView().setVisibility(View.GONE);
Adrian Roosb6011622014-05-14 15:52:53 +0200596 }
597 }
598 }
599
600 if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) {
601 mStatusBarWindowManager.setBouncerShowing(bouncerShowing);
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500602 mStatusBar.setBouncerShowing(bouncerShowing);
Adrian Roosb6011622014-05-14 15:52:53 +0200603 }
604
605 KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
606 if ((showing && !occluded) != (mLastShowing && !mLastOccluded) || mFirstUpdate) {
Jorim Jaggi6a15d522015-09-22 15:55:33 -0700607 updateMonitor.onKeyguardVisibilityChanged(showing && !occluded);
Adrian Roosb6011622014-05-14 15:52:53 +0200608 }
609 if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) {
610 updateMonitor.sendKeyguardBouncerChanged(bouncerShowing);
611 }
612
613 mFirstUpdate = false;
614 mLastShowing = showing;
615 mLastOccluded = occluded;
616 mLastBouncerShowing = bouncerShowing;
617 mLastBouncerDismissible = bouncerDismissible;
Adrian Roosd28ccd72016-01-06 15:23:14 +0100618 mLastRemoteInputActive = remoteInputActive;
Adrian Roos087826a2017-04-19 16:59:09 -0700619 mLastDozing = mDozing;
Jorim Jaggif5304ad2017-07-17 18:31:13 +0200620 mLastFpMode = mFingerprintUnlockController.getMode();
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500621 mStatusBar.onKeyguardViewManagerStatesUpdated();
Jorim Jaggie5c7a892014-04-10 20:37:32 +0200622 }
Jorim Jaggi8c8bcc12014-04-16 21:36:51 +0200623
Xiyuan Xia1b30f792016-01-06 08:50:30 -0800624 /**
625 * @return Whether the navigation bar should be made visible based on the current state.
626 */
627 protected boolean isNavBarVisible() {
Jorim Jaggif5304ad2017-07-17 18:31:13 +0200628 int fpMode = mFingerprintUnlockController.getMode();
629 boolean keyguardShowing = mShowing && !mOccluded;
630 boolean hideWhileDozing = mDozing && fpMode != MODE_WAKE_AND_UNLOCK_PULSING;
631 return (!keyguardShowing && !hideWhileDozing || mBouncer.isShowing()
Lucas Dupin9e3fa102017-11-08 17:16:55 -0800632 || mRemoteInputActive);
Xiyuan Xia1b30f792016-01-06 08:50:30 -0800633 }
634
635 /**
636 * @return Whether the navigation bar was made visible based on the last known state.
637 */
638 protected boolean getLastNavBarVisible() {
Jorim Jaggif5304ad2017-07-17 18:31:13 +0200639 boolean keyguardShowing = mLastShowing && !mLastOccluded;
640 boolean hideWhileDozing = mLastDozing && mLastFpMode != MODE_WAKE_AND_UNLOCK_PULSING;
641 return (!keyguardShowing && !hideWhileDozing || mLastBouncerShowing
Lucas Dupin9e3fa102017-11-08 17:16:55 -0800642 || mLastRemoteInputActive);
Xiyuan Xia1b30f792016-01-06 08:50:30 -0800643 }
644
Selim Cinek28540192016-02-19 17:25:08 -0800645 public boolean shouldDismissOnMenuPressed() {
646 return mBouncer.shouldDismissOnMenuPressed();
Jorim Jaggi8c8bcc12014-04-16 21:36:51 +0200647 }
Jorim Jaggidf993512014-05-13 23:06:35 +0200648
649 public boolean interceptMediaKey(KeyEvent event) {
650 return mBouncer.interceptMediaKey(event);
651 }
Jorim Jaggi8de4311c2014-08-11 22:36:20 +0200652
Jorim Jaggife762342016-10-13 14:33:27 +0200653 public void readyForKeyguardDone() {
654 mViewMediatorCallback.readyForKeyguardDone();
655 }
656
Jorim Jaggi84a3e7a2014-08-13 17:58:58 +0200657 public boolean shouldDisableWindowAnimationsForUnlock() {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500658 return mStatusBar.isInLaunchTransition();
Jorim Jaggi84a3e7a2014-08-13 17:58:58 +0200659 }
660
661 public boolean isGoingToNotificationShade() {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500662 return mStatusBar.isGoingToNotificationShade();
Jorim Jaggi84a3e7a2014-08-13 17:58:58 +0200663 }
Adrian Roos31b844b2014-11-21 13:55:09 +0100664
665 public boolean isSecure(int userId) {
666 return mBouncer.isSecure() || mLockPatternUtils.isSecure(userId);
667 }
Jim Millerab954542014-10-10 18:21:49 -0700668
Jorim Jaggi33ae80e2015-02-04 16:37:11 +0100669 public void keyguardGoingAway() {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500670 mStatusBar.keyguardGoingAway();
Jorim Jaggi33ae80e2015-02-04 16:37:11 +0100671 }
Jim Miller25d7e512015-03-03 17:12:09 -0800672
Jorim Jaggif3b3bee2015-04-16 14:57:34 -0700673 public void animateCollapsePanels(float speedUpFactor) {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500674 mStatusBar.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */,
Jorim Jaggif3b3bee2015-04-16 14:57:34 -0700675 false /* delayed */, speedUpFactor);
Jim Miller25d7e512015-03-03 17:12:09 -0800676 }
Jorim Jaggi5cc86592015-06-08 14:48:28 -0700677
678 /**
679 * Notifies that the user has authenticated by other means than using the bouncer, for example,
680 * fingerprint.
681 */
Jorim Jaggi25b4d4b2015-08-11 15:54:06 -0700682 public void notifyKeyguardAuthenticated(boolean strongAuth) {
683 mBouncer.notifyKeyguardAuthenticated(strongAuth);
Jorim Jaggi5cc86592015-06-08 14:48:28 -0700684 }
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700685
Selim Cinekcfafe4e2015-08-11 14:58:44 -0700686 public void showBouncerMessage(String message, int color) {
687 mBouncer.showMessage(message, color);
688 }
Jorim Jaggib774e552015-08-24 14:52:45 -0700689
690 public ViewRootImpl getViewRootImpl() {
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500691 return mStatusBar.getStatusBarView().getViewRootImpl();
Jorim Jaggib774e552015-08-24 14:52:45 -0700692 }
Adrian Roosfee661c2017-08-04 17:05:45 +0200693
Adrian Roos34e65402017-08-07 19:32:45 +0200694 public void launchPendingWakeupAction() {
695 DismissWithActionRequest request = mPendingWakeupAction;
696 mPendingWakeupAction = null;
Adrian Roosfee661c2017-08-04 17:05:45 +0200697 if (request != null) {
698 if (mShowing) {
699 dismissWithAction(request.dismissAction, request.cancelAction,
Lucas Dupinc80c67e2017-12-04 14:29:10 -0800700 request.afterKeyguardGone, request.message);
Adrian Roosfee661c2017-08-04 17:05:45 +0200701 } else if (request.dismissAction != null) {
702 request.dismissAction.onDismiss();
703 }
704 }
705 }
706
Adrian Roos34e65402017-08-07 19:32:45 +0200707 public void cancelPendingWakeupAction() {
708 DismissWithActionRequest request = mPendingWakeupAction;
709 mPendingWakeupAction = null;
Adrian Roosfee661c2017-08-04 17:05:45 +0200710 if (request != null && request.cancelAction != null) {
711 request.cancelAction.run();
712 }
713 }
714
Lucas Dupin6f0d71f2018-03-23 17:26:06 -0700715 public boolean willDismissWithAction() {
716 return mBouncer.willDismissWithAction();
717 }
718
Lucas Dupin15a6b6c2018-04-16 14:50:20 +0800719 public void dump(PrintWriter pw) {
720 pw.println("StatusBarKeyguardViewManager:");
721 pw.println(" mShowing: " + mShowing);
722 pw.println(" mOccluded: " + mOccluded);
723 pw.println(" mRemoteInputActive: " + mRemoteInputActive);
724 pw.println(" mDozing: " + mDozing);
725 pw.println(" mGoingToSleepVisibleNotOccluded: " + mGoingToSleepVisibleNotOccluded);
726 pw.println(" mAfterKeyguardGoneAction: " + mAfterKeyguardGoneAction);
727 pw.println(" mAfterKeyguardGoneRunnables: " + mAfterKeyguardGoneRunnables);
728 pw.println(" mPendingWakeupAction: " + mPendingWakeupAction);
729
730 if (mBouncer != null) {
731 mBouncer.dump(pw);
732 }
733 }
734
Adrian Roos34e65402017-08-07 19:32:45 +0200735 private static class DismissWithActionRequest {
Adrian Roosfee661c2017-08-04 17:05:45 +0200736 final OnDismissAction dismissAction;
737 final Runnable cancelAction;
738 final boolean afterKeyguardGone;
Lucas Dupinc80c67e2017-12-04 14:29:10 -0800739 final String message;
Adrian Roosfee661c2017-08-04 17:05:45 +0200740
Adrian Roos34e65402017-08-07 19:32:45 +0200741 DismissWithActionRequest(OnDismissAction dismissAction, Runnable cancelAction,
Lucas Dupinc80c67e2017-12-04 14:29:10 -0800742 boolean afterKeyguardGone, String message) {
Adrian Roosfee661c2017-08-04 17:05:45 +0200743 this.dismissAction = dismissAction;
744 this.cancelAction = cancelAction;
745 this.afterKeyguardGone = afterKeyguardGone;
Lucas Dupinc80c67e2017-12-04 14:29:10 -0800746 this.message = message;
Adrian Roosfee661c2017-08-04 17:05:45 +0200747 }
748 }
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100749}