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 | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 22 | import android.os.RemoteException; |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 23 | import android.os.SystemClock; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 24 | import android.util.Slog; |
Jorim Jaggi | df99351 | 2014-05-13 23:06:35 +0200 | [diff] [blame] | 25 | import android.view.KeyEvent; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 26 | import android.view.View; |
| 27 | import android.view.ViewGroup; |
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 | |
| 30 | import com.android.internal.policy.IKeyguardShowCallback; |
| 31 | import com.android.internal.widget.LockPatternUtils; |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 32 | import com.android.keyguard.KeyguardUpdateMonitor; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 33 | import com.android.keyguard.ViewMediatorCallback; |
Jim Miller | 25d7e51 | 2015-03-03 17:12:09 -0800 | [diff] [blame] | 34 | import com.android.systemui.statusbar.CommandQueue; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 35 | |
Jorim Jaggi | 6b88cdf | 2014-12-22 20:56:50 +0100 | [diff] [blame] | 36 | import static com.android.keyguard.KeyguardHostView.OnDismissAction; |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 37 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 38 | /** |
| 39 | * Manages creating, showing, hiding and resetting the keyguard within the status bar. Calls back |
| 40 | * via {@link ViewMediatorCallback} to poke the wake lock and report that the keyguard is done, |
| 41 | * which is in turn, reported to this class by the current |
| 42 | * {@link com.android.keyguard.KeyguardViewBase}. |
| 43 | */ |
| 44 | public class StatusBarKeyguardViewManager { |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 45 | |
| 46 | // When hiding the Keyguard with timing supplied from WindowManager, better be early than late. |
| 47 | private static final long HIDE_TIMING_CORRECTION_MS = -3 * 16; |
| 48 | |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 49 | // Delay for showing the navigation bar when the bouncer appears. This should be kept in sync |
| 50 | // with the appear animations of the PIN/pattern/password views. |
| 51 | private static final long NAV_BAR_SHOW_DELAY_BOUNCER = 320; |
| 52 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 53 | private static String TAG = "StatusBarKeyguardViewManager"; |
| 54 | |
| 55 | private final Context mContext; |
| 56 | |
| 57 | private LockPatternUtils mLockPatternUtils; |
| 58 | private ViewMediatorCallback mViewMediatorCallback; |
| 59 | private PhoneStatusBar mPhoneStatusBar; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 60 | private ScrimController mScrimController; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 61 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 62 | private ViewGroup mContainer; |
| 63 | private StatusBarWindowManager mStatusBarWindowManager; |
| 64 | |
| 65 | private boolean mScreenOn = false; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 66 | private KeyguardBouncer mBouncer; |
| 67 | private boolean mShowing; |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 68 | private boolean mOccluded; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 69 | |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 70 | private boolean mFirstUpdate = true; |
| 71 | private boolean mLastShowing; |
| 72 | private boolean mLastOccluded; |
| 73 | private boolean mLastBouncerShowing; |
| 74 | private boolean mLastBouncerDismissible; |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 75 | private OnDismissAction mAfterKeyguardGoneAction; |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 76 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 77 | public StatusBarKeyguardViewManager(Context context, ViewMediatorCallback callback, |
| 78 | LockPatternUtils lockPatternUtils) { |
| 79 | mContext = context; |
| 80 | mViewMediatorCallback = callback; |
| 81 | mLockPatternUtils = lockPatternUtils; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | public void registerStatusBar(PhoneStatusBar phoneStatusBar, |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 85 | ViewGroup container, StatusBarWindowManager statusBarWindowManager, |
| 86 | ScrimController scrimController) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 87 | mPhoneStatusBar = phoneStatusBar; |
| 88 | mContainer = container; |
| 89 | mStatusBarWindowManager = statusBarWindowManager; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 90 | mScrimController = scrimController; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 91 | mBouncer = new KeyguardBouncer(mContext, mViewMediatorCallback, mLockPatternUtils, |
| 92 | mStatusBarWindowManager, container); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Show the keyguard. Will handle creating and attaching to the view manager |
| 97 | * lazily. |
| 98 | */ |
| 99 | public void show(Bundle options) { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 100 | mShowing = true; |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 101 | mStatusBarWindowManager.setKeyguardShowing(true); |
Jorim Jaggi | 43bdbbd | 2014-05-09 16:05:53 +0200 | [diff] [blame] | 102 | reset(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 103 | } |
| 104 | |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 105 | /** |
| 106 | * Shows the notification keyguard or the bouncer depending on |
| 107 | * {@link KeyguardBouncer#needsFullscreenBouncer()}. |
| 108 | */ |
| 109 | private void showBouncerOrKeyguard() { |
| 110 | if (mBouncer.needsFullscreenBouncer()) { |
| 111 | |
| 112 | // The keyguard might be showing (already). So we need to hide it. |
| 113 | mPhoneStatusBar.hideKeyguard(); |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 114 | mBouncer.show(true /* resetSecuritySelection */); |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 115 | } else { |
| 116 | mPhoneStatusBar.showKeyguard(); |
Jorim Jaggi | a0be6d5 | 2014-05-26 03:01:13 +0200 | [diff] [blame] | 117 | mBouncer.hide(false /* destroyView */); |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 118 | mBouncer.prepare(); |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 119 | } |
| 120 | } |
| 121 | |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 122 | private void showBouncer() { |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 123 | if (mShowing) { |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 124 | mBouncer.show(false /* resetSecuritySelection */); |
Dan Sandler | 3806c77 | 2014-05-08 14:52:10 -0400 | [diff] [blame] | 125 | } |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 126 | updateStates(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 127 | } |
| 128 | |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 129 | public void dismissWithAction(OnDismissAction r, boolean afterKeyguardGone) { |
Adrian Roos | 0002a45 | 2014-07-03 13:46:07 +0200 | [diff] [blame] | 130 | if (mShowing) { |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 131 | if (!afterKeyguardGone) { |
| 132 | mBouncer.showWithDismissAction(r); |
| 133 | } else { |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 134 | mBouncer.show(false /* resetSecuritySelection */); |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 135 | mAfterKeyguardGoneAction = r; |
| 136 | } |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 137 | } |
| 138 | updateStates(); |
| 139 | } |
| 140 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 141 | /** |
| 142 | * Reset the state of the view. |
| 143 | */ |
| 144 | public void reset() { |
Jorim Jaggi | 43bdbbd | 2014-05-09 16:05:53 +0200 | [diff] [blame] | 145 | if (mShowing) { |
| 146 | if (mOccluded) { |
| 147 | mPhoneStatusBar.hideKeyguard(); |
Jorim Jaggi | a0be6d5 | 2014-05-26 03:01:13 +0200 | [diff] [blame] | 148 | mBouncer.hide(false /* destroyView */); |
Jorim Jaggi | 43bdbbd | 2014-05-09 16:05:53 +0200 | [diff] [blame] | 149 | } else { |
| 150 | showBouncerOrKeyguard(); |
| 151 | } |
| 152 | updateStates(); |
Dan Sandler | 3806c77 | 2014-05-08 14:52:10 -0400 | [diff] [blame] | 153 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | public void onScreenTurnedOff() { |
| 157 | mScreenOn = false; |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 158 | mPhoneStatusBar.onScreenTurnedOff(); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 159 | mBouncer.onScreenTurnedOff(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | public void onScreenTurnedOn(final IKeyguardShowCallback callback) { |
| 163 | mScreenOn = true; |
Jorim Jaggi | 75c9504 | 2014-05-16 19:09:59 +0200 | [diff] [blame] | 164 | mPhoneStatusBar.onScreenTurnedOn(); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 165 | if (callback != null) { |
| 166 | callbackAfterDraw(callback); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 167 | } |
| 168 | } |
| 169 | |
| 170 | private void callbackAfterDraw(final IKeyguardShowCallback callback) { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 171 | mContainer.post(new Runnable() { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 172 | @Override |
| 173 | public void run() { |
| 174 | try { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 175 | callback.onShown(mContainer.getWindowToken()); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 176 | } catch (RemoteException e) { |
| 177 | Slog.w(TAG, "Exception calling onShown():", e); |
| 178 | } |
| 179 | } |
| 180 | }); |
| 181 | } |
| 182 | |
| 183 | public void verifyUnlock() { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 184 | dismiss(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | public void setNeedsInput(boolean needsInput) { |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 188 | mStatusBarWindowManager.setKeyguardNeedsInput(needsInput); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 189 | } |
| 190 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 191 | public void setOccluded(boolean occluded) { |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 192 | if (occluded && !mOccluded && mShowing) { |
| 193 | if (mPhoneStatusBar.isInLaunchTransition()) { |
| 194 | mOccluded = true; |
| 195 | mPhoneStatusBar.fadeKeyguardAfterLaunchTransition(null /* beforeFading */, |
| 196 | new Runnable() { |
| 197 | @Override |
| 198 | public void run() { |
Jorim Jaggi | 826730a | 2014-12-08 21:05:13 +0100 | [diff] [blame] | 199 | mStatusBarWindowManager.setKeyguardOccluded(mOccluded); |
Jorim Jaggi | fbc88e1 | 2014-08-14 23:38:15 +0200 | [diff] [blame] | 200 | reset(); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 201 | } |
| 202 | }); |
| 203 | return; |
| 204 | } |
| 205 | } |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 206 | mOccluded = occluded; |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 207 | mStatusBarWindowManager.setKeyguardOccluded(occluded); |
Dan Sandler | 3806c77 | 2014-05-08 14:52:10 -0400 | [diff] [blame] | 208 | reset(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 209 | } |
| 210 | |
Dan Sandler | 4b22bdf | 2014-06-05 00:58:02 -0400 | [diff] [blame] | 211 | public boolean isOccluded() { |
| 212 | return mOccluded; |
| 213 | } |
| 214 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 215 | /** |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 216 | * Starts the animation before we dismiss Keyguard, i.e. an disappearing animation on the |
| 217 | * security view of the bouncer. |
| 218 | * |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 219 | * @param finishRunnable the runnable to be run after the animation finished, or {@code null} if |
| 220 | * no action should be run |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 221 | */ |
| 222 | public void startPreHideAnimation(Runnable finishRunnable) { |
| 223 | if (mBouncer.isShowing()) { |
| 224 | mBouncer.startPreHideAnimation(finishRunnable); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 225 | } else if (finishRunnable != null) { |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 226 | finishRunnable.run(); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 231 | * Hides the keyguard view |
| 232 | */ |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 233 | public void hide(long startTime, final long fadeoutDuration) { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 234 | mShowing = false; |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 235 | |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 236 | long uptimeMillis = SystemClock.uptimeMillis(); |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 237 | long delay = Math.max(0, startTime + HIDE_TIMING_CORRECTION_MS - uptimeMillis); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 238 | |
| 239 | if (mPhoneStatusBar.isInLaunchTransition() ) { |
| 240 | mPhoneStatusBar.fadeKeyguardAfterLaunchTransition(new Runnable() { |
| 241 | @Override |
| 242 | public void run() { |
| 243 | mStatusBarWindowManager.setKeyguardShowing(false); |
| 244 | mStatusBarWindowManager.setKeyguardFadingAway(true); |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 245 | mBouncer.hide(true /* destroyView */); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 246 | updateStates(); |
| 247 | mScrimController.animateKeyguardFadingOut( |
| 248 | PhoneStatusBar.FADE_KEYGUARD_START_DELAY, |
| 249 | PhoneStatusBar.FADE_KEYGUARD_DURATION, null); |
| 250 | } |
| 251 | }, new Runnable() { |
| 252 | @Override |
| 253 | public void run() { |
| 254 | mPhoneStatusBar.hideKeyguard(); |
| 255 | mStatusBarWindowManager.setKeyguardFadingAway(false); |
| 256 | mViewMediatorCallback.keyguardGone(); |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 257 | executeAfterKeyguardGoneAction(); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 258 | } |
| 259 | }); |
| 260 | } else { |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 261 | mPhoneStatusBar.setKeyguardFadingAway(startTime, delay, fadeoutDuration); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 262 | boolean staying = mPhoneStatusBar.hideKeyguard(); |
| 263 | if (!staying) { |
| 264 | mStatusBarWindowManager.setKeyguardFadingAway(true); |
| 265 | mScrimController.animateKeyguardFadingOut(delay, fadeoutDuration, new Runnable() { |
| 266 | @Override |
| 267 | public void run() { |
| 268 | mStatusBarWindowManager.setKeyguardFadingAway(false); |
| 269 | mPhoneStatusBar.finishKeyguardFadingAway(); |
Jorim Jaggi | 786afcb | 2014-09-25 02:41:29 +0200 | [diff] [blame] | 270 | WindowManagerGlobal.getInstance().trimMemory( |
| 271 | ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN); |
Jorim Jaggi | dbc3dce | 2014-08-01 01:16:36 +0200 | [diff] [blame] | 272 | } |
| 273 | }); |
| 274 | } else { |
| 275 | mScrimController.animateGoingToFullShade(delay, fadeoutDuration); |
| 276 | mPhoneStatusBar.finishKeyguardFadingAway(); |
| 277 | } |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 278 | mStatusBarWindowManager.setKeyguardShowing(false); |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 279 | mBouncer.hide(true /* destroyView */); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 280 | mViewMediatorCallback.keyguardGone(); |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 281 | executeAfterKeyguardGoneAction(); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 282 | updateStates(); |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 283 | } |
Jorim Jaggi | 44cf919 | 2014-06-17 19:16:00 -0700 | [diff] [blame] | 284 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 285 | } |
| 286 | |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 287 | private void executeAfterKeyguardGoneAction() { |
| 288 | if (mAfterKeyguardGoneAction != null) { |
| 289 | mAfterKeyguardGoneAction.onDismiss(); |
| 290 | mAfterKeyguardGoneAction = null; |
| 291 | } |
| 292 | } |
| 293 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 294 | /** |
| 295 | * Dismisses the keyguard by going to the next screen or making it gone. |
| 296 | */ |
| 297 | public void dismiss() { |
| 298 | if (mScreenOn) { |
Jorim Jaggi | 0bed7f2 | 2014-04-03 16:12:54 +0200 | [diff] [blame] | 299 | showBouncer(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 300 | } |
| 301 | } |
| 302 | |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 303 | /** |
| 304 | * WARNING: This method might cause Binder calls. |
| 305 | */ |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 306 | public boolean isSecure() { |
| 307 | return mBouncer.isSecure(); |
| 308 | } |
| 309 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 310 | /** |
| 311 | * @return Whether the keyguard is showing |
| 312 | */ |
| 313 | public boolean isShowing() { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 314 | return mShowing; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 315 | } |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 316 | |
| 317 | /** |
| 318 | * Notifies this manager that the back button has been pressed. |
| 319 | * |
| 320 | * @return whether the back press has been handled |
| 321 | */ |
| 322 | public boolean onBackPressed() { |
| 323 | if (mBouncer.isShowing()) { |
Jorim Jaggi | 6bad244 | 2014-08-26 15:16:57 +0200 | [diff] [blame] | 324 | reset(); |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 325 | return true; |
| 326 | } |
| 327 | return false; |
| 328 | } |
| 329 | |
Jim Miller | f41fc96 | 2014-06-18 16:33:51 -0700 | [diff] [blame] | 330 | public boolean isBouncerShowing() { |
| 331 | return mBouncer.isShowing(); |
| 332 | } |
| 333 | |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 334 | private long getNavBarShowDelay() { |
| 335 | if (mPhoneStatusBar.isKeyguardFadingAway()) { |
| 336 | return mPhoneStatusBar.getKeyguardFadingAwayDelay(); |
| 337 | } else { |
| 338 | |
| 339 | // Keyguard is not going away, thus we are showing the navigation bar because the |
| 340 | // bouncer is appearing. |
| 341 | return NAV_BAR_SHOW_DELAY_BOUNCER; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | private Runnable mMakeNavigationBarVisibleRunnable = new Runnable() { |
| 346 | @Override |
| 347 | public void run() { |
| 348 | mPhoneStatusBar.getNavigationBarView().setVisibility(View.VISIBLE); |
| 349 | } |
| 350 | }; |
| 351 | |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 352 | private void updateStates() { |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 353 | int vis = mContainer.getSystemUiVisibility(); |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 354 | boolean showing = mShowing; |
| 355 | boolean occluded = mOccluded; |
| 356 | boolean bouncerShowing = mBouncer.isShowing(); |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 357 | boolean bouncerDismissible = !mBouncer.isFullscreenBouncer(); |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 358 | |
| 359 | if ((bouncerDismissible || !showing) != (mLastBouncerDismissible || !mLastShowing) |
| 360 | || mFirstUpdate) { |
| 361 | if (bouncerDismissible || !showing) { |
| 362 | mContainer.setSystemUiVisibility(vis & ~View.STATUS_BAR_DISABLE_BACK); |
Jason Monk | 1e68fb3 | 2014-05-02 16:06:20 -0400 | [diff] [blame] | 363 | } else { |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 364 | mContainer.setSystemUiVisibility(vis | View.STATUS_BAR_DISABLE_BACK); |
Jason Monk | 1e68fb3 | 2014-05-02 16:06:20 -0400 | [diff] [blame] | 365 | } |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 366 | } |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 367 | if ((!(showing && !occluded) || bouncerShowing) |
| 368 | != (!(mLastShowing && !mLastOccluded) || mLastBouncerShowing) || mFirstUpdate) { |
| 369 | if (mPhoneStatusBar.getNavigationBarView() != null) { |
| 370 | if (!(showing && !occluded) || bouncerShowing) { |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 371 | mContainer.postOnAnimationDelayed(mMakeNavigationBarVisibleRunnable, |
| 372 | getNavBarShowDelay()); |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 373 | } else { |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 374 | mContainer.removeCallbacks(mMakeNavigationBarVisibleRunnable); |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 375 | mPhoneStatusBar.getNavigationBarView().setVisibility(View.GONE); |
| 376 | } |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) { |
| 381 | mStatusBarWindowManager.setBouncerShowing(bouncerShowing); |
| 382 | mPhoneStatusBar.setBouncerShowing(bouncerShowing); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 383 | mScrimController.setBouncerShowing(bouncerShowing); |
Adrian Roos | b601162 | 2014-05-14 15:52:53 +0200 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext); |
| 387 | if ((showing && !occluded) != (mLastShowing && !mLastOccluded) || mFirstUpdate) { |
| 388 | updateMonitor.sendKeyguardVisibilityChanged(showing && !occluded); |
| 389 | } |
| 390 | if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) { |
| 391 | updateMonitor.sendKeyguardBouncerChanged(bouncerShowing); |
| 392 | } |
| 393 | |
| 394 | mFirstUpdate = false; |
| 395 | mLastShowing = showing; |
| 396 | mLastOccluded = occluded; |
| 397 | mLastBouncerShowing = bouncerShowing; |
| 398 | mLastBouncerDismissible = bouncerDismissible; |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 399 | |
| 400 | mPhoneStatusBar.onKeyguardViewManagerStatesUpdated(); |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 401 | } |
Jorim Jaggi | 8c8bcc1 | 2014-04-16 21:36:51 +0200 | [diff] [blame] | 402 | |
| 403 | public boolean onMenuPressed() { |
| 404 | return mBouncer.onMenuPressed(); |
| 405 | } |
Jorim Jaggi | df99351 | 2014-05-13 23:06:35 +0200 | [diff] [blame] | 406 | |
| 407 | public boolean interceptMediaKey(KeyEvent event) { |
| 408 | return mBouncer.interceptMediaKey(event); |
| 409 | } |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 410 | |
| 411 | public void onActivityDrawn() { |
| 412 | if (mPhoneStatusBar.isCollapsing()) { |
| 413 | mPhoneStatusBar.addPostCollapseAction(new Runnable() { |
| 414 | @Override |
| 415 | public void run() { |
| 416 | mViewMediatorCallback.readyForKeyguardDone(); |
| 417 | } |
| 418 | }); |
| 419 | } else { |
| 420 | mViewMediatorCallback.readyForKeyguardDone(); |
| 421 | } |
| 422 | } |
Jorim Jaggi | 84a3e7a | 2014-08-13 17:58:58 +0200 | [diff] [blame] | 423 | |
| 424 | public boolean shouldDisableWindowAnimationsForUnlock() { |
| 425 | return mPhoneStatusBar.isInLaunchTransition(); |
| 426 | } |
| 427 | |
| 428 | public boolean isGoingToNotificationShade() { |
| 429 | return mPhoneStatusBar.isGoingToNotificationShade(); |
| 430 | } |
Adrian Roos | 31b844b | 2014-11-21 13:55:09 +0100 | [diff] [blame] | 431 | |
| 432 | public boolean isSecure(int userId) { |
| 433 | return mBouncer.isSecure() || mLockPatternUtils.isSecure(userId); |
| 434 | } |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 435 | |
| 436 | public boolean isInputRestricted() { |
| 437 | return mViewMediatorCallback.isInputRestricted(); |
| 438 | } |
Jorim Jaggi | 33ae80e | 2015-02-04 16:37:11 +0100 | [diff] [blame] | 439 | |
| 440 | public void keyguardGoingAway() { |
| 441 | mPhoneStatusBar.keyguardGoingAway(); |
| 442 | } |
Jim Miller | 25d7e51 | 2015-03-03 17:12:09 -0800 | [diff] [blame] | 443 | |
| 444 | public void animateCollapsePanels() { |
| 445 | mPhoneStatusBar.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */); |
| 446 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 447 | } |