Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.systemui.statusbar.phone; |
| 18 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 19 | import static com.android.systemui.plugins.ActivityStarter.OnDismissAction; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 20 | import static com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK; |
| 21 | import static com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK_PULSING; |
Jorim Jaggi | f5304ad | 2017-07-17 18:31:13 +0200 | [diff] [blame] | 22 | |
Jorim Jaggi | 786afcb | 2014-09-25 02:41:29 +0200 | [diff] [blame] | 23 | import android.content.ComponentCallbacks2; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 24 | import android.content.Context; |
Jason Chang | 1e4a4bd | 2018-05-22 17:30:19 +0800 | [diff] [blame] | 25 | import android.content.res.ColorStateList; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 26 | import android.os.Bundle; |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 27 | import android.os.SystemClock; |
Tej Singh | dd7bd35 | 2018-02-09 19:33:15 -0800 | [diff] [blame] | 28 | import android.util.StatsLog; |
Jorim Jaggi | df99351 | 2014-05-13 23:06:35 +0200 | [diff] [blame] | 29 | import android.view.KeyEvent; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 30 | import android.view.View; |
| 31 | import android.view.ViewGroup; |
Jorim Jaggi | b774e55 | 2015-08-24 14:52:45 -0700 | [diff] [blame] | 32 | import android.view.ViewRootImpl; |
Jorim Jaggi | 786afcb | 2014-09-25 02:41:29 +0200 | [diff] [blame] | 33 | import android.view.WindowManagerGlobal; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 34 | |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 35 | import com.android.internal.util.LatencyTracker; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 36 | import com.android.internal.widget.LockPatternUtils; |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 37 | import com.android.keyguard.KeyguardUpdateMonitor; |
Jorim Jaggi | a9d7fcd | 2017-05-18 01:08:12 +0200 | [diff] [blame] | 38 | import com.android.keyguard.KeyguardUpdateMonitorCallback; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 39 | import com.android.keyguard.ViewMediatorCallback; |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 40 | import com.android.settingslib.animation.AppearAnimationUtils; |
Jorim Jaggi | 8adb30c | 2016-09-13 15:02:22 -0700 | [diff] [blame] | 41 | import com.android.systemui.DejankUtils; |
Jason Monk | 421a941 | 2017-02-06 09:15:21 -0800 | [diff] [blame] | 42 | import com.android.systemui.Dependency; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 43 | import com.android.systemui.SystemUIFactory; |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 44 | import com.android.systemui.dock.DockManager; |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 45 | import com.android.systemui.keyguard.DismissCallbackRegistry; |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 46 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 47 | import com.android.systemui.shared.system.QuickStepContract; |
Jim Miller | 25d7e51 | 2015-03-03 17:12:09 -0800 | [diff] [blame] | 48 | import com.android.systemui.statusbar.CommandQueue; |
Lucas Dupin | 269feda | 2019-04-29 17:11:02 -0700 | [diff] [blame] | 49 | import com.android.systemui.statusbar.CrossFadeHelper; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 50 | import com.android.systemui.statusbar.NotificationMediaManager; |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 51 | import com.android.systemui.statusbar.RemoteInputController; |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 52 | import com.android.systemui.statusbar.StatusBarState; |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 53 | import com.android.systemui.statusbar.SysuiStatusBarStateController; |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 54 | import com.android.systemui.statusbar.phone.KeyguardBouncer.BouncerExpansionCallback; |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 55 | import com.android.systemui.statusbar.policy.ConfigurationController; |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 56 | import com.android.systemui.statusbar.policy.KeyguardMonitor; |
Evan Laird | 2d620fa | 2018-10-30 13:03:31 -0400 | [diff] [blame] | 57 | import com.android.systemui.statusbar.policy.KeyguardMonitorImpl; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 58 | |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 59 | import java.io.PrintWriter; |
Jorim Jaggi | bcbe948 | 2016-11-23 17:37:49 +0100 | [diff] [blame] | 60 | import java.util.ArrayList; |
| 61 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 62 | /** |
| 63 | * Manages creating, showing, hiding and resetting the keyguard within the status bar. Calls back |
| 64 | * via {@link ViewMediatorCallback} to poke the wake lock and report that the keyguard is done, |
| 65 | * which is in turn, reported to this class by the current |
| 66 | * {@link com.android.keyguard.KeyguardViewBase}. |
| 67 | */ |
Evan Laird | 878c853 | 2018-10-15 15:54:29 -0400 | [diff] [blame] | 68 | public class StatusBarKeyguardViewManager implements RemoteInputController.Callback, |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 69 | StatusBarStateController.StateListener, ConfigurationController.ConfigurationListener, |
Winson Chung | 1aa24b9 | 2019-04-24 15:17:33 -0700 | [diff] [blame] | 70 | NotificationPanelView.PanelExpansionListener, NavigationModeController.ModeChangedListener { |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 71 | |
| 72 | // When hiding the Keyguard with timing supplied from WindowManager, better be early than late. |
Jorim Jaggi | 56fd70c | 2016-10-27 19:57:08 -0700 | [diff] [blame] | 73 | private static final long HIDE_TIMING_CORRECTION_MS = - 16 * 3; |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 74 | |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 75 | // Delay for showing the navigation bar when the bouncer appears. This should be kept in sync |
| 76 | // with the appear animations of the PIN/pattern/password views. |
| 77 | private static final long NAV_BAR_SHOW_DELAY_BOUNCER = 320; |
| 78 | |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 79 | private static final long WAKE_AND_UNLOCK_SCRIM_FADEOUT_DURATION_MS = 200; |
| 80 | |
Jorim Jaggi | e8fde5d | 2016-06-30 23:41:37 -0700 | [diff] [blame] | 81 | // Duration of the Keyguard dismissal animation in case the user is currently locked. This is to |
| 82 | // make everything a bit slower to bridge a gap until the user is unlocked and home screen has |
| 83 | // dranw its first frame. |
| 84 | private static final long KEYGUARD_DISMISS_DURATION_LOCKED = 2000; |
| 85 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 86 | private static String TAG = "StatusBarKeyguardViewManager"; |
| 87 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 88 | protected final Context mContext; |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 89 | private final StatusBarWindowController mStatusBarWindowController; |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 90 | private final BouncerExpansionCallback mExpansionCallback = new BouncerExpansionCallback() { |
| 91 | @Override |
| 92 | public void onFullyShown() { |
| 93 | updateStates(); |
Lucas Dupin | 3cfd688 | 2019-03-19 15:22:03 -0700 | [diff] [blame] | 94 | mStatusBar.wakeUpIfDozing(SystemClock.uptimeMillis(), mContainer, "BOUNCER_VISIBLE"); |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 95 | updateLockIcon(); |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | @Override |
Lucas Dupin | 8499354 | 2018-10-11 19:23:45 -0700 | [diff] [blame] | 99 | public void onStartingToHide() { |
| 100 | updateStates(); |
| 101 | } |
| 102 | |
| 103 | @Override |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 104 | public void onStartingToShow() { |
| 105 | updateLockIcon(); |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 106 | } |
Lucas Dupin | 27321c4 | 2019-03-20 16:22:24 -0700 | [diff] [blame] | 107 | |
| 108 | @Override |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 109 | public void onFullyHidden() { |
| 110 | updateStates(); |
| 111 | updateLockIcon(); |
Lucas Dupin | 27321c4 | 2019-03-20 16:22:24 -0700 | [diff] [blame] | 112 | } |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 113 | }; |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 114 | private final DockManager.DockEventListener mDockEventListener = |
| 115 | new DockManager.DockEventListener() { |
| 116 | @Override |
| 117 | public void onEvent(int event) { |
| 118 | boolean isDocked = mDockManager.isDocked(); |
| 119 | if (isDocked == mIsDocked) { |
| 120 | return; |
| 121 | } |
| 122 | mIsDocked = isDocked; |
| 123 | updateStates(); |
| 124 | } |
| 125 | }; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 126 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 127 | protected LockPatternUtils mLockPatternUtils; |
| 128 | protected ViewMediatorCallback mViewMediatorCallback; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 129 | protected StatusBar mStatusBar; |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 130 | private NotificationPanelView mNotificationPanelView; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 131 | private BiometricUnlockController mBiometricUnlockController; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 132 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 133 | private ViewGroup mContainer; |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 134 | private ViewGroup mLockIconContainer; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 135 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 136 | protected KeyguardBouncer mBouncer; |
| 137 | protected boolean mShowing; |
| 138 | protected boolean mOccluded; |
| 139 | protected boolean mRemoteInputActive; |
Adrian Roos | 087826a | 2017-04-19 16:59:09 -0700 | [diff] [blame] | 140 | private boolean mDozing; |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 141 | private boolean mPulsing; |
| 142 | private boolean mGesturalNav; |
| 143 | private boolean mIsDocked; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 144 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 145 | protected boolean mFirstUpdate = true; |
| 146 | protected boolean mLastShowing; |
| 147 | protected boolean mLastOccluded; |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 148 | private boolean mLastBouncerShowing; |
| 149 | private boolean mLastBouncerDismissible; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 150 | protected boolean mLastRemoteInputActive; |
Adrian Roos | 087826a | 2017-04-19 16:59:09 -0700 | [diff] [blame] | 151 | private boolean mLastDozing; |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 152 | private boolean mLastGesturalNav; |
| 153 | private boolean mLastIsDocked; |
| 154 | private boolean mLastPulsing; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 155 | private int mLastBiometricMode; |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 156 | private boolean mGoingToSleepVisibleNotOccluded; |
Lucas Dupin | 269feda | 2019-04-29 17:11:02 -0700 | [diff] [blame] | 157 | private boolean mLastLockVisible; |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 158 | |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 159 | private OnDismissAction mAfterKeyguardGoneAction; |
Jorim Jaggi | bcbe948 | 2016-11-23 17:37:49 +0100 | [diff] [blame] | 160 | private final ArrayList<Runnable> mAfterKeyguardGoneRunnables = new ArrayList<>(); |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 161 | |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 162 | // Dismiss action to be launched when we stop dozing or the keyguard is gone. |
Adrian Roos | 34e6540 | 2017-08-07 19:32:45 +0200 | [diff] [blame] | 163 | private DismissWithActionRequest mPendingWakeupAction; |
Evan Laird | 2d620fa | 2018-10-30 13:03:31 -0400 | [diff] [blame] | 164 | private final KeyguardMonitorImpl mKeyguardMonitor = |
| 165 | (KeyguardMonitorImpl) Dependency.get(KeyguardMonitor.class); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 166 | private final NotificationMediaManager mMediaManager = |
| 167 | Dependency.get(NotificationMediaManager.class); |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 168 | private final StatusBarStateController mStatusBarStateController = |
| 169 | Dependency.get(StatusBarStateController.class); |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 170 | private final DockManager mDockManager; |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 171 | |
Jorim Jaggi | a9d7fcd | 2017-05-18 01:08:12 +0200 | [diff] [blame] | 172 | private final KeyguardUpdateMonitorCallback mUpdateMonitorCallback = |
| 173 | new KeyguardUpdateMonitorCallback() { |
| 174 | @Override |
| 175 | public void onEmergencyCallAction() { |
| 176 | |
| 177 | // Since we won't get a setOccluded call we have to reset the view manually such that |
| 178 | // the bouncer goes away. |
| 179 | if (mOccluded) { |
Lucas Dupin | 28f9029 | 2017-08-08 18:07:49 -0400 | [diff] [blame] | 180 | reset(true /* hideBouncerWhenShowing */); |
Jorim Jaggi | a9d7fcd | 2017-05-18 01:08:12 +0200 | [diff] [blame] | 181 | } |
| 182 | } |
| 183 | }; |
| 184 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 185 | public StatusBarKeyguardViewManager(Context context, ViewMediatorCallback callback, |
| 186 | LockPatternUtils lockPatternUtils) { |
| 187 | mContext = context; |
| 188 | mViewMediatorCallback = callback; |
| 189 | mLockPatternUtils = lockPatternUtils; |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 190 | mStatusBarWindowController = Dependency.get(StatusBarWindowController.class); |
Jorim Jaggi | a9d7fcd | 2017-05-18 01:08:12 +0200 | [diff] [blame] | 191 | KeyguardUpdateMonitor.getInstance(context).registerCallback(mUpdateMonitorCallback); |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 192 | mStatusBarStateController.addCallback(this); |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 193 | Dependency.get(ConfigurationController.class).addCallback(this); |
Lucas Dupin | be050b2 | 2019-05-02 16:38:33 -0700 | [diff] [blame] | 194 | mGesturalNav = QuickStepContract.isGesturalMode( |
Winson Chung | 1aa24b9 | 2019-04-24 15:17:33 -0700 | [diff] [blame] | 195 | Dependency.get(NavigationModeController.class).addListener(this)); |
Lucas Dupin | d93e95f | 2019-05-01 00:49:35 +0000 | [diff] [blame] | 196 | mDockManager = Dependency.get(DockManager.class); |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 197 | if (mDockManager != null) { |
| 198 | mDockManager.addListener(mDockEventListener); |
| 199 | mIsDocked = mDockManager.isDocked(); |
| 200 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 201 | } |
| 202 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 203 | public void registerStatusBar(StatusBar statusBar, |
Jason Monk | 421a941 | 2017-02-06 09:15:21 -0800 | [diff] [blame] | 204 | ViewGroup container, |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 205 | NotificationPanelView notificationPanelView, |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 206 | BiometricUnlockController biometricUnlockController, |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 207 | DismissCallbackRegistry dismissCallbackRegistry, |
| 208 | ViewGroup lockIconContainer) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 209 | mStatusBar = statusBar; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 210 | mContainer = container; |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 211 | mLockIconContainer = lockIconContainer; |
Lucas Dupin | 269feda | 2019-04-29 17:11:02 -0700 | [diff] [blame] | 212 | if (mLockIconContainer != null) { |
| 213 | mLastLockVisible = mLockIconContainer.getVisibility() == View.VISIBLE; |
| 214 | } |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 215 | mBiometricUnlockController = biometricUnlockController; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 216 | mBouncer = SystemUIFactory.getInstance().createKeyguardBouncer(mContext, |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 217 | mViewMediatorCallback, mLockPatternUtils, container, dismissCallbackRegistry, |
| 218 | mExpansionCallback); |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 219 | mNotificationPanelView = notificationPanelView; |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 220 | notificationPanelView.setExpansionListener(this); |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 221 | } |
| 222 | |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 223 | @Override |
| 224 | public void onPanelExpansionChanged(float expansion, boolean tracking) { |
Lucas Dupin | 6f0d71f | 2018-03-23 17:26:06 -0700 | [diff] [blame] | 225 | // We don't want to translate the bounce when: |
| 226 | // • Keyguard is occluded, because we're in a FLAG_SHOW_WHEN_LOCKED activity and need to |
| 227 | // conserve the original animation. |
| 228 | // • The user quickly taps on the display and we show "swipe up to unlock." |
| 229 | // • Keyguard will be dismissed by an action. a.k.a: FLAG_DISMISS_KEYGUARD_ACTIVITY |
jovanak | 5f6dc61 | 2018-03-27 11:59:22 -0700 | [diff] [blame] | 230 | // • Full-screen user switcher is displayed. |
Lucas Dupin | d7344dc | 2018-04-20 12:08:52 +0800 | [diff] [blame] | 231 | if (mNotificationPanelView.isUnlockHintRunning()) { |
Lucas Dupin | f9ca35e | 2018-05-16 20:41:35 -0700 | [diff] [blame] | 232 | mBouncer.setExpansion(KeyguardBouncer.EXPANSION_HIDDEN); |
Lucas Dupin | c516bac | 2018-06-19 10:50:04 -0700 | [diff] [blame] | 233 | } else if (bouncerNeedsScrimming()) { |
Lucas Dupin | f9ca35e | 2018-05-16 20:41:35 -0700 | [diff] [blame] | 234 | mBouncer.setExpansion(KeyguardBouncer.EXPANSION_VISIBLE); |
Lucas Dupin | 1c32743 | 2019-01-03 13:37:53 -0800 | [diff] [blame] | 235 | } else if (mShowing) { |
Lucas Dupin | aaac2cb | 2018-06-08 14:11:41 -0700 | [diff] [blame] | 236 | if (!isWakeAndUnlocking() && !mStatusBar.isInLaunchTransition()) { |
Lucas Dupin | 71dd484 | 2018-05-29 15:41:03 -0700 | [diff] [blame] | 237 | mBouncer.setExpansion(expansion); |
| 238 | } |
Lucas Dupin | f9ca35e | 2018-05-16 20:41:35 -0700 | [diff] [blame] | 239 | if (expansion != KeyguardBouncer.EXPANSION_HIDDEN && tracking |
| 240 | && mStatusBar.isKeyguardCurrentlySecure() |
Lucas Dupin | 52a9587 | 2018-04-20 10:28:07 +0800 | [diff] [blame] | 241 | && !mBouncer.isShowing() && !mBouncer.isAnimatingAway()) { |
Lucas Dupin | 71dd484 | 2018-05-29 15:41:03 -0700 | [diff] [blame] | 242 | mBouncer.show(false /* resetSecuritySelection */, false /* scrimmed */); |
Lucas Dupin | 3d565fa | 2018-03-20 15:40:14 -0700 | [diff] [blame] | 243 | } |
Lucas Dupin | f6a1f17 | 2019-04-18 20:57:40 -0700 | [diff] [blame] | 244 | } else if (mPulsing && expansion == KeyguardBouncer.EXPANSION_VISIBLE) { |
| 245 | // Panel expanded while pulsing but didn't translate the bouncer (because we are |
| 246 | // unlocked.) Let's simply wake-up to dismiss the lock screen. |
| 247 | mStatusBar.wakeUpIfDozing(SystemClock.uptimeMillis(), mContainer, "BOUNCER_VISIBLE"); |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 248 | } |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | @Override |
| 252 | public void onQsExpansionChanged(float expansion) { |
| 253 | updateLockIcon(); |
| 254 | } |
| 255 | |
| 256 | private void updateLockIcon() { |
Brad Stenning | 691c274 | 2019-04-19 11:48:00 -0700 | [diff] [blame] | 257 | // Not all form factors have a lock icon |
| 258 | if (mLockIconContainer == null) { |
| 259 | return; |
| 260 | } |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 261 | boolean keyguardWithoutQs = mStatusBarStateController.getState() == StatusBarState.KEYGUARD |
| 262 | && !mNotificationPanelView.isQsExpanded(); |
Lucas Dupin | 269feda | 2019-04-29 17:11:02 -0700 | [diff] [blame] | 263 | boolean lockVisible = (mBouncer.isShowing() || keyguardWithoutQs) |
| 264 | && !mBouncer.isAnimatingAway(); |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 265 | |
Lucas Dupin | 269feda | 2019-04-29 17:11:02 -0700 | [diff] [blame] | 266 | if (mLastLockVisible != lockVisible) { |
| 267 | mLastLockVisible = lockVisible; |
| 268 | if (lockVisible) { |
| 269 | CrossFadeHelper.fadeIn(mLockIconContainer, |
| 270 | AppearAnimationUtils.DEFAULT_APPEAR_DURATION /* duration */, |
| 271 | 0 /* delay */); |
| 272 | } else { |
| 273 | CrossFadeHelper.fadeOut(mLockIconContainer, |
| 274 | AppearAnimationUtils.DEFAULT_APPEAR_DURATION / 2 /* duration */, |
| 275 | 0 /* delay */, null /* runnable */); |
| 276 | } |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 277 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | /** |
| 281 | * Show the keyguard. Will handle creating and attaching to the view manager |
| 282 | * lazily. |
| 283 | */ |
| 284 | public void show(Bundle options) { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 285 | mShowing = true; |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 286 | mStatusBarWindowController.setKeyguardShowing(true); |
Evan Laird | 2d620fa | 2018-10-30 13:03:31 -0400 | [diff] [blame] | 287 | mKeyguardMonitor.notifyKeyguardState( |
| 288 | mShowing, mKeyguardMonitor.isSecure(), mKeyguardMonitor.isOccluded()); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 289 | reset(true /* hideBouncerWhenShowing */); |
Tej Singh | dd7bd35 | 2018-02-09 19:33:15 -0800 | [diff] [blame] | 290 | StatsLog.write(StatsLog.KEYGUARD_STATE_CHANGED, |
| 291 | StatsLog.KEYGUARD_STATE_CHANGED__STATE__SHOWN); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 292 | } |
| 293 | |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 294 | /** |
| 295 | * Shows the notification keyguard or the bouncer depending on |
| 296 | * {@link KeyguardBouncer#needsFullscreenBouncer()}. |
| 297 | */ |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 298 | protected void showBouncerOrKeyguard(boolean hideBouncerWhenShowing) { |
Adrian Roos | 41eecff | 2017-06-29 14:09:52 +0200 | [diff] [blame] | 299 | if (mBouncer.needsFullscreenBouncer() && !mDozing) { |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 300 | // The keyguard might be showing (already). So we need to hide it. |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 301 | mStatusBar.hideKeyguard(); |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 302 | mBouncer.show(true /* resetSecuritySelection */); |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 303 | } else { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 304 | mStatusBar.showKeyguard(); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 305 | if (hideBouncerWhenShowing) { |
Jian Jin | d1b6398 | 2018-05-21 15:20:40 -0700 | [diff] [blame] | 306 | hideBouncer(shouldDestroyViewOnReset() /* destroyView */); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 307 | mBouncer.prepare(); |
| 308 | } |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 309 | } |
Adrian Roos | 61676aa | 2017-08-03 16:24:32 +0200 | [diff] [blame] | 310 | updateStates(); |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 311 | } |
| 312 | |
Jian Jin | d1b6398 | 2018-05-21 15:20:40 -0700 | [diff] [blame] | 313 | protected boolean shouldDestroyViewOnReset() { |
| 314 | return false; |
| 315 | } |
| 316 | |
Lucas Dupin | 3c9df5a | 2018-02-27 11:32:16 -0800 | [diff] [blame] | 317 | private void hideBouncer(boolean destroyView) { |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 318 | if (mBouncer == null) { |
| 319 | return; |
| 320 | } |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 321 | mBouncer.hide(destroyView); |
Adrian Roos | 34e6540 | 2017-08-07 19:32:45 +0200 | [diff] [blame] | 322 | cancelPendingWakeupAction(); |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 323 | } |
| 324 | |
Lucas Dupin | f9ca35e | 2018-05-16 20:41:35 -0700 | [diff] [blame] | 325 | public void showBouncer(boolean scrimmed) { |
| 326 | if (mShowing && !mBouncer.isShowing()) { |
| 327 | mBouncer.show(false /* resetSecuritySelection */, scrimmed); |
Dan Sandler | 3806c77 | 2014-05-08 14:52:10 -0400 | [diff] [blame] | 328 | } |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 329 | updateStates(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 330 | } |
| 331 | |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 332 | public void dismissWithAction(OnDismissAction r, Runnable cancelAction, |
| 333 | boolean afterKeyguardGone) { |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 334 | dismissWithAction(r, cancelAction, afterKeyguardGone, null /* message */); |
| 335 | } |
| 336 | |
| 337 | public void dismissWithAction(OnDismissAction r, Runnable cancelAction, |
| 338 | boolean afterKeyguardGone, String message) { |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 339 | if (mShowing) { |
Adrian Roos | 34e6540 | 2017-08-07 19:32:45 +0200 | [diff] [blame] | 340 | cancelPendingWakeupAction(); |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 341 | // If we're dozing, this needs to be delayed until after we wake up - unless we're |
| 342 | // wake-and-unlocking, because there dozing will last until the end of the transition. |
| 343 | if (mDozing && !isWakeAndUnlocking()) { |
Adrian Roos | 34e6540 | 2017-08-07 19:32:45 +0200 | [diff] [blame] | 344 | mPendingWakeupAction = new DismissWithActionRequest( |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 345 | r, cancelAction, afterKeyguardGone, message); |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 346 | return; |
| 347 | } |
| 348 | |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 349 | if (!afterKeyguardGone) { |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 350 | mBouncer.showWithDismissAction(r, cancelAction); |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 351 | } else { |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 352 | mAfterKeyguardGoneAction = r; |
Jorim Jaggi | 8d5a6e7 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 353 | mBouncer.show(false /* resetSecuritySelection */); |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 354 | } |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 355 | } |
| 356 | updateStates(); |
| 357 | } |
| 358 | |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 359 | private boolean isWakeAndUnlocking() { |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 360 | int mode = mBiometricUnlockController.getMode(); |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 361 | return mode == MODE_WAKE_AND_UNLOCK || mode == MODE_WAKE_AND_UNLOCK_PULSING; |
| 362 | } |
| 363 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 364 | /** |
Jorim Jaggi | bcbe948 | 2016-11-23 17:37:49 +0100 | [diff] [blame] | 365 | * Adds a {@param runnable} to be executed after Keyguard is gone. |
| 366 | */ |
| 367 | public void addAfterKeyguardGoneRunnable(Runnable runnable) { |
| 368 | mAfterKeyguardGoneRunnables.add(runnable); |
| 369 | } |
| 370 | |
| 371 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 372 | * Reset the state of the view. |
| 373 | */ |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 374 | public void reset(boolean hideBouncerWhenShowing) { |
Jorim Jaggi | 43bdbbd | 2014-05-09 16:05:53 +0200 | [diff] [blame] | 375 | if (mShowing) { |
Adrian Roos | 7a56d1a | 2017-08-04 15:04:43 +0200 | [diff] [blame] | 376 | if (mOccluded && !mDozing) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 377 | mStatusBar.hideKeyguard(); |
Adrian Roos | 91ffdc4 | 2017-08-04 18:14:41 +0200 | [diff] [blame] | 378 | if (hideBouncerWhenShowing || mBouncer.needsFullscreenBouncer()) { |
| 379 | hideBouncer(false /* destroyView */); |
| 380 | } |
Jorim Jaggi | 43bdbbd | 2014-05-09 16:05:53 +0200 | [diff] [blame] | 381 | } else { |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 382 | showBouncerOrKeyguard(hideBouncerWhenShowing); |
Jorim Jaggi | 43bdbbd | 2014-05-09 16:05:53 +0200 | [diff] [blame] | 383 | } |
Selim Cinek | 1fcafc4 | 2015-07-20 14:39:25 -0700 | [diff] [blame] | 384 | KeyguardUpdateMonitor.getInstance(mContext).sendKeyguardReset(); |
Jorim Jaggi | 43bdbbd | 2014-05-09 16:05:53 +0200 | [diff] [blame] | 385 | updateStates(); |
Dan Sandler | 3806c77 | 2014-05-08 14:52:10 -0400 | [diff] [blame] | 386 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 387 | } |
| 388 | |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 389 | public boolean isGoingToSleepVisibleNotOccluded() { |
| 390 | return mGoingToSleepVisibleNotOccluded; |
| 391 | } |
| 392 | |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 393 | public void onStartedGoingToSleep() { |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 394 | mGoingToSleepVisibleNotOccluded = isShowing() && !isOccluded(); |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 395 | } |
| 396 | |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 397 | public void onFinishedGoingToSleep() { |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 398 | mGoingToSleepVisibleNotOccluded = false; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 399 | mBouncer.onScreenTurnedOff(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 400 | } |
| 401 | |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 402 | public void onStartedWakingUp() { |
Adrian Roos | 731d4df | 2017-07-18 15:10:39 +0200 | [diff] [blame] | 403 | // TODO: remove |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 404 | } |
| 405 | |
Jorim Jaggi | 9373911 | 2015-08-13 15:53:14 -0700 | [diff] [blame] | 406 | public void onScreenTurningOn() { |
Adrian Roos | 731d4df | 2017-07-18 15:10:39 +0200 | [diff] [blame] | 407 | // TODO: remove |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 408 | } |
| 409 | |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 410 | public void onScreenTurnedOn() { |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 411 | // TODO: remove |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 412 | } |
| 413 | |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 414 | @Override |
| 415 | public void onRemoteInputActive(boolean active) { |
| 416 | mRemoteInputActive = active; |
| 417 | updateStates(); |
| 418 | } |
| 419 | |
Evan Laird | 878c853 | 2018-10-15 15:54:29 -0400 | [diff] [blame] | 420 | private void setDozing(boolean dozing) { |
Adrian Roos | 41eecff | 2017-06-29 14:09:52 +0200 | [diff] [blame] | 421 | if (mDozing != dozing) { |
| 422 | mDozing = dozing; |
Adrian Roos | 61676aa | 2017-08-03 16:24:32 +0200 | [diff] [blame] | 423 | if (dozing || mBouncer.needsFullscreenBouncer() || mOccluded) { |
| 424 | reset(dozing /* hideBouncerWhenShowing */); |
| 425 | } |
Adrian Roos | 41eecff | 2017-06-29 14:09:52 +0200 | [diff] [blame] | 426 | updateStates(); |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 427 | |
| 428 | if (!dozing) { |
Adrian Roos | 34e6540 | 2017-08-07 19:32:45 +0200 | [diff] [blame] | 429 | launchPendingWakeupAction(); |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 430 | } |
Adrian Roos | 41eecff | 2017-06-29 14:09:52 +0200 | [diff] [blame] | 431 | } |
Adrian Roos | 087826a | 2017-04-19 16:59:09 -0700 | [diff] [blame] | 432 | } |
| 433 | |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 434 | /** |
| 435 | * If {@link StatusBar} is pulsing. |
| 436 | */ |
| 437 | public void setPulsing(boolean pulsing) { |
| 438 | if (mPulsing != pulsing) { |
| 439 | mPulsing = pulsing; |
| 440 | updateStates(); |
| 441 | } |
| 442 | } |
| 443 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 444 | public void setNeedsInput(boolean needsInput) { |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 445 | mStatusBarWindowController.setKeyguardNeedsInput(needsInput); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 446 | } |
| 447 | |
Adrian Roos | d5c2db6 | 2016-03-08 16:11:31 -0800 | [diff] [blame] | 448 | public boolean isUnlockWithWallpaper() { |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 449 | return mStatusBarWindowController.isShowingWallpaper(); |
Adrian Roos | d5c2db6 | 2016-03-08 16:11:31 -0800 | [diff] [blame] | 450 | } |
| 451 | |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 452 | public void setOccluded(boolean occluded, boolean animate) { |
Selim Cinek | 3a49ba2 | 2017-08-10 11:17:39 -0700 | [diff] [blame] | 453 | mStatusBar.setOccluded(occluded); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 454 | if (occluded && !mOccluded && mShowing) { |
Tej Singh | dd7bd35 | 2018-02-09 19:33:15 -0800 | [diff] [blame] | 455 | StatsLog.write(StatsLog.KEYGUARD_STATE_CHANGED, |
| 456 | StatsLog.KEYGUARD_STATE_CHANGED__STATE__OCCLUDED); |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 457 | if (mStatusBar.isInLaunchTransition()) { |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 458 | mOccluded = true; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 459 | mStatusBar.fadeKeyguardAfterLaunchTransition(null /* beforeFading */, |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 460 | new Runnable() { |
| 461 | @Override |
| 462 | public void run() { |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 463 | mStatusBarWindowController.setKeyguardOccluded(mOccluded); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 464 | reset(true /* hideBouncerWhenShowing */); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 465 | } |
| 466 | }); |
| 467 | return; |
| 468 | } |
Tej Singh | dd7bd35 | 2018-02-09 19:33:15 -0800 | [diff] [blame] | 469 | } else if (!occluded && mOccluded && mShowing) { |
| 470 | StatsLog.write(StatsLog.KEYGUARD_STATE_CHANGED, |
| 471 | StatsLog.KEYGUARD_STATE_CHANGED__STATE__SHOWN); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 472 | } |
Lucas Dupin | 28f9029 | 2017-08-08 18:07:49 -0400 | [diff] [blame] | 473 | boolean isOccluding = !mOccluded && occluded; |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 474 | mOccluded = occluded; |
Adrian Roos | 909fe2d | 2016-10-12 12:03:24 -0700 | [diff] [blame] | 475 | if (mShowing) { |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 476 | mMediaManager.updateMediaMetaData(false, animate && !occluded); |
Adrian Roos | 909fe2d | 2016-10-12 12:03:24 -0700 | [diff] [blame] | 477 | } |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 478 | mStatusBarWindowController.setKeyguardOccluded(occluded); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 479 | |
Adrian Roos | 7a56d1a | 2017-08-04 15:04:43 +0200 | [diff] [blame] | 480 | // setDozing(false) will call reset once we stop dozing. |
| 481 | if (!mDozing) { |
| 482 | // If Keyguard is reshown, don't hide the bouncer as it might just have been requested |
| 483 | // by a FLAG_DISMISS_KEYGUARD_ACTIVITY. |
Lucas Dupin | 28f9029 | 2017-08-08 18:07:49 -0400 | [diff] [blame] | 484 | reset(isOccluding /* hideBouncerWhenShowing*/); |
Adrian Roos | 7a56d1a | 2017-08-04 15:04:43 +0200 | [diff] [blame] | 485 | } |
Lucas Dupin | e9e7071 | 2019-05-01 14:41:49 -0700 | [diff] [blame] | 486 | if (animate && !occluded && mShowing && !mBouncer.isShowing()) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 487 | mStatusBar.animateKeyguardUnoccluding(); |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 488 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 489 | } |
| 490 | |
Dan Sandler | 4b22bdf | 2014-06-05 00:58:02 -0400 | [diff] [blame] | 491 | public boolean isOccluded() { |
| 492 | return mOccluded; |
| 493 | } |
| 494 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 495 | /** |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 496 | * Starts the animation before we dismiss Keyguard, i.e. an disappearing animation on the |
| 497 | * security view of the bouncer. |
| 498 | * |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 499 | * @param finishRunnable the runnable to be run after the animation finished, or {@code null} if |
| 500 | * no action should be run |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 501 | */ |
| 502 | public void startPreHideAnimation(Runnable finishRunnable) { |
| 503 | if (mBouncer.isShowing()) { |
| 504 | mBouncer.startPreHideAnimation(finishRunnable); |
Lucas Dupin | 9375255 | 2018-03-19 21:32:19 -0700 | [diff] [blame] | 505 | mNotificationPanelView.onBouncerPreHideAnimation(); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 506 | } else if (finishRunnable != null) { |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 507 | finishRunnable.run(); |
| 508 | } |
Lucas Dupin | d61974d | 2019-03-29 16:09:26 -0700 | [diff] [blame] | 509 | mNotificationPanelView.blockExpansionForCurrentTouch(); |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 510 | updateLockIcon(); |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 514 | * Hides the keyguard view |
| 515 | */ |
Jorim Jaggi | e8fde5d | 2016-06-30 23:41:37 -0700 | [diff] [blame] | 516 | public void hide(long startTime, long fadeoutDuration) { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 517 | mShowing = false; |
Evan Laird | 2d620fa | 2018-10-30 13:03:31 -0400 | [diff] [blame] | 518 | mKeyguardMonitor.notifyKeyguardState( |
| 519 | mShowing, mKeyguardMonitor.isSecure(), mKeyguardMonitor.isOccluded()); |
Adrian Roos | 34e6540 | 2017-08-07 19:32:45 +0200 | [diff] [blame] | 520 | launchPendingWakeupAction(); |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 521 | |
Jorim Jaggi | 031f795 | 2016-09-01 16:39:26 -0700 | [diff] [blame] | 522 | if (KeyguardUpdateMonitor.getInstance(mContext).needsSlowUnlockTransition()) { |
Jorim Jaggi | e8fde5d | 2016-06-30 23:41:37 -0700 | [diff] [blame] | 523 | fadeoutDuration = KEYGUARD_DISMISS_DURATION_LOCKED; |
| 524 | } |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 525 | long uptimeMillis = SystemClock.uptimeMillis(); |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 526 | long delay = Math.max(0, startTime + HIDE_TIMING_CORRECTION_MS - uptimeMillis); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 527 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 528 | if (mStatusBar.isInLaunchTransition() ) { |
| 529 | mStatusBar.fadeKeyguardAfterLaunchTransition(new Runnable() { |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 530 | @Override |
| 531 | public void run() { |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 532 | mStatusBarWindowController.setKeyguardShowing(false); |
| 533 | mStatusBarWindowController.setKeyguardFadingAway(true); |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 534 | hideBouncer(true /* destroyView */); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 535 | updateStates(); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 536 | } |
| 537 | }, new Runnable() { |
| 538 | @Override |
| 539 | public void run() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 540 | mStatusBar.hideKeyguard(); |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 541 | mStatusBarWindowController.setKeyguardFadingAway(false); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 542 | mViewMediatorCallback.keyguardGone(); |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 543 | executeAfterKeyguardGoneAction(); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 544 | } |
| 545 | }); |
| 546 | } else { |
Jorim Jaggi | 8d5a6e7 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 547 | executeAfterKeyguardGoneAction(); |
Jorim Jaggi | e93698b | 2016-11-11 18:24:38 -0800 | [diff] [blame] | 548 | boolean wakeUnlockPulsing = |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 549 | mBiometricUnlockController.getMode() == MODE_WAKE_AND_UNLOCK_PULSING; |
Jorim Jaggi | e93698b | 2016-11-11 18:24:38 -0800 | [diff] [blame] | 550 | if (wakeUnlockPulsing) { |
| 551 | delay = 0; |
| 552 | fadeoutDuration = 240; |
| 553 | } |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 554 | mStatusBar.setKeyguardFadingAway(startTime, delay, fadeoutDuration); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 555 | mBiometricUnlockController.startKeyguardFadingAway(); |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 556 | hideBouncer(true /* destroyView */); |
Jorim Jaggi | e93698b | 2016-11-11 18:24:38 -0800 | [diff] [blame] | 557 | if (wakeUnlockPulsing) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 558 | mStatusBar.fadeKeyguardWhilePulsing(); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 559 | wakeAndUnlockDejank(); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 560 | } else { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 561 | boolean staying = mStatusBar.hideKeyguard(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 562 | if (!staying) { |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 563 | mStatusBarWindowController.setKeyguardFadingAway(true); |
Lucas Dupin | f0a67e3 | 2018-09-19 15:23:54 -0700 | [diff] [blame] | 564 | // hide() will happen asynchronously and might arrive after the scrims |
| 565 | // were already hidden, this means that the transition callback won't |
| 566 | // be triggered anymore and StatusBarWindowController will be forever in |
| 567 | // the fadingAway state. |
| 568 | mStatusBar.updateScrimController(); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 569 | wakeAndUnlockDejank(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 570 | } else { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 571 | mStatusBar.finishKeyguardFadingAway(); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 572 | mBiometricUnlockController.finishKeyguardFadingAway(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 573 | } |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 574 | } |
Jorim Jaggi | 67b29d5 | 2017-06-09 18:00:00 -0700 | [diff] [blame] | 575 | updateStates(); |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 576 | mStatusBarWindowController.setKeyguardShowing(false); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 577 | mViewMediatorCallback.keyguardGone(); |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 578 | } |
Tej Singh | dd7bd35 | 2018-02-09 19:33:15 -0800 | [diff] [blame] | 579 | StatsLog.write(StatsLog.KEYGUARD_STATE_CHANGED, |
| 580 | StatsLog.KEYGUARD_STATE_CHANGED__STATE__HIDDEN); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 581 | } |
| 582 | |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 583 | @Override |
Selim Cinek | aa8bbf1 | 2016-05-04 14:13:20 -0700 | [diff] [blame] | 584 | public void onDensityOrFontScaleChanged() { |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 585 | hideBouncer(true /* destroyView */); |
Selim Cinek | aa8bbf1 | 2016-05-04 14:13:20 -0700 | [diff] [blame] | 586 | } |
| 587 | |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 588 | @Override |
Winson Chung | 1aa24b9 | 2019-04-24 15:17:33 -0700 | [diff] [blame] | 589 | public void onNavigationModeChanged(int mode) { |
| 590 | boolean gesturalNav = QuickStepContract.isGesturalMode(mode); |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 591 | if (gesturalNav != mGesturalNav) { |
| 592 | mGesturalNav = gesturalNav; |
| 593 | updateStates(); |
| 594 | } |
| 595 | } |
| 596 | |
Lucas Dupin | 8c51ce2 | 2017-11-21 13:21:05 -0800 | [diff] [blame] | 597 | public void onThemeChanged() { |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 598 | hideBouncer(true /* destroyView */); |
Lucas Dupin | f190a85 | 2017-07-31 17:11:26 -0700 | [diff] [blame] | 599 | mBouncer.prepare(); |
Lucas Dupin | 89516d4 | 2017-07-05 13:29:18 -0700 | [diff] [blame] | 600 | } |
| 601 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 602 | public void onKeyguardFadedAway() { |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 603 | mContainer.postDelayed(() -> mStatusBarWindowController.setKeyguardFadingAway(false), |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 604 | 100); |
| 605 | mStatusBar.finishKeyguardFadingAway(); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 606 | mBiometricUnlockController.finishKeyguardFadingAway(); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 607 | WindowManagerGlobal.getInstance().trimMemory( |
| 608 | ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN); |
| 609 | |
Jorim Jaggi | 9097885 | 2015-08-18 19:55:53 -0700 | [diff] [blame] | 610 | } |
| 611 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 612 | private void wakeAndUnlockDejank() { |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 613 | if (mBiometricUnlockController.getMode() == MODE_WAKE_AND_UNLOCK |
Jorim Jaggi | 8adb30c | 2016-09-13 15:02:22 -0700 | [diff] [blame] | 614 | && LatencyTracker.isEnabled(mContext)) { |
| 615 | DejankUtils.postAfterTraversal(() -> |
| 616 | LatencyTracker.getInstance(mContext).onActionEnd( |
| 617 | LatencyTracker.ACTION_FINGERPRINT_WAKE_AND_UNLOCK)); |
| 618 | } |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 619 | } |
| 620 | |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 621 | private void executeAfterKeyguardGoneAction() { |
| 622 | if (mAfterKeyguardGoneAction != null) { |
| 623 | mAfterKeyguardGoneAction.onDismiss(); |
| 624 | mAfterKeyguardGoneAction = null; |
| 625 | } |
Jorim Jaggi | bcbe948 | 2016-11-23 17:37:49 +0100 | [diff] [blame] | 626 | for (int i = 0; i < mAfterKeyguardGoneRunnables.size(); i++) { |
| 627 | mAfterKeyguardGoneRunnables.get(i).run(); |
| 628 | } |
| 629 | mAfterKeyguardGoneRunnables.clear(); |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 630 | } |
| 631 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 632 | /** |
| 633 | * Dismisses the keyguard by going to the next screen or making it gone. |
| 634 | */ |
Jorim Jaggi | 8d5a6e7 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 635 | public void dismissAndCollapse() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 636 | mStatusBar.executeRunnableDismissingKeyguard(null, null, true, false, true); |
Jorim Jaggi | 8d5a6e7 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 637 | } |
| 638 | |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 639 | /** |
| 640 | * WARNING: This method might cause Binder calls. |
| 641 | */ |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 642 | public boolean isSecure() { |
| 643 | return mBouncer.isSecure(); |
| 644 | } |
| 645 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 646 | /** |
| 647 | * @return Whether the keyguard is showing |
| 648 | */ |
| 649 | public boolean isShowing() { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 650 | return mShowing; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 651 | } |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 652 | |
| 653 | /** |
| 654 | * Notifies this manager that the back button has been pressed. |
| 655 | * |
Lucas Dupin | 3f54fe2 | 2018-04-08 23:17:40 -0700 | [diff] [blame] | 656 | * @param hideImmediately Hide bouncer when {@code true}, keep it around otherwise. |
| 657 | * Non-scrimmed bouncers have a special animation tied to the expansion |
| 658 | * of the notification panel. |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 659 | * @return whether the back press has been handled |
| 660 | */ |
Lucas Dupin | 3f54fe2 | 2018-04-08 23:17:40 -0700 | [diff] [blame] | 661 | public boolean onBackPressed(boolean hideImmediately) { |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 662 | if (mBouncer.isShowing()) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 663 | mStatusBar.endAffordanceLaunch(); |
Fabian Kozynski | baa47b6 | 2019-04-26 15:40:43 -0400 | [diff] [blame] | 664 | // The second condition is for SIM card locked bouncer |
| 665 | if (mBouncer.isScrimmed() && !mBouncer.needsFullscreenBouncer()) { |
| 666 | hideBouncer(false); |
| 667 | updateStates(); |
| 668 | } else { |
| 669 | reset(hideImmediately); |
| 670 | } |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 671 | return true; |
| 672 | } |
| 673 | return false; |
| 674 | } |
| 675 | |
Jim Miller | f41fc96 | 2014-06-18 16:33:51 -0700 | [diff] [blame] | 676 | public boolean isBouncerShowing() { |
| 677 | return mBouncer.isShowing(); |
| 678 | } |
| 679 | |
Lucas Dupin | d61974d | 2019-03-29 16:09:26 -0700 | [diff] [blame] | 680 | public boolean isBouncerPartiallyVisible() { |
| 681 | return mBouncer.isPartiallyVisible(); |
| 682 | } |
| 683 | |
Jackal Guo | 42cae96 | 2018-04-18 18:41:19 +0800 | [diff] [blame] | 684 | public boolean isFullscreenBouncer() { |
| 685 | return mBouncer.isFullscreenBouncer(); |
| 686 | } |
| 687 | |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 688 | private long getNavBarShowDelay() { |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 689 | if (mKeyguardMonitor.isKeyguardFadingAway()) { |
| 690 | return mKeyguardMonitor.getKeyguardFadingAwayDelay(); |
Adrian Roos | 087826a | 2017-04-19 16:59:09 -0700 | [diff] [blame] | 691 | } else if (mBouncer.isShowing()) { |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 692 | return NAV_BAR_SHOW_DELAY_BOUNCER; |
Adrian Roos | 087826a | 2017-04-19 16:59:09 -0700 | [diff] [blame] | 693 | } else { |
| 694 | // No longer dozing, or remote input is active. No delay. |
| 695 | return 0; |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 696 | } |
| 697 | } |
| 698 | |
| 699 | private Runnable mMakeNavigationBarVisibleRunnable = new Runnable() { |
| 700 | @Override |
| 701 | public void run() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 702 | mStatusBar.getNavigationBarView().getRootView().setVisibility(View.VISIBLE); |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 703 | } |
| 704 | }; |
| 705 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 706 | protected void updateStates() { |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 707 | int vis = mContainer.getSystemUiVisibility(); |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 708 | boolean showing = mShowing; |
| 709 | boolean occluded = mOccluded; |
| 710 | boolean bouncerShowing = mBouncer.isShowing(); |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 711 | boolean bouncerDismissible = !mBouncer.isFullscreenBouncer(); |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 712 | boolean remoteInputActive = mRemoteInputActive; |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 713 | |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 714 | if ((bouncerDismissible || !showing || remoteInputActive) != |
| 715 | (mLastBouncerDismissible || !mLastShowing || mLastRemoteInputActive) |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 716 | || mFirstUpdate) { |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 717 | if (bouncerDismissible || !showing || remoteInputActive) { |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 718 | mContainer.setSystemUiVisibility(vis & ~View.STATUS_BAR_DISABLE_BACK); |
Jason Monk | 1e68fb3 | 2014-05-02 16:06:20 -0400 | [diff] [blame] | 719 | } else { |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 720 | mContainer.setSystemUiVisibility(vis | View.STATUS_BAR_DISABLE_BACK); |
Jason Monk | 1e68fb3 | 2014-05-02 16:06:20 -0400 | [diff] [blame] | 721 | } |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 722 | } |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 723 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 724 | boolean navBarVisible = isNavBarVisible(); |
| 725 | boolean lastNavBarVisible = getLastNavBarVisible(); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 726 | if (navBarVisible != lastNavBarVisible || mFirstUpdate) { |
Brad Stenning | 7e41181 | 2018-04-13 22:52:39 -0700 | [diff] [blame] | 727 | updateNavigationBarVisibility(navBarVisible); |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 728 | } |
| 729 | |
| 730 | if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) { |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 731 | mStatusBarWindowController.setBouncerShowing(bouncerShowing); |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 732 | mStatusBar.setBouncerShowing(bouncerShowing); |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 733 | } |
| 734 | |
| 735 | KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext); |
| 736 | if ((showing && !occluded) != (mLastShowing && !mLastOccluded) || mFirstUpdate) { |
Jorim Jaggi | 6a15d52 | 2015-09-22 15:55:33 -0700 | [diff] [blame] | 737 | updateMonitor.onKeyguardVisibilityChanged(showing && !occluded); |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 738 | } |
| 739 | if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) { |
| 740 | updateMonitor.sendKeyguardBouncerChanged(bouncerShowing); |
| 741 | } |
| 742 | |
| 743 | mFirstUpdate = false; |
| 744 | mLastShowing = showing; |
| 745 | mLastOccluded = occluded; |
| 746 | mLastBouncerShowing = bouncerShowing; |
| 747 | mLastBouncerDismissible = bouncerDismissible; |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 748 | mLastRemoteInputActive = remoteInputActive; |
Adrian Roos | 087826a | 2017-04-19 16:59:09 -0700 | [diff] [blame] | 749 | mLastDozing = mDozing; |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 750 | mLastPulsing = mPulsing; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 751 | mLastBiometricMode = mBiometricUnlockController.getMode(); |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 752 | mLastGesturalNav = mGesturalNav; |
| 753 | mLastIsDocked = mIsDocked; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 754 | mStatusBar.onKeyguardViewManagerStatesUpdated(); |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 755 | } |
Jorim Jaggi | 8c8bcc1 | 2014-04-16 21:36:51 +0200 | [diff] [blame] | 756 | |
Brad Stenning | 7e41181 | 2018-04-13 22:52:39 -0700 | [diff] [blame] | 757 | protected void updateNavigationBarVisibility(boolean navBarVisible) { |
| 758 | if (mStatusBar.getNavigationBarView() != null) { |
| 759 | if (navBarVisible) { |
| 760 | long delay = getNavBarShowDelay(); |
| 761 | if (delay == 0) { |
| 762 | mMakeNavigationBarVisibleRunnable.run(); |
| 763 | } else { |
| 764 | mContainer.postOnAnimationDelayed(mMakeNavigationBarVisibleRunnable, |
| 765 | delay); |
| 766 | } |
| 767 | } else { |
| 768 | mContainer.removeCallbacks(mMakeNavigationBarVisibleRunnable); |
| 769 | mStatusBar.getNavigationBarView().getRootView().setVisibility(View.GONE); |
| 770 | } |
| 771 | } |
| 772 | } |
| 773 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 774 | /** |
| 775 | * @return Whether the navigation bar should be made visible based on the current state. |
| 776 | */ |
| 777 | protected boolean isNavBarVisible() { |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 778 | int biometricMode = mBiometricUnlockController.getMode(); |
Jorim Jaggi | f5304ad | 2017-07-17 18:31:13 +0200 | [diff] [blame] | 779 | boolean keyguardShowing = mShowing && !mOccluded; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 780 | boolean hideWhileDozing = mDozing && biometricMode != MODE_WAKE_AND_UNLOCK_PULSING; |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 781 | boolean keyguardWithGestureNav = (keyguardShowing && !mDozing || mPulsing && !mIsDocked) |
| 782 | && mGesturalNav; |
Jorim Jaggi | f5304ad | 2017-07-17 18:31:13 +0200 | [diff] [blame] | 783 | return (!keyguardShowing && !hideWhileDozing || mBouncer.isShowing() |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 784 | || mRemoteInputActive || keyguardWithGestureNav); |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 785 | } |
| 786 | |
| 787 | /** |
| 788 | * @return Whether the navigation bar was made visible based on the last known state. |
| 789 | */ |
| 790 | protected boolean getLastNavBarVisible() { |
Jorim Jaggi | f5304ad | 2017-07-17 18:31:13 +0200 | [diff] [blame] | 791 | boolean keyguardShowing = mLastShowing && !mLastOccluded; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 792 | boolean hideWhileDozing = mLastDozing && mLastBiometricMode != MODE_WAKE_AND_UNLOCK_PULSING; |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 793 | boolean keyguardWithGestureNav = (keyguardShowing && !mLastDozing |
| 794 | || mLastPulsing && !mLastIsDocked) && mLastGesturalNav; |
Jorim Jaggi | f5304ad | 2017-07-17 18:31:13 +0200 | [diff] [blame] | 795 | return (!keyguardShowing && !hideWhileDozing || mLastBouncerShowing |
Lucas Dupin | afffbf9 | 2019-04-09 19:52:26 -0700 | [diff] [blame] | 796 | || mLastRemoteInputActive || keyguardWithGestureNav); |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 797 | } |
| 798 | |
Selim Cinek | 2854019 | 2016-02-19 17:25:08 -0800 | [diff] [blame] | 799 | public boolean shouldDismissOnMenuPressed() { |
| 800 | return mBouncer.shouldDismissOnMenuPressed(); |
Jorim Jaggi | 8c8bcc1 | 2014-04-16 21:36:51 +0200 | [diff] [blame] | 801 | } |
Jorim Jaggi | df99351 | 2014-05-13 23:06:35 +0200 | [diff] [blame] | 802 | |
| 803 | public boolean interceptMediaKey(KeyEvent event) { |
| 804 | return mBouncer.interceptMediaKey(event); |
| 805 | } |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 806 | |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 807 | public void readyForKeyguardDone() { |
| 808 | mViewMediatorCallback.readyForKeyguardDone(); |
| 809 | } |
| 810 | |
Jorim Jaggi | 84a3e7a | 2014-08-13 17:58:58 +0200 | [diff] [blame] | 811 | public boolean shouldDisableWindowAnimationsForUnlock() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 812 | return mStatusBar.isInLaunchTransition(); |
Jorim Jaggi | 84a3e7a | 2014-08-13 17:58:58 +0200 | [diff] [blame] | 813 | } |
| 814 | |
| 815 | public boolean isGoingToNotificationShade() { |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 816 | return ((SysuiStatusBarStateController) Dependency.get(StatusBarStateController.class)) |
| 817 | .leaveOpenOnKeyguardHide(); |
Jorim Jaggi | 84a3e7a | 2014-08-13 17:58:58 +0200 | [diff] [blame] | 818 | } |
Adrian Roos | 31b844b | 2014-11-21 13:55:09 +0100 | [diff] [blame] | 819 | |
| 820 | public boolean isSecure(int userId) { |
| 821 | return mBouncer.isSecure() || mLockPatternUtils.isSecure(userId); |
| 822 | } |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 823 | |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 824 | public void keyguardGoingAway() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 825 | mStatusBar.keyguardGoingAway(); |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 826 | } |
Jim Miller | 25d7e51 | 2015-03-03 17:12:09 -0800 | [diff] [blame] | 827 | |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 828 | public void animateCollapsePanels(float speedUpFactor) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 829 | mStatusBar.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */, |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 830 | false /* delayed */, speedUpFactor); |
Jim Miller | 25d7e51 | 2015-03-03 17:12:09 -0800 | [diff] [blame] | 831 | } |
Jorim Jaggi | 5cc8659 | 2015-06-08 14:48:28 -0700 | [diff] [blame] | 832 | |
Aarthi Balachander | 0a427ef | 2018-07-13 15:00:58 -0700 | [diff] [blame] | 833 | |
| 834 | /** |
| 835 | * Called when cancel button in bouncer is pressed. |
| 836 | */ |
| 837 | public void onCancelClicked() { |
| 838 | // No-op |
| 839 | } |
| 840 | |
Jorim Jaggi | 5cc8659 | 2015-06-08 14:48:28 -0700 | [diff] [blame] | 841 | /** |
| 842 | * Notifies that the user has authenticated by other means than using the bouncer, for example, |
| 843 | * fingerprint. |
| 844 | */ |
Jorim Jaggi | 25b4d4b | 2015-08-11 15:54:06 -0700 | [diff] [blame] | 845 | public void notifyKeyguardAuthenticated(boolean strongAuth) { |
| 846 | mBouncer.notifyKeyguardAuthenticated(strongAuth); |
Jorim Jaggi | 5cc8659 | 2015-06-08 14:48:28 -0700 | [diff] [blame] | 847 | } |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 848 | |
Jason Chang | 1e4a4bd | 2018-05-22 17:30:19 +0800 | [diff] [blame] | 849 | public void showBouncerMessage(String message, ColorStateList colorState) { |
| 850 | mBouncer.showMessage(message, colorState); |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 851 | } |
Jorim Jaggi | b774e55 | 2015-08-24 14:52:45 -0700 | [diff] [blame] | 852 | |
| 853 | public ViewRootImpl getViewRootImpl() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 854 | return mStatusBar.getStatusBarView().getViewRootImpl(); |
Jorim Jaggi | b774e55 | 2015-08-24 14:52:45 -0700 | [diff] [blame] | 855 | } |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 856 | |
Adrian Roos | 34e6540 | 2017-08-07 19:32:45 +0200 | [diff] [blame] | 857 | public void launchPendingWakeupAction() { |
| 858 | DismissWithActionRequest request = mPendingWakeupAction; |
| 859 | mPendingWakeupAction = null; |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 860 | if (request != null) { |
| 861 | if (mShowing) { |
| 862 | dismissWithAction(request.dismissAction, request.cancelAction, |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 863 | request.afterKeyguardGone, request.message); |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 864 | } else if (request.dismissAction != null) { |
| 865 | request.dismissAction.onDismiss(); |
| 866 | } |
| 867 | } |
| 868 | } |
| 869 | |
Adrian Roos | 34e6540 | 2017-08-07 19:32:45 +0200 | [diff] [blame] | 870 | public void cancelPendingWakeupAction() { |
| 871 | DismissWithActionRequest request = mPendingWakeupAction; |
| 872 | mPendingWakeupAction = null; |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 873 | if (request != null && request.cancelAction != null) { |
| 874 | request.cancelAction.run(); |
| 875 | } |
| 876 | } |
| 877 | |
Lucas Dupin | f9ca35e | 2018-05-16 20:41:35 -0700 | [diff] [blame] | 878 | public boolean bouncerNeedsScrimming() { |
Lucas Dupin | 300e371 | 2019-03-27 19:33:36 -0700 | [diff] [blame] | 879 | return mOccluded || mBouncer.willDismissWithAction() |
Lucas Dupin | 93f714d | 2019-03-26 16:49:24 -0700 | [diff] [blame] | 880 | || mStatusBar.isFullScreenUserSwitcherState() |
Lucas Dupin | 300e371 | 2019-03-27 19:33:36 -0700 | [diff] [blame] | 881 | || (mBouncer.isShowing() && mBouncer.isScrimmed()) |
| 882 | || mBouncer.isFullscreenBouncer(); |
Lucas Dupin | f9ca35e | 2018-05-16 20:41:35 -0700 | [diff] [blame] | 883 | } |
| 884 | |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 885 | public void dump(PrintWriter pw) { |
| 886 | pw.println("StatusBarKeyguardViewManager:"); |
| 887 | pw.println(" mShowing: " + mShowing); |
| 888 | pw.println(" mOccluded: " + mOccluded); |
| 889 | pw.println(" mRemoteInputActive: " + mRemoteInputActive); |
| 890 | pw.println(" mDozing: " + mDozing); |
| 891 | pw.println(" mGoingToSleepVisibleNotOccluded: " + mGoingToSleepVisibleNotOccluded); |
| 892 | pw.println(" mAfterKeyguardGoneAction: " + mAfterKeyguardGoneAction); |
| 893 | pw.println(" mAfterKeyguardGoneRunnables: " + mAfterKeyguardGoneRunnables); |
| 894 | pw.println(" mPendingWakeupAction: " + mPendingWakeupAction); |
| 895 | |
| 896 | if (mBouncer != null) { |
| 897 | mBouncer.dump(pw); |
| 898 | } |
| 899 | } |
| 900 | |
Evan Laird | 878c853 | 2018-10-15 15:54:29 -0400 | [diff] [blame] | 901 | @Override |
| 902 | public void onStateChanged(int newState) { |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 903 | updateLockIcon(); |
Evan Laird | 878c853 | 2018-10-15 15:54:29 -0400 | [diff] [blame] | 904 | } |
| 905 | |
| 906 | @Override |
| 907 | public void onDozingChanged(boolean isDozing) { |
| 908 | setDozing(isDozing); |
| 909 | } |
| 910 | |
Lucas Dupin | 407cc58 | 2019-03-11 21:04:31 -0700 | [diff] [blame] | 911 | public KeyguardBouncer getBouncer() { |
| 912 | return mBouncer; |
| 913 | } |
| 914 | |
Adrian Roos | 34e6540 | 2017-08-07 19:32:45 +0200 | [diff] [blame] | 915 | private static class DismissWithActionRequest { |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 916 | final OnDismissAction dismissAction; |
| 917 | final Runnable cancelAction; |
| 918 | final boolean afterKeyguardGone; |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 919 | final String message; |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 920 | |
Adrian Roos | 34e6540 | 2017-08-07 19:32:45 +0200 | [diff] [blame] | 921 | DismissWithActionRequest(OnDismissAction dismissAction, Runnable cancelAction, |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 922 | boolean afterKeyguardGone, String message) { |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 923 | this.dismissAction = dismissAction; |
| 924 | this.cancelAction = cancelAction; |
| 925 | this.afterKeyguardGone = afterKeyguardGone; |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 926 | this.message = message; |
Adrian Roos | fee661c | 2017-08-04 17:05:45 +0200 | [diff] [blame] | 927 | } |
| 928 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 929 | } |