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