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 | |
Jorim Jaggi | 786afcb | 2014-09-25 02:41:29 +0200 | [diff] [blame] | 19 | import android.content.ComponentCallbacks2; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 20 | import android.content.Context; |
| 21 | import android.os.Bundle; |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 22 | import android.os.SystemClock; |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 23 | import android.os.Trace; |
Jorim Jaggi | df99351 | 2014-05-13 23:06:35 +0200 | [diff] [blame] | 24 | import android.view.KeyEvent; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 25 | import android.view.View; |
| 26 | import android.view.ViewGroup; |
Jorim Jaggi | b774e55 | 2015-08-24 14:52:45 -0700 | [diff] [blame] | 27 | import android.view.ViewRootImpl; |
Jorim Jaggi | 786afcb | 2014-09-25 02:41:29 +0200 | [diff] [blame] | 28 | import android.view.WindowManagerGlobal; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 29 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 30 | import com.android.internal.widget.LockPatternUtils; |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 31 | import com.android.keyguard.KeyguardUpdateMonitor; |
Jorim Jaggi | a9d7fcd | 2017-05-18 01:08:12 +0200 | [diff] [blame] | 32 | import com.android.keyguard.KeyguardUpdateMonitorCallback; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 33 | import com.android.keyguard.ViewMediatorCallback; |
Jorim Jaggi | 8adb30c | 2016-09-13 15:02:22 -0700 | [diff] [blame] | 34 | import com.android.systemui.DejankUtils; |
Jorim Jaggi | d056517 | 2016-09-15 16:31:14 -0700 | [diff] [blame] | 35 | import com.android.keyguard.LatencyTracker; |
Jason Monk | 421a941 | 2017-02-06 09:15:21 -0800 | [diff] [blame] | 36 | import com.android.systemui.Dependency; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 37 | import com.android.systemui.SystemUIFactory; |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 38 | import com.android.systemui.keyguard.DismissCallbackRegistry; |
Jim Miller | 25d7e51 | 2015-03-03 17:12:09 -0800 | [diff] [blame] | 39 | import com.android.systemui.statusbar.CommandQueue; |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 40 | import com.android.systemui.statusbar.RemoteInputController; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 41 | |
Jorim Jaggi | 6b88cdf | 2014-12-22 20:56:50 +0100 | [diff] [blame] | 42 | import static com.android.keyguard.KeyguardHostView.OnDismissAction; |
Jorim Jaggi | 8adb30c | 2016-09-13 15:02:22 -0700 | [diff] [blame] | 43 | import static com.android.systemui.statusbar.phone.FingerprintUnlockController.*; |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 44 | |
Jorim Jaggi | bcbe948 | 2016-11-23 17:37:49 +0100 | [diff] [blame] | 45 | import java.util.ArrayList; |
| 46 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 47 | /** |
| 48 | * Manages creating, showing, hiding and resetting the keyguard within the status bar. Calls back |
| 49 | * via {@link ViewMediatorCallback} to poke the wake lock and report that the keyguard is done, |
| 50 | * which is in turn, reported to this class by the current |
| 51 | * {@link com.android.keyguard.KeyguardViewBase}. |
| 52 | */ |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 53 | public class StatusBarKeyguardViewManager implements RemoteInputController.Callback { |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 54 | |
| 55 | // 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] | 56 | private static final long HIDE_TIMING_CORRECTION_MS = - 16 * 3; |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 57 | |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 58 | // Delay for showing the navigation bar when the bouncer appears. This should be kept in sync |
| 59 | // with the appear animations of the PIN/pattern/password views. |
| 60 | private static final long NAV_BAR_SHOW_DELAY_BOUNCER = 320; |
| 61 | |
Jorim Jaggi | 007f0e8 | 2015-08-14 13:56:01 -0700 | [diff] [blame] | 62 | private static final long WAKE_AND_UNLOCK_SCRIM_FADEOUT_DURATION_MS = 200; |
| 63 | |
Jorim Jaggi | e8fde5d | 2016-06-30 23:41:37 -0700 | [diff] [blame] | 64 | // Duration of the Keyguard dismissal animation in case the user is currently locked. This is to |
| 65 | // make everything a bit slower to bridge a gap until the user is unlocked and home screen has |
| 66 | // dranw its first frame. |
| 67 | private static final long KEYGUARD_DISMISS_DURATION_LOCKED = 2000; |
| 68 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 69 | private static String TAG = "StatusBarKeyguardViewManager"; |
| 70 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 71 | protected final Context mContext; |
Jason Monk | 421a941 | 2017-02-06 09:15:21 -0800 | [diff] [blame] | 72 | private final StatusBarWindowManager mStatusBarWindowManager; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 73 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 74 | protected LockPatternUtils mLockPatternUtils; |
| 75 | protected ViewMediatorCallback mViewMediatorCallback; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 76 | protected StatusBar mStatusBar; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 77 | private ScrimController mScrimController; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 78 | private FingerprintUnlockController mFingerprintUnlockController; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 79 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 80 | private ViewGroup mContainer; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 81 | |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 82 | private boolean mDeviceInteractive = false; |
| 83 | private boolean mScreenTurnedOn; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 84 | protected KeyguardBouncer mBouncer; |
| 85 | protected boolean mShowing; |
| 86 | protected boolean mOccluded; |
| 87 | protected boolean mRemoteInputActive; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 88 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 89 | protected boolean mFirstUpdate = true; |
| 90 | protected boolean mLastShowing; |
| 91 | protected boolean mLastOccluded; |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 92 | private boolean mLastBouncerShowing; |
| 93 | private boolean mLastBouncerDismissible; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 94 | protected boolean mLastRemoteInputActive; |
Jorim Jaggi | 67b29d5 | 2017-06-09 18:00:00 -0700 | [diff] [blame] | 95 | private boolean mLastDeferScrimFadeOut; |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 96 | |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 97 | private OnDismissAction mAfterKeyguardGoneAction; |
Jorim Jaggi | bcbe948 | 2016-11-23 17:37:49 +0100 | [diff] [blame] | 98 | private final ArrayList<Runnable> mAfterKeyguardGoneRunnables = new ArrayList<>(); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 99 | private boolean mDeviceWillWakeUp; |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 100 | private boolean mDeferScrimFadeOut; |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 101 | |
Jorim Jaggi | a9d7fcd | 2017-05-18 01:08:12 +0200 | [diff] [blame] | 102 | private final KeyguardUpdateMonitorCallback mUpdateMonitorCallback = |
| 103 | new KeyguardUpdateMonitorCallback() { |
| 104 | @Override |
| 105 | public void onEmergencyCallAction() { |
| 106 | |
| 107 | // Since we won't get a setOccluded call we have to reset the view manually such that |
| 108 | // the bouncer goes away. |
| 109 | if (mOccluded) { |
| 110 | reset(false /* hideBouncerWhenShowing */); |
| 111 | } |
| 112 | } |
| 113 | }; |
| 114 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 115 | public StatusBarKeyguardViewManager(Context context, ViewMediatorCallback callback, |
| 116 | LockPatternUtils lockPatternUtils) { |
| 117 | mContext = context; |
| 118 | mViewMediatorCallback = callback; |
| 119 | mLockPatternUtils = lockPatternUtils; |
Jason Monk | 421a941 | 2017-02-06 09:15:21 -0800 | [diff] [blame] | 120 | mStatusBarWindowManager = Dependency.get(StatusBarWindowManager.class); |
Jorim Jaggi | a9d7fcd | 2017-05-18 01:08:12 +0200 | [diff] [blame] | 121 | KeyguardUpdateMonitor.getInstance(context).registerCallback(mUpdateMonitorCallback); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 122 | } |
| 123 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 124 | public void registerStatusBar(StatusBar statusBar, |
Jason Monk | 421a941 | 2017-02-06 09:15:21 -0800 | [diff] [blame] | 125 | ViewGroup container, |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 126 | ScrimController scrimController, |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 127 | FingerprintUnlockController fingerprintUnlockController, |
| 128 | DismissCallbackRegistry dismissCallbackRegistry) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 129 | mStatusBar = statusBar; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 130 | mContainer = container; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 131 | mScrimController = scrimController; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 132 | mFingerprintUnlockController = fingerprintUnlockController; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 133 | mBouncer = SystemUIFactory.getInstance().createKeyguardBouncer(mContext, |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 134 | mViewMediatorCallback, mLockPatternUtils, container, dismissCallbackRegistry); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Show the keyguard. Will handle creating and attaching to the view manager |
| 139 | * lazily. |
| 140 | */ |
| 141 | public void show(Bundle options) { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 142 | mShowing = true; |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 143 | mStatusBarWindowManager.setKeyguardShowing(true); |
Selim Cinek | edd32b8 | 2015-06-23 22:05:58 -0400 | [diff] [blame] | 144 | mScrimController.abortKeyguardFadingOut(); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 145 | reset(true /* hideBouncerWhenShowing */); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 146 | } |
| 147 | |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 148 | /** |
| 149 | * Shows the notification keyguard or the bouncer depending on |
| 150 | * {@link KeyguardBouncer#needsFullscreenBouncer()}. |
| 151 | */ |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 152 | protected void showBouncerOrKeyguard(boolean hideBouncerWhenShowing) { |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 153 | if (mBouncer.needsFullscreenBouncer()) { |
| 154 | |
| 155 | // The keyguard might be showing (already). So we need to hide it. |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 156 | mStatusBar.hideKeyguard(); |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 157 | mBouncer.show(true /* resetSecuritySelection */); |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 158 | } else { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 159 | mStatusBar.showKeyguard(); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 160 | if (hideBouncerWhenShowing) { |
| 161 | mBouncer.hide(false /* destroyView */); |
| 162 | mBouncer.prepare(); |
| 163 | } |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 164 | } |
| 165 | } |
| 166 | |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 167 | private void showBouncer() { |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 168 | if (mShowing) { |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 169 | mBouncer.show(false /* resetSecuritySelection */); |
Dan Sandler | 3806c77 | 2014-05-08 14:52:10 -0400 | [diff] [blame] | 170 | } |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 171 | updateStates(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 172 | } |
| 173 | |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 174 | public void dismissWithAction(OnDismissAction r, Runnable cancelAction, |
| 175 | boolean afterKeyguardGone) { |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 176 | if (mShowing) { |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 177 | if (!afterKeyguardGone) { |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 178 | mBouncer.showWithDismissAction(r, cancelAction); |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 179 | } else { |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 180 | mAfterKeyguardGoneAction = r; |
Jorim Jaggi | 8d5a6e7 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 181 | mBouncer.show(false /* resetSecuritySelection */); |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 182 | } |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 183 | } |
| 184 | updateStates(); |
| 185 | } |
| 186 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 187 | /** |
Jorim Jaggi | bcbe948 | 2016-11-23 17:37:49 +0100 | [diff] [blame] | 188 | * Adds a {@param runnable} to be executed after Keyguard is gone. |
| 189 | */ |
| 190 | public void addAfterKeyguardGoneRunnable(Runnable runnable) { |
| 191 | mAfterKeyguardGoneRunnables.add(runnable); |
| 192 | } |
| 193 | |
| 194 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 195 | * Reset the state of the view. |
| 196 | */ |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 197 | public void reset(boolean hideBouncerWhenShowing) { |
Jorim Jaggi | 43bdbbd | 2014-05-09 16:05:53 +0200 | [diff] [blame] | 198 | if (mShowing) { |
| 199 | if (mOccluded) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 200 | mStatusBar.hideKeyguard(); |
| 201 | mStatusBar.stopWaitingForKeyguardExit(); |
Jorim Jaggi | a0be6d5 | 2014-05-26 03:01:13 +0200 | [diff] [blame] | 202 | mBouncer.hide(false /* destroyView */); |
Jorim Jaggi | 43bdbbd | 2014-05-09 16:05:53 +0200 | [diff] [blame] | 203 | } else { |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 204 | showBouncerOrKeyguard(hideBouncerWhenShowing); |
Jorim Jaggi | 43bdbbd | 2014-05-09 16:05:53 +0200 | [diff] [blame] | 205 | } |
Selim Cinek | 1fcafc4 | 2015-07-20 14:39:25 -0700 | [diff] [blame] | 206 | KeyguardUpdateMonitor.getInstance(mContext).sendKeyguardReset(); |
Jorim Jaggi | 43bdbbd | 2014-05-09 16:05:53 +0200 | [diff] [blame] | 207 | updateStates(); |
Dan Sandler | 3806c77 | 2014-05-08 14:52:10 -0400 | [diff] [blame] | 208 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 209 | } |
| 210 | |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 211 | public void onStartedGoingToSleep() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 212 | mStatusBar.onStartedGoingToSleep(); |
Jorim Jaggi | 18f18ae | 2015-09-10 15:48:21 -0700 | [diff] [blame] | 213 | } |
| 214 | |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 215 | public void onFinishedGoingToSleep() { |
| 216 | mDeviceInteractive = false; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 217 | mStatusBar.onFinishedGoingToSleep(); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 218 | mBouncer.onScreenTurnedOff(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 219 | } |
| 220 | |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 221 | public void onStartedWakingUp() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 222 | Trace.beginSection("StatusBarKeyguardViewManager#onStartedWakingUp"); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 223 | mDeviceInteractive = true; |
| 224 | mDeviceWillWakeUp = false; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 225 | mStatusBar.onStartedWakingUp(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 226 | Trace.endSection(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 227 | } |
| 228 | |
Jorim Jaggi | 9373911 | 2015-08-13 15:53:14 -0700 | [diff] [blame] | 229 | public void onScreenTurningOn() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 230 | Trace.beginSection("StatusBarKeyguardViewManager#onScreenTurningOn"); |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 231 | mStatusBar.onScreenTurningOn(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 232 | Trace.endSection(); |
Jorim Jaggi | 9373911 | 2015-08-13 15:53:14 -0700 | [diff] [blame] | 233 | } |
| 234 | |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 235 | public boolean isScreenTurnedOn() { |
| 236 | return mScreenTurnedOn; |
| 237 | } |
| 238 | |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 239 | public void onScreenTurnedOn() { |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 240 | Trace.beginSection("StatusBarKeyguardViewManager#onScreenTurnedOn"); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 241 | mScreenTurnedOn = true; |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 242 | if (mDeferScrimFadeOut) { |
| 243 | mDeferScrimFadeOut = false; |
Jorim Jaggi | ab45a21 | 2015-08-20 16:59:44 -0700 | [diff] [blame] | 244 | animateScrimControllerKeyguardFadingOut(0, WAKE_AND_UNLOCK_SCRIM_FADEOUT_DURATION_MS, |
| 245 | true /* skipFirstFrame */); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 246 | updateStates(); |
| 247 | } |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 248 | mStatusBar.onScreenTurnedOn(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 249 | Trace.endSection(); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 250 | } |
| 251 | |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 252 | @Override |
| 253 | public void onRemoteInputActive(boolean active) { |
| 254 | mRemoteInputActive = active; |
| 255 | updateStates(); |
| 256 | } |
| 257 | |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 258 | public void onScreenTurnedOff() { |
| 259 | mScreenTurnedOn = false; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 260 | mStatusBar.onScreenTurnedOff(); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | public void notifyDeviceWakeUpRequested() { |
| 264 | mDeviceWillWakeUp = !mDeviceInteractive; |
Selim Cinek | f8fbc2a7 | 2015-06-22 16:42:07 -0400 | [diff] [blame] | 265 | } |
| 266 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 267 | public void setNeedsInput(boolean needsInput) { |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 268 | mStatusBarWindowManager.setKeyguardNeedsInput(needsInput); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 269 | } |
| 270 | |
Adrian Roos | d5c2db6 | 2016-03-08 16:11:31 -0800 | [diff] [blame] | 271 | public boolean isUnlockWithWallpaper() { |
| 272 | return mStatusBarWindowManager.isShowingWallpaper(); |
| 273 | } |
| 274 | |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 275 | public void setOccluded(boolean occluded, boolean animate) { |
Vadim Tryshev | 9ef8a51 | 2016-04-07 14:27:46 -0700 | [diff] [blame] | 276 | if (occluded != mOccluded) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 277 | mStatusBar.onKeyguardOccludedChanged(occluded); |
Vadim Tryshev | 9ef8a51 | 2016-04-07 14:27:46 -0700 | [diff] [blame] | 278 | } |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 279 | if (occluded && !mOccluded && mShowing) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 280 | if (mStatusBar.isInLaunchTransition()) { |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 281 | mOccluded = true; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 282 | mStatusBar.fadeKeyguardAfterLaunchTransition(null /* beforeFading */, |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 283 | new Runnable() { |
| 284 | @Override |
| 285 | public void run() { |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 286 | mStatusBarWindowManager.setKeyguardOccluded(mOccluded); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 287 | reset(true /* hideBouncerWhenShowing */); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 288 | } |
| 289 | }); |
| 290 | return; |
| 291 | } |
| 292 | } |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 293 | mOccluded = occluded; |
Adrian Roos | 909fe2d | 2016-10-12 12:03:24 -0700 | [diff] [blame] | 294 | if (mShowing) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 295 | mStatusBar.updateMediaMetaData(false, animate && !occluded); |
Adrian Roos | 909fe2d | 2016-10-12 12:03:24 -0700 | [diff] [blame] | 296 | } |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 297 | mStatusBarWindowManager.setKeyguardOccluded(occluded); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 298 | |
| 299 | // If Keyguard is reshown, don't hide the bouncer as it might just have been requested by |
| 300 | // a FLAG_DISMISS_KEYGUARD_ACTIVITY. |
| 301 | reset(false /* hideBouncerWhenShowing*/); |
Adrian Roos | 909fe2d | 2016-10-12 12:03:24 -0700 | [diff] [blame] | 302 | if (animate && !occluded && mShowing) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 303 | mStatusBar.animateKeyguardUnoccluding(); |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 304 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 305 | } |
| 306 | |
Dan Sandler | 4b22bdf | 2014-06-05 00:58:02 -0400 | [diff] [blame] | 307 | public boolean isOccluded() { |
| 308 | return mOccluded; |
| 309 | } |
| 310 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 311 | /** |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 312 | * Starts the animation before we dismiss Keyguard, i.e. an disappearing animation on the |
| 313 | * security view of the bouncer. |
| 314 | * |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 315 | * @param finishRunnable the runnable to be run after the animation finished, or {@code null} if |
| 316 | * no action should be run |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 317 | */ |
| 318 | public void startPreHideAnimation(Runnable finishRunnable) { |
| 319 | if (mBouncer.isShowing()) { |
| 320 | mBouncer.startPreHideAnimation(finishRunnable); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 321 | } else if (finishRunnable != null) { |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 322 | finishRunnable.run(); |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 327 | * Hides the keyguard view |
| 328 | */ |
Jorim Jaggi | e8fde5d | 2016-06-30 23:41:37 -0700 | [diff] [blame] | 329 | public void hide(long startTime, long fadeoutDuration) { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 330 | mShowing = false; |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 331 | |
Jorim Jaggi | 031f795 | 2016-09-01 16:39:26 -0700 | [diff] [blame] | 332 | if (KeyguardUpdateMonitor.getInstance(mContext).needsSlowUnlockTransition()) { |
Jorim Jaggi | e8fde5d | 2016-06-30 23:41:37 -0700 | [diff] [blame] | 333 | fadeoutDuration = KEYGUARD_DISMISS_DURATION_LOCKED; |
| 334 | } |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 335 | long uptimeMillis = SystemClock.uptimeMillis(); |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 336 | long delay = Math.max(0, startTime + HIDE_TIMING_CORRECTION_MS - uptimeMillis); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 337 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 338 | if (mStatusBar.isInLaunchTransition() ) { |
| 339 | mStatusBar.fadeKeyguardAfterLaunchTransition(new Runnable() { |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 340 | @Override |
| 341 | public void run() { |
| 342 | mStatusBarWindowManager.setKeyguardShowing(false); |
| 343 | mStatusBarWindowManager.setKeyguardFadingAway(true); |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 344 | mBouncer.hide(true /* destroyView */); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 345 | updateStates(); |
| 346 | mScrimController.animateKeyguardFadingOut( |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 347 | StatusBar.FADE_KEYGUARD_START_DELAY, |
| 348 | StatusBar.FADE_KEYGUARD_DURATION, null, |
Jorim Jaggi | ab45a21 | 2015-08-20 16:59:44 -0700 | [diff] [blame] | 349 | false /* skipFirstFrame */); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 350 | } |
| 351 | }, new Runnable() { |
| 352 | @Override |
| 353 | public void run() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 354 | mStatusBar.hideKeyguard(); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 355 | mStatusBarWindowManager.setKeyguardFadingAway(false); |
| 356 | mViewMediatorCallback.keyguardGone(); |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 357 | executeAfterKeyguardGoneAction(); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 358 | } |
| 359 | }); |
| 360 | } else { |
Jorim Jaggi | 8d5a6e7 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 361 | executeAfterKeyguardGoneAction(); |
Jorim Jaggi | e93698b | 2016-11-11 18:24:38 -0800 | [diff] [blame] | 362 | boolean wakeUnlockPulsing = |
| 363 | mFingerprintUnlockController.getMode() == MODE_WAKE_AND_UNLOCK_PULSING; |
| 364 | if (wakeUnlockPulsing) { |
| 365 | delay = 0; |
| 366 | fadeoutDuration = 240; |
| 367 | } |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 368 | mStatusBar.setKeyguardFadingAway(startTime, delay, fadeoutDuration); |
Jorim Jaggi | e93698b | 2016-11-11 18:24:38 -0800 | [diff] [blame] | 369 | mFingerprintUnlockController.startKeyguardFadingAway(); |
| 370 | mBouncer.hide(true /* destroyView */); |
Jorim Jaggi | e93698b | 2016-11-11 18:24:38 -0800 | [diff] [blame] | 371 | if (wakeUnlockPulsing) { |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 372 | mStatusBarWindowManager.setKeyguardFadingAway(true); |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 373 | mStatusBar.fadeKeyguardWhilePulsing(); |
Jorim Jaggi | e93698b | 2016-11-11 18:24:38 -0800 | [diff] [blame] | 374 | animateScrimControllerKeyguardFadingOut(delay, fadeoutDuration, |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 375 | mStatusBar::hideKeyguard, false /* skipFirstFrame */); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 376 | } else { |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 377 | mFingerprintUnlockController.startKeyguardFadingAway(); |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 378 | mStatusBar.setKeyguardFadingAway(startTime, delay, fadeoutDuration); |
| 379 | boolean staying = mStatusBar.hideKeyguard(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 380 | if (!staying) { |
| 381 | mStatusBarWindowManager.setKeyguardFadingAway(true); |
Jorim Jaggi | 8adb30c | 2016-09-13 15:02:22 -0700 | [diff] [blame] | 382 | if (mFingerprintUnlockController.getMode() == MODE_WAKE_AND_UNLOCK) { |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 383 | if (!mScreenTurnedOn) { |
| 384 | mDeferScrimFadeOut = true; |
| 385 | } else { |
| 386 | |
| 387 | // Screen is already on, don't defer with fading out. |
| 388 | animateScrimControllerKeyguardFadingOut(0, |
Jorim Jaggi | ab45a21 | 2015-08-20 16:59:44 -0700 | [diff] [blame] | 389 | WAKE_AND_UNLOCK_SCRIM_FADEOUT_DURATION_MS, |
| 390 | true /* skipFirstFrame */); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 391 | } |
| 392 | } else { |
Jorim Jaggi | ab45a21 | 2015-08-20 16:59:44 -0700 | [diff] [blame] | 393 | animateScrimControllerKeyguardFadingOut(delay, fadeoutDuration, |
| 394 | false /* skipFirstFrame */); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 395 | } |
| 396 | } else { |
| 397 | mScrimController.animateGoingToFullShade(delay, fadeoutDuration); |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 398 | mStatusBar.finishKeyguardFadingAway(); |
Adrian Roos | 88e61aa | 2017-05-23 16:16:50 -0700 | [diff] [blame] | 399 | mFingerprintUnlockController.finishKeyguardFadingAway(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 400 | } |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 401 | } |
Jorim Jaggi | 67b29d5 | 2017-06-09 18:00:00 -0700 | [diff] [blame] | 402 | updateStates(); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 403 | mStatusBarWindowManager.setKeyguardShowing(false); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 404 | mViewMediatorCallback.keyguardGone(); |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 405 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 406 | } |
| 407 | |
Selim Cinek | aa8bbf1 | 2016-05-04 14:13:20 -0700 | [diff] [blame] | 408 | public void onDensityOrFontScaleChanged() { |
| 409 | mBouncer.hide(true /* destroyView */); |
| 410 | } |
| 411 | |
Jorim Jaggi | ab45a21 | 2015-08-20 16:59:44 -0700 | [diff] [blame] | 412 | private void animateScrimControllerKeyguardFadingOut(long delay, long duration, |
| 413 | boolean skipFirstFrame) { |
| 414 | animateScrimControllerKeyguardFadingOut(delay, duration, null /* endRunnable */, |
| 415 | skipFirstFrame); |
Jorim Jaggi | 9097885 | 2015-08-18 19:55:53 -0700 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | private void animateScrimControllerKeyguardFadingOut(long delay, long duration, |
Jorim Jaggi | ab45a21 | 2015-08-20 16:59:44 -0700 | [diff] [blame] | 419 | final Runnable endRunnable, boolean skipFirstFrame) { |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 420 | Trace.asyncTraceBegin(Trace.TRACE_TAG_VIEW, "Fading out", 0); |
| 421 | mScrimController.animateKeyguardFadingOut(delay, duration, new Runnable() { |
| 422 | @Override |
| 423 | public void run() { |
Jorim Jaggi | 9097885 | 2015-08-18 19:55:53 -0700 | [diff] [blame] | 424 | if (endRunnable != null) { |
| 425 | endRunnable.run(); |
| 426 | } |
Jorim Jaggi | 56fd70c | 2016-10-27 19:57:08 -0700 | [diff] [blame] | 427 | mContainer.postDelayed(() -> mStatusBarWindowManager.setKeyguardFadingAway(false), |
| 428 | 100); |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 429 | mStatusBar.finishKeyguardFadingAway(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 430 | mFingerprintUnlockController.finishKeyguardFadingAway(); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 431 | WindowManagerGlobal.getInstance().trimMemory( |
| 432 | ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN); |
| 433 | Trace.asyncTraceEnd(Trace.TRACE_TAG_VIEW, "Fading out", 0); |
| 434 | } |
Jorim Jaggi | ab45a21 | 2015-08-20 16:59:44 -0700 | [diff] [blame] | 435 | }, skipFirstFrame); |
Jorim Jaggi | 8adb30c | 2016-09-13 15:02:22 -0700 | [diff] [blame] | 436 | if (mFingerprintUnlockController.getMode() == MODE_WAKE_AND_UNLOCK |
| 437 | && LatencyTracker.isEnabled(mContext)) { |
| 438 | DejankUtils.postAfterTraversal(() -> |
| 439 | LatencyTracker.getInstance(mContext).onActionEnd( |
| 440 | LatencyTracker.ACTION_FINGERPRINT_WAKE_AND_UNLOCK)); |
| 441 | } |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 442 | } |
| 443 | |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 444 | private void executeAfterKeyguardGoneAction() { |
| 445 | if (mAfterKeyguardGoneAction != null) { |
| 446 | mAfterKeyguardGoneAction.onDismiss(); |
| 447 | mAfterKeyguardGoneAction = null; |
| 448 | } |
Jorim Jaggi | bcbe948 | 2016-11-23 17:37:49 +0100 | [diff] [blame] | 449 | for (int i = 0; i < mAfterKeyguardGoneRunnables.size(); i++) { |
| 450 | mAfterKeyguardGoneRunnables.get(i).run(); |
| 451 | } |
| 452 | mAfterKeyguardGoneRunnables.clear(); |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 453 | } |
| 454 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 455 | /** |
| 456 | * Dismisses the keyguard by going to the next screen or making it gone. |
| 457 | */ |
Jorim Jaggi | 8d5a6e7 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 458 | public void dismissAndCollapse() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 459 | mStatusBar.executeRunnableDismissingKeyguard(null, null, true, false, true); |
Jorim Jaggi | 8d5a6e7 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 460 | } |
| 461 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 462 | public void dismiss() { |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 463 | showBouncer(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 464 | } |
| 465 | |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 466 | /** |
| 467 | * WARNING: This method might cause Binder calls. |
| 468 | */ |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 469 | public boolean isSecure() { |
| 470 | return mBouncer.isSecure(); |
| 471 | } |
| 472 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 473 | /** |
| 474 | * @return Whether the keyguard is showing |
| 475 | */ |
| 476 | public boolean isShowing() { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 477 | return mShowing; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 478 | } |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 479 | |
| 480 | /** |
| 481 | * Notifies this manager that the back button has been pressed. |
| 482 | * |
| 483 | * @return whether the back press has been handled |
| 484 | */ |
| 485 | public boolean onBackPressed() { |
| 486 | if (mBouncer.isShowing()) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 487 | mStatusBar.endAffordanceLaunch(); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 488 | reset(true /* hideBouncerWhenShowing */); |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 489 | return true; |
| 490 | } |
| 491 | return false; |
| 492 | } |
| 493 | |
Jim Miller | f41fc96 | 2014-06-18 16:33:51 -0700 | [diff] [blame] | 494 | public boolean isBouncerShowing() { |
| 495 | return mBouncer.isShowing(); |
| 496 | } |
| 497 | |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 498 | private long getNavBarShowDelay() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 499 | if (mStatusBar.isKeyguardFadingAway()) { |
| 500 | return mStatusBar.getKeyguardFadingAwayDelay(); |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 501 | } else { |
| 502 | |
| 503 | // Keyguard is not going away, thus we are showing the navigation bar because the |
| 504 | // bouncer is appearing. |
| 505 | return NAV_BAR_SHOW_DELAY_BOUNCER; |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | private Runnable mMakeNavigationBarVisibleRunnable = new Runnable() { |
| 510 | @Override |
| 511 | public void run() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 512 | mStatusBar.getNavigationBarView().getRootView().setVisibility(View.VISIBLE); |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 513 | } |
| 514 | }; |
| 515 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 516 | protected void updateStates() { |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 517 | int vis = mContainer.getSystemUiVisibility(); |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 518 | boolean showing = mShowing; |
| 519 | boolean occluded = mOccluded; |
| 520 | boolean bouncerShowing = mBouncer.isShowing(); |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 521 | boolean bouncerDismissible = !mBouncer.isFullscreenBouncer(); |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 522 | boolean remoteInputActive = mRemoteInputActive; |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 523 | |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 524 | if ((bouncerDismissible || !showing || remoteInputActive) != |
| 525 | (mLastBouncerDismissible || !mLastShowing || mLastRemoteInputActive) |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 526 | || mFirstUpdate) { |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 527 | if (bouncerDismissible || !showing || remoteInputActive) { |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 528 | mContainer.setSystemUiVisibility(vis & ~View.STATUS_BAR_DISABLE_BACK); |
Jason Monk | 1e68fb3 | 2014-05-02 16:06:20 -0400 | [diff] [blame] | 529 | } else { |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 530 | mContainer.setSystemUiVisibility(vis | View.STATUS_BAR_DISABLE_BACK); |
Jason Monk | 1e68fb3 | 2014-05-02 16:06:20 -0400 | [diff] [blame] | 531 | } |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 532 | } |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 533 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 534 | boolean navBarVisible = isNavBarVisible(); |
| 535 | boolean lastNavBarVisible = getLastNavBarVisible(); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 536 | if (navBarVisible != lastNavBarVisible || mFirstUpdate) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 537 | if (mStatusBar.getNavigationBarView() != null) { |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 538 | if (navBarVisible) { |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 539 | long delay = getNavBarShowDelay(); |
| 540 | if (delay == 0) { |
| 541 | mMakeNavigationBarVisibleRunnable.run(); |
| 542 | } else { |
| 543 | mContainer.postOnAnimationDelayed(mMakeNavigationBarVisibleRunnable, |
| 544 | delay); |
| 545 | } |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 546 | } else { |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 547 | mContainer.removeCallbacks(mMakeNavigationBarVisibleRunnable); |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 548 | mStatusBar.getNavigationBarView().getRootView().setVisibility(View.GONE); |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 549 | } |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) { |
| 554 | mStatusBarWindowManager.setBouncerShowing(bouncerShowing); |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 555 | mStatusBar.setBouncerShowing(bouncerShowing); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 556 | mScrimController.setBouncerShowing(bouncerShowing); |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext); |
| 560 | if ((showing && !occluded) != (mLastShowing && !mLastOccluded) || mFirstUpdate) { |
Jorim Jaggi | 6a15d52 | 2015-09-22 15:55:33 -0700 | [diff] [blame] | 561 | updateMonitor.onKeyguardVisibilityChanged(showing && !occluded); |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 562 | } |
| 563 | if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) { |
| 564 | updateMonitor.sendKeyguardBouncerChanged(bouncerShowing); |
| 565 | } |
| 566 | |
| 567 | mFirstUpdate = false; |
| 568 | mLastShowing = showing; |
| 569 | mLastOccluded = occluded; |
| 570 | mLastBouncerShowing = bouncerShowing; |
| 571 | mLastBouncerDismissible = bouncerDismissible; |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 572 | mLastRemoteInputActive = remoteInputActive; |
Jorim Jaggi | 67b29d5 | 2017-06-09 18:00:00 -0700 | [diff] [blame] | 573 | mLastDeferScrimFadeOut = mDeferScrimFadeOut; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 574 | mStatusBar.onKeyguardViewManagerStatesUpdated(); |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 575 | } |
Jorim Jaggi | 8c8bcc1 | 2014-04-16 21:36:51 +0200 | [diff] [blame] | 576 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 577 | /** |
| 578 | * @return Whether the navigation bar should be made visible based on the current state. |
| 579 | */ |
| 580 | protected boolean isNavBarVisible() { |
Jorim Jaggi | 67b29d5 | 2017-06-09 18:00:00 -0700 | [diff] [blame] | 581 | return (!(mShowing && !mOccluded) || mBouncer.isShowing() || mRemoteInputActive) |
| 582 | && !mDeferScrimFadeOut; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 583 | } |
| 584 | |
| 585 | /** |
| 586 | * @return Whether the navigation bar was made visible based on the last known state. |
| 587 | */ |
| 588 | protected boolean getLastNavBarVisible() { |
Jorim Jaggi | 67b29d5 | 2017-06-09 18:00:00 -0700 | [diff] [blame] | 589 | return (!(mLastShowing && !mLastOccluded) || mLastBouncerShowing || mLastRemoteInputActive) |
| 590 | && !mLastDeferScrimFadeOut; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 591 | } |
| 592 | |
Selim Cinek | 2854019 | 2016-02-19 17:25:08 -0800 | [diff] [blame] | 593 | public boolean shouldDismissOnMenuPressed() { |
| 594 | return mBouncer.shouldDismissOnMenuPressed(); |
Jorim Jaggi | 8c8bcc1 | 2014-04-16 21:36:51 +0200 | [diff] [blame] | 595 | } |
Jorim Jaggi | df99351 | 2014-05-13 23:06:35 +0200 | [diff] [blame] | 596 | |
| 597 | public boolean interceptMediaKey(KeyEvent event) { |
| 598 | return mBouncer.interceptMediaKey(event); |
| 599 | } |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 600 | |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 601 | public void readyForKeyguardDone() { |
| 602 | mViewMediatorCallback.readyForKeyguardDone(); |
| 603 | } |
| 604 | |
Jorim Jaggi | 84a3e7a | 2014-08-13 17:58:58 +0200 | [diff] [blame] | 605 | public boolean shouldDisableWindowAnimationsForUnlock() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 606 | return mStatusBar.isInLaunchTransition(); |
Jorim Jaggi | 84a3e7a | 2014-08-13 17:58:58 +0200 | [diff] [blame] | 607 | } |
| 608 | |
| 609 | public boolean isGoingToNotificationShade() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 610 | return mStatusBar.isGoingToNotificationShade(); |
Jorim Jaggi | 84a3e7a | 2014-08-13 17:58:58 +0200 | [diff] [blame] | 611 | } |
Adrian Roos | 31b844b | 2014-11-21 13:55:09 +0100 | [diff] [blame] | 612 | |
| 613 | public boolean isSecure(int userId) { |
| 614 | return mBouncer.isSecure() || mLockPatternUtils.isSecure(userId); |
| 615 | } |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 616 | |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 617 | public void keyguardGoingAway() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 618 | mStatusBar.keyguardGoingAway(); |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 619 | } |
Jim Miller | 25d7e51 | 2015-03-03 17:12:09 -0800 | [diff] [blame] | 620 | |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 621 | public void animateCollapsePanels(float speedUpFactor) { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 622 | mStatusBar.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */, |
Jorim Jaggi | f3b3bee | 2015-04-16 14:57:34 -0700 | [diff] [blame] | 623 | false /* delayed */, speedUpFactor); |
Jim Miller | 25d7e51 | 2015-03-03 17:12:09 -0800 | [diff] [blame] | 624 | } |
Jorim Jaggi | 5cc8659 | 2015-06-08 14:48:28 -0700 | [diff] [blame] | 625 | |
| 626 | /** |
| 627 | * Notifies that the user has authenticated by other means than using the bouncer, for example, |
| 628 | * fingerprint. |
| 629 | */ |
Jorim Jaggi | 25b4d4b | 2015-08-11 15:54:06 -0700 | [diff] [blame] | 630 | public void notifyKeyguardAuthenticated(boolean strongAuth) { |
| 631 | mBouncer.notifyKeyguardAuthenticated(strongAuth); |
Jorim Jaggi | 5cc8659 | 2015-06-08 14:48:28 -0700 | [diff] [blame] | 632 | } |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 633 | |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 634 | public void showBouncerMessage(String message, int color) { |
| 635 | mBouncer.showMessage(message, color); |
| 636 | } |
Jorim Jaggi | b774e55 | 2015-08-24 14:52:45 -0700 | [diff] [blame] | 637 | |
| 638 | public ViewRootImpl getViewRootImpl() { |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 639 | return mStatusBar.getStatusBarView().getViewRootImpl(); |
Jorim Jaggi | b774e55 | 2015-08-24 14:52:45 -0700 | [diff] [blame] | 640 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 641 | } |