Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [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 | |
Lucas Dupin | 0df9b7a | 2018-03-15 17:53:17 -0700 | [diff] [blame] | 19 | import static com.android.keyguard.KeyguardSecurityModel.SecurityMode; |
Gus Prevas | ab33679 | 2018-11-14 13:52:20 -0500 | [diff] [blame] | 20 | import static com.android.systemui.plugins.ActivityStarter.OnDismissAction; |
Lucas Dupin | 0df9b7a | 2018-03-15 17:53:17 -0700 | [diff] [blame] | 21 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 22 | import android.content.Context; |
Jason Chang | 1e4a4bd | 2018-05-22 17:30:19 +0800 | [diff] [blame] | 23 | import android.content.res.ColorStateList; |
Jorim Jaggi | fabc743 | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 24 | import android.os.Handler; |
Toni Barzic | 657f885 | 2016-02-04 15:14:49 -0800 | [diff] [blame] | 25 | import android.os.UserHandle; |
Toni Barzic | b799d3f | 2016-02-17 15:09:10 -0800 | [diff] [blame] | 26 | import android.os.UserManager; |
Lucas Dupin | 0df9b7a | 2018-03-15 17:53:17 -0700 | [diff] [blame] | 27 | import android.util.Log; |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 28 | import android.util.MathUtils; |
Toni Barzic | 657f885 | 2016-02-04 15:14:49 -0800 | [diff] [blame] | 29 | import android.util.Slog; |
Jorim Jaggi | df99351 | 2014-05-13 23:06:35 +0200 | [diff] [blame] | 30 | import android.view.KeyEvent; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 31 | import android.view.LayoutInflater; |
| 32 | import android.view.View; |
| 33 | import android.view.ViewGroup; |
Adrian Roos | edfa96f | 2016-01-29 12:46:35 -0800 | [diff] [blame] | 34 | import android.view.ViewTreeObserver; |
Lucas Dupin | 6865b71 | 2017-09-11 12:28:03 -0700 | [diff] [blame] | 35 | import android.view.WindowInsets; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 36 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 37 | import com.android.internal.widget.LockPatternUtils; |
Jorim Jaggi | 6b88cdf | 2014-12-22 20:56:50 +0100 | [diff] [blame] | 38 | import com.android.keyguard.KeyguardHostView; |
Dave Mankoff | f44b13a | 2019-10-03 17:29:58 -0400 | [diff] [blame] | 39 | import com.android.keyguard.KeyguardSecurityModel; |
Selim Cinek | 3122fa8 | 2015-06-18 01:38:59 -0700 | [diff] [blame] | 40 | import com.android.keyguard.KeyguardSecurityView; |
Jorim Jaggi | 25b4d4b | 2015-08-11 15:54:06 -0700 | [diff] [blame] | 41 | import com.android.keyguard.KeyguardUpdateMonitor; |
| 42 | import com.android.keyguard.KeyguardUpdateMonitorCallback; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 43 | import com.android.keyguard.ViewMediatorCallback; |
Jorim Jaggi | 86b273f | 2015-07-14 18:08:43 -0700 | [diff] [blame] | 44 | import com.android.systemui.DejankUtils; |
Dave Mankoff | f44b13a | 2019-10-03 17:29:58 -0400 | [diff] [blame] | 45 | import com.android.systemui.Dependency; |
Hyunyoung Song | 8f9d34c | 2019-08-30 14:47:43 -0700 | [diff] [blame] | 46 | import com.android.systemui.R; |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 47 | import com.android.systemui.keyguard.DismissCallbackRegistry; |
Dave Mankoff | 468d4f6 | 2019-05-08 14:56:29 -0400 | [diff] [blame] | 48 | import com.android.systemui.plugins.FalsingManager; |
Muhammad Qureshi | 9bced7d | 2020-01-16 15:22:12 -0800 | [diff] [blame] | 49 | import com.android.systemui.shared.system.SysUiStatsLog; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 50 | import com.android.systemui.statusbar.policy.KeyguardStateController; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 51 | |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 52 | import java.io.PrintWriter; |
| 53 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 54 | /** |
| 55 | * A class which manages the bouncer on the lockscreen. |
| 56 | */ |
| 57 | public class KeyguardBouncer { |
| 58 | |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 59 | private static final String TAG = "KeyguardBouncer"; |
Lucas Dupin | 7825b94 | 2019-06-03 20:22:39 -0700 | [diff] [blame] | 60 | static final long BOUNCER_FACE_DELAY = 1200; |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 61 | static final float ALPHA_EXPANSION_THRESHOLD = 0.95f; |
Lucas Dupin | f9ca35e | 2018-05-16 20:41:35 -0700 | [diff] [blame] | 62 | static final float EXPANSION_HIDDEN = 1f; |
| 63 | static final float EXPANSION_VISIBLE = 0f; |
Toni Barzic | 657f885 | 2016-02-04 15:14:49 -0800 | [diff] [blame] | 64 | |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 65 | protected final Context mContext; |
| 66 | protected final ViewMediatorCallback mCallback; |
| 67 | protected final LockPatternUtils mLockPatternUtils; |
| 68 | protected final ViewGroup mContainer; |
| 69 | private final FalsingManager mFalsingManager; |
| 70 | private final DismissCallbackRegistry mDismissCallbackRegistry; |
Jorim Jaggi | fabc743 | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 71 | private final Handler mHandler; |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 72 | private final BouncerExpansionCallback mExpansionCallback; |
Lucas Dupin | 787f9a0 | 2019-04-24 14:56:52 -0700 | [diff] [blame] | 73 | private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 74 | private final KeyguardStateController mKeyguardStateController; |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 75 | private final KeyguardUpdateMonitorCallback mUpdateMonitorCallback = |
Jorim Jaggi | 25b4d4b | 2015-08-11 15:54:06 -0700 | [diff] [blame] | 76 | new KeyguardUpdateMonitorCallback() { |
| 77 | @Override |
Adrian Roos | 1de8bcb | 2015-08-19 16:52:52 -0700 | [diff] [blame] | 78 | public void onStrongAuthStateChanged(int userId) { |
Jorim Jaggi | 25b4d4b | 2015-08-11 15:54:06 -0700 | [diff] [blame] | 79 | mBouncerPromptReason = mCallback.getBouncerPromptReason(); |
| 80 | } |
| 81 | }; |
Jorim Jaggi | fabc743 | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 82 | private final Runnable mRemoveViewRunnable = this::removeView; |
Lucas Dupin | 055ef94 | 2019-08-15 11:41:52 -0700 | [diff] [blame] | 83 | private final KeyguardBypassController mKeyguardBypassController; |
Lucas Dupin | 7065900 | 2018-04-30 15:56:52 -0700 | [diff] [blame] | 84 | protected KeyguardHostView mKeyguardView; |
| 85 | private final Runnable mResetRunnable = ()-> { |
| 86 | if (mKeyguardView != null) { |
Lucas Dupin | 8018049 | 2018-05-08 17:06:06 -0700 | [diff] [blame] | 87 | mKeyguardView.resetSecurityContainer(); |
Lucas Dupin | 7065900 | 2018-04-30 15:56:52 -0700 | [diff] [blame] | 88 | } |
| 89 | }; |
Lucas Dupin | 3d565fa | 2018-03-20 15:40:14 -0700 | [diff] [blame] | 90 | |
Selim Cinek | cb3d45a | 2017-09-08 18:00:18 -0700 | [diff] [blame] | 91 | private int mStatusBarHeight; |
Lucas Dupin | 7065900 | 2018-04-30 15:56:52 -0700 | [diff] [blame] | 92 | private float mExpansion = EXPANSION_HIDDEN; |
Lucas Dupin | 3d565fa | 2018-03-20 15:40:14 -0700 | [diff] [blame] | 93 | protected ViewGroup mRoot; |
| 94 | private boolean mShowingSoon; |
| 95 | private int mBouncerPromptReason; |
Lucas Dupin | 28dc9d7 | 2018-03-21 15:59:15 -0700 | [diff] [blame] | 96 | private boolean mIsAnimatingAway; |
Lucas Dupin | f9ca35e | 2018-05-16 20:41:35 -0700 | [diff] [blame] | 97 | private boolean mIsScrimmed; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 98 | |
| 99 | public KeyguardBouncer(Context context, ViewMediatorCallback callback, |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 100 | LockPatternUtils lockPatternUtils, ViewGroup container, |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 101 | DismissCallbackRegistry dismissCallbackRegistry, FalsingManager falsingManager, |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 102 | BouncerExpansionCallback expansionCallback, |
| 103 | KeyguardStateController keyguardStateController, |
Lucas Dupin | 055ef94 | 2019-08-15 11:41:52 -0700 | [diff] [blame] | 104 | KeyguardUpdateMonitor keyguardUpdateMonitor, |
| 105 | KeyguardBypassController keyguardBypassController, Handler handler) { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 106 | mContext = context; |
| 107 | mCallback = callback; |
| 108 | mLockPatternUtils = lockPatternUtils; |
| 109 | mContainer = container; |
Lucas Dupin | 787f9a0 | 2019-04-24 14:56:52 -0700 | [diff] [blame] | 110 | mKeyguardUpdateMonitor = keyguardUpdateMonitor; |
Lucas Dupin | 0df9b7a | 2018-03-15 17:53:17 -0700 | [diff] [blame] | 111 | mFalsingManager = falsingManager; |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 112 | mDismissCallbackRegistry = dismissCallbackRegistry; |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 113 | mExpansionCallback = expansionCallback; |
Lucas Dupin | 787f9a0 | 2019-04-24 14:56:52 -0700 | [diff] [blame] | 114 | mHandler = handler; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 115 | mKeyguardStateController = keyguardStateController; |
Lucas Dupin | 787f9a0 | 2019-04-24 14:56:52 -0700 | [diff] [blame] | 116 | mKeyguardUpdateMonitor.registerCallback(mUpdateMonitorCallback); |
Lucas Dupin | 055ef94 | 2019-08-15 11:41:52 -0700 | [diff] [blame] | 117 | mKeyguardBypassController = keyguardBypassController; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 118 | } |
| 119 | |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 120 | public void show(boolean resetSecuritySelection) { |
Lucas Dupin | f9ca35e | 2018-05-16 20:41:35 -0700 | [diff] [blame] | 121 | show(resetSecuritySelection, true /* scrimmed */); |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 122 | } |
| 123 | |
Lucas Dupin | 0df9b7a | 2018-03-15 17:53:17 -0700 | [diff] [blame] | 124 | /** |
| 125 | * Shows the bouncer. |
| 126 | * |
| 127 | * @param resetSecuritySelection Cleans keyguard view |
Lucas Dupin | f9ca35e | 2018-05-16 20:41:35 -0700 | [diff] [blame] | 128 | * @param isScrimmed true when the bouncer show show scrimmed, false when the user will be |
| 129 | * dragging it and translation should be deferred. |
Lucas Dupin | 0df9b7a | 2018-03-15 17:53:17 -0700 | [diff] [blame] | 130 | */ |
Lucas Dupin | f9ca35e | 2018-05-16 20:41:35 -0700 | [diff] [blame] | 131 | public void show(boolean resetSecuritySelection, boolean isScrimmed) { |
Vadim Tryshev | ec01843 | 2016-02-10 14:11:03 -0800 | [diff] [blame] | 132 | final int keyguardUserId = KeyguardUpdateMonitor.getCurrentUser(); |
| 133 | if (keyguardUserId == UserHandle.USER_SYSTEM && UserManager.isSplitSystemUser()) { |
| 134 | // In split system user mode, we never unlock system user. |
| 135 | return; |
| 136 | } |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 137 | ensureView(); |
Lucas Dupin | 93f714d | 2019-03-26 16:49:24 -0700 | [diff] [blame] | 138 | mIsScrimmed = isScrimmed; |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 139 | |
| 140 | // On the keyguard, we want to show the bouncer when the user drags up, but it's |
| 141 | // not correct to end the falsing session. We still need to verify if those touches |
| 142 | // are valid. |
| 143 | // Later, at the end of the animation, when the bouncer is at the top of the screen, |
| 144 | // onFullyShown() will be called and FalsingManager will stop recording touches. |
Lucas Dupin | f9ca35e | 2018-05-16 20:41:35 -0700 | [diff] [blame] | 145 | if (isScrimmed) { |
Lucas Dupin | 7065900 | 2018-04-30 15:56:52 -0700 | [diff] [blame] | 146 | setExpansion(EXPANSION_VISIBLE); |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 147 | } |
Lucas Dupin | 0df9b7a | 2018-03-15 17:53:17 -0700 | [diff] [blame] | 148 | |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 149 | if (resetSecuritySelection) { |
| 150 | // showPrimarySecurityScreen() updates the current security method. This is needed in |
| 151 | // case we are already showing and the current security method changed. |
Lucas Dupin | 27321c4 | 2019-03-20 16:22:24 -0700 | [diff] [blame] | 152 | showPrimarySecurityScreen(); |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 153 | } |
Lucas Dupin | 93f714d | 2019-03-26 16:49:24 -0700 | [diff] [blame] | 154 | |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 155 | if (mRoot.getVisibility() == View.VISIBLE || mShowingSoon) { |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 156 | return; |
| 157 | } |
Jorim Jaggi | 0bed7f2 | 2014-04-03 16:12:54 +0200 | [diff] [blame] | 158 | |
Selim Cinek | 1a891a9 | 2017-12-04 17:41:27 +0100 | [diff] [blame] | 159 | final int activeUserId = KeyguardUpdateMonitor.getCurrentUser(); |
Xiaohui Chen | d743cef | 2016-10-03 09:55:53 -0700 | [diff] [blame] | 160 | final boolean isSystemUser = |
| 161 | UserManager.isSplitSystemUser() && activeUserId == UserHandle.USER_SYSTEM; |
| 162 | final boolean allowDismissKeyguard = !isSystemUser && activeUserId == keyguardUserId; |
| 163 | |
Toni Barzic | 657f885 | 2016-02-04 15:14:49 -0800 | [diff] [blame] | 164 | // If allowed, try to dismiss the Keyguard. If no security auth (password/pin/pattern) is |
| 165 | // set, this will dismiss the whole Keyguard. Otherwise, show the bouncer. |
Vadim Tryshev | 8702ca7 | 2016-04-22 08:14:12 -0700 | [diff] [blame] | 166 | if (allowDismissKeyguard && mKeyguardView.dismiss(activeUserId)) { |
Toni Barzic | 657f885 | 2016-02-04 15:14:49 -0800 | [diff] [blame] | 167 | return; |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 168 | } |
Toni Barzic | 657f885 | 2016-02-04 15:14:49 -0800 | [diff] [blame] | 169 | |
| 170 | // This condition may indicate an error on Android, so log it. |
| 171 | if (!allowDismissKeyguard) { |
| 172 | Slog.w(TAG, "User can't dismiss keyguard: " + activeUserId + " != " + keyguardUserId); |
| 173 | } |
| 174 | |
| 175 | mShowingSoon = true; |
| 176 | |
| 177 | // Split up the work over multiple frames. |
Lucas Dupin | 7065900 | 2018-04-30 15:56:52 -0700 | [diff] [blame] | 178 | DejankUtils.removeCallbacks(mResetRunnable); |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 179 | if (mKeyguardStateController.isFaceAuthEnabled() && !needsFullscreenBouncer() |
Lucas Dupin | 055ef94 | 2019-08-15 11:41:52 -0700 | [diff] [blame] | 180 | && !mKeyguardUpdateMonitor.userNeedsStrongAuth() |
| 181 | && !mKeyguardBypassController.getBypassEnabled()) { |
Lucas Dupin | 787f9a0 | 2019-04-24 14:56:52 -0700 | [diff] [blame] | 182 | mHandler.postDelayed(mShowRunnable, BOUNCER_FACE_DELAY); |
| 183 | } else { |
| 184 | DejankUtils.postAfterTraversal(mShowRunnable); |
| 185 | } |
Matthew Ng | 66f0b70 | 2017-12-08 12:58:42 -0800 | [diff] [blame] | 186 | |
| 187 | mCallback.onBouncerVisiblityChanged(true /* shown */); |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 188 | mExpansionCallback.onStartingToShow(); |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 189 | } |
| 190 | |
Lucas Dupin | 93f714d | 2019-03-26 16:49:24 -0700 | [diff] [blame] | 191 | public boolean isScrimmed() { |
| 192 | return mIsScrimmed; |
Lucas Dupin | f9ca35e | 2018-05-16 20:41:35 -0700 | [diff] [blame] | 193 | } |
| 194 | |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 195 | /** |
| 196 | * This method must be called at the end of the bouncer animation when |
| 197 | * the translation is performed manually by the user, otherwise FalsingManager |
| 198 | * will never be notified and its internal state will be out of sync. |
| 199 | */ |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 200 | private void onFullyShown() { |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 201 | mFalsingManager.onBouncerShown(); |
Lucas Dupin | d2ce46d | 2018-04-04 17:00:29 -0700 | [diff] [blame] | 202 | if (mKeyguardView == null) { |
| 203 | Log.wtf(TAG, "onFullyShown when view was null"); |
| 204 | } else { |
| 205 | mKeyguardView.onResume(); |
| 206 | } |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | /** |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 210 | * @see #onFullyShown() |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 211 | */ |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 212 | private void onFullyHidden() { |
Lucas Dupin | 9b8e5e3 | 2019-07-24 16:36:14 -0700 | [diff] [blame] | 213 | cancelShowRunnable(); |
| 214 | if (mRoot != null) { |
| 215 | mRoot.setVisibility(View.INVISIBLE); |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 216 | } |
Lucas Dupin | 9b8e5e3 | 2019-07-24 16:36:14 -0700 | [diff] [blame] | 217 | mFalsingManager.onBouncerHidden(); |
| 218 | DejankUtils.postAfterTraversal(mResetRunnable); |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 219 | } |
| 220 | |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 221 | private final Runnable mShowRunnable = new Runnable() { |
| 222 | @Override |
| 223 | public void run() { |
Jorim Jaggi | 0bed7f2 | 2014-04-03 16:12:54 +0200 | [diff] [blame] | 224 | mRoot.setVisibility(View.VISIBLE); |
Selim Cinek | 3122fa8 | 2015-06-18 01:38:59 -0700 | [diff] [blame] | 225 | showPromptReason(mBouncerPromptReason); |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 226 | final CharSequence customMessage = mCallback.consumeCustomMessage(); |
| 227 | if (customMessage != null) { |
| 228 | mKeyguardView.showErrorMessage(customMessage); |
| 229 | } |
Selim Cinek | cb3d45a | 2017-09-08 18:00:18 -0700 | [diff] [blame] | 230 | // We might still be collapsed and the view didn't have time to layout yet or still |
| 231 | // be small, let's wait on the predraw to do the animation in that case. |
| 232 | if (mKeyguardView.getHeight() != 0 && mKeyguardView.getHeight() != mStatusBarHeight) { |
Adrian Roos | edfa96f | 2016-01-29 12:46:35 -0800 | [diff] [blame] | 233 | mKeyguardView.startAppearAnimation(); |
| 234 | } else { |
| 235 | mKeyguardView.getViewTreeObserver().addOnPreDrawListener( |
| 236 | new ViewTreeObserver.OnPreDrawListener() { |
| 237 | @Override |
| 238 | public boolean onPreDraw() { |
| 239 | mKeyguardView.getViewTreeObserver().removeOnPreDrawListener(this); |
| 240 | mKeyguardView.startAppearAnimation(); |
| 241 | return true; |
| 242 | } |
| 243 | }); |
| 244 | mKeyguardView.requestLayout(); |
| 245 | } |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 246 | mShowingSoon = false; |
Lucas Dupin | 7065900 | 2018-04-30 15:56:52 -0700 | [diff] [blame] | 247 | if (mExpansion == EXPANSION_VISIBLE) { |
| 248 | mKeyguardView.onResume(); |
Wang, ArvinX | a2d94c5 | 2018-09-12 11:31:32 +0800 | [diff] [blame] | 249 | mKeyguardView.resetSecurityContainer(); |
Lucas Dupin | 7065900 | 2018-04-30 15:56:52 -0700 | [diff] [blame] | 250 | } |
Muhammad Qureshi | 9bced7d | 2020-01-16 15:22:12 -0800 | [diff] [blame] | 251 | SysUiStatsLog.write(SysUiStatsLog.KEYGUARD_BOUNCER_STATE_CHANGED, |
| 252 | SysUiStatsLog.KEYGUARD_BOUNCER_STATE_CHANGED__STATE__SHOWN); |
Jorim Jaggi | 0bed7f2 | 2014-04-03 16:12:54 +0200 | [diff] [blame] | 253 | } |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 254 | }; |
| 255 | |
Selim Cinek | 3122fa8 | 2015-06-18 01:38:59 -0700 | [diff] [blame] | 256 | /** |
| 257 | * Show a string explaining why the security view needs to be solved. |
| 258 | * |
| 259 | * @param reason a flag indicating which string should be shown, see |
| 260 | * {@link KeyguardSecurityView#PROMPT_REASON_NONE} |
| 261 | * and {@link KeyguardSecurityView#PROMPT_REASON_RESTART} |
| 262 | */ |
| 263 | public void showPromptReason(int reason) { |
Lucas Dupin | 0df9b7a | 2018-03-15 17:53:17 -0700 | [diff] [blame] | 264 | if (mKeyguardView != null) { |
| 265 | mKeyguardView.showPromptReason(reason); |
| 266 | } else { |
| 267 | Log.w(TAG, "Trying to show prompt reason on empty bouncer"); |
| 268 | } |
Selim Cinek | 3122fa8 | 2015-06-18 01:38:59 -0700 | [diff] [blame] | 269 | } |
| 270 | |
Jason Chang | 1e4a4bd | 2018-05-22 17:30:19 +0800 | [diff] [blame] | 271 | public void showMessage(String message, ColorStateList colorState) { |
Lucas Dupin | 0df9b7a | 2018-03-15 17:53:17 -0700 | [diff] [blame] | 272 | if (mKeyguardView != null) { |
Jason Chang | 1e4a4bd | 2018-05-22 17:30:19 +0800 | [diff] [blame] | 273 | mKeyguardView.showMessage(message, colorState); |
Lucas Dupin | 0df9b7a | 2018-03-15 17:53:17 -0700 | [diff] [blame] | 274 | } else { |
| 275 | Log.w(TAG, "Trying to show message on empty bouncer"); |
| 276 | } |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 277 | } |
| 278 | |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 279 | private void cancelShowRunnable() { |
Jorim Jaggi | 86b273f | 2015-07-14 18:08:43 -0700 | [diff] [blame] | 280 | DejankUtils.removeCallbacks(mShowRunnable); |
Lucas Dupin | 787f9a0 | 2019-04-24 14:56:52 -0700 | [diff] [blame] | 281 | mHandler.removeCallbacks(mShowRunnable); |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 282 | mShowingSoon = false; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 283 | } |
| 284 | |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 285 | public void showWithDismissAction(OnDismissAction r, Runnable cancelAction) { |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 286 | ensureView(); |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 287 | mKeyguardView.setOnDismissAction(r, cancelAction); |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 288 | show(false /* resetSecuritySelection */); |
Adrian Roos | 7d7090d | 2014-05-21 13:10:23 +0200 | [diff] [blame] | 289 | } |
| 290 | |
Jorim Jaggi | a0be6d5 | 2014-05-26 03:01:13 +0200 | [diff] [blame] | 291 | public void hide(boolean destroyView) { |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 292 | if (isShowing()) { |
Muhammad Qureshi | 9bced7d | 2020-01-16 15:22:12 -0800 | [diff] [blame] | 293 | SysUiStatsLog.write(SysUiStatsLog.KEYGUARD_BOUNCER_STATE_CHANGED, |
| 294 | SysUiStatsLog.KEYGUARD_BOUNCER_STATE_CHANGED__STATE__HIDDEN); |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 295 | mDismissCallbackRegistry.notifyDismissCancelled(); |
| 296 | } |
Lucas Dupin | 93f714d | 2019-03-26 16:49:24 -0700 | [diff] [blame] | 297 | mIsScrimmed = false; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 298 | mFalsingManager.onBouncerHidden(); |
Matthew Ng | 66f0b70 | 2017-12-08 12:58:42 -0800 | [diff] [blame] | 299 | mCallback.onBouncerVisiblityChanged(false /* shown */); |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 300 | cancelShowRunnable(); |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 301 | if (mKeyguardView != null) { |
Jorim Jaggi | d944986 | 2015-05-29 14:49:08 -0700 | [diff] [blame] | 302 | mKeyguardView.cancelDismissAction(); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 303 | mKeyguardView.cleanUp(); |
| 304 | } |
Lucas Dupin | 28dc9d7 | 2018-03-21 15:59:15 -0700 | [diff] [blame] | 305 | mIsAnimatingAway = false; |
Jorim Jaggi | fabc743 | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 306 | if (mRoot != null) { |
Jorim Jaggi | a0be6d5 | 2014-05-26 03:01:13 +0200 | [diff] [blame] | 307 | mRoot.setVisibility(View.INVISIBLE); |
Jorim Jaggi | fabc743 | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 308 | if (destroyView) { |
| 309 | |
| 310 | // We have a ViewFlipper that unregisters a broadcast when being detached, which may |
| 311 | // be slow because of AM lock contention during unlocking. We can delay it a bit. |
| 312 | mHandler.postDelayed(mRemoveViewRunnable, 50); |
| 313 | } |
Jorim Jaggi | a0be6d5 | 2014-05-26 03:01:13 +0200 | [diff] [blame] | 314 | } |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 315 | } |
| 316 | |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 317 | /** |
| 318 | * See {@link StatusBarKeyguardViewManager#startPreHideAnimation}. |
| 319 | */ |
| 320 | public void startPreHideAnimation(Runnable runnable) { |
Lucas Dupin | 28dc9d7 | 2018-03-21 15:59:15 -0700 | [diff] [blame] | 321 | mIsAnimatingAway = true; |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 322 | if (mKeyguardView != null) { |
| 323 | mKeyguardView.startDisappearAnimation(runnable); |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 324 | } else if (runnable != null) { |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 325 | runnable.run(); |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 326 | } |
| 327 | } |
| 328 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 329 | /** |
| 330 | * Reset the state of the view. |
| 331 | */ |
| 332 | public void reset() { |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 333 | cancelShowRunnable(); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 334 | inflateView(); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 335 | mFalsingManager.onBouncerHidden(); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | public void onScreenTurnedOff() { |
Dan Sandler | 9ee256d | 2014-04-21 12:05:00 -0400 | [diff] [blame] | 339 | if (mKeyguardView != null && mRoot != null && mRoot.getVisibility() == View.VISIBLE) { |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 340 | mKeyguardView.onPause(); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 341 | } |
| 342 | } |
| 343 | |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 344 | public boolean isShowing() { |
Lucas Dupin | 3d565fa | 2018-03-20 15:40:14 -0700 | [diff] [blame] | 345 | return (mShowingSoon || (mRoot != null && mRoot.getVisibility() == View.VISIBLE)) |
Lucas Dupin | 7065900 | 2018-04-30 15:56:52 -0700 | [diff] [blame] | 346 | && mExpansion == EXPANSION_VISIBLE && !isAnimatingAway(); |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 347 | } |
| 348 | |
Lucas Dupin | 28dc9d7 | 2018-03-21 15:59:15 -0700 | [diff] [blame] | 349 | /** |
Lucas Dupin | b7d3274 | 2019-07-12 17:46:11 +0900 | [diff] [blame] | 350 | * {@link #show(boolean)} was called but we're not showing yet, or being dragged. |
Lucas Dupin | fa817a0 | 2019-07-02 15:22:54 -0700 | [diff] [blame] | 351 | */ |
Lucas Dupin | b7d3274 | 2019-07-12 17:46:11 +0900 | [diff] [blame] | 352 | public boolean inTransit() { |
Lucas Dupin | 273832d | 2019-07-23 13:44:12 -0700 | [diff] [blame] | 353 | return mShowingSoon || mExpansion != EXPANSION_HIDDEN && mExpansion != EXPANSION_VISIBLE; |
Lucas Dupin | fa817a0 | 2019-07-02 15:22:54 -0700 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | /** |
Lucas Dupin | 28dc9d7 | 2018-03-21 15:59:15 -0700 | [diff] [blame] | 357 | * @return {@code true} when bouncer's pre-hide animation already started but isn't completely |
| 358 | * hidden yet, {@code false} otherwise. |
| 359 | */ |
| 360 | public boolean isAnimatingAway() { |
| 361 | return mIsAnimatingAway; |
| 362 | } |
| 363 | |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 364 | public void prepare() { |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 365 | boolean wasInitialized = mRoot != null; |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 366 | ensureView(); |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 367 | if (wasInitialized) { |
Lucas Dupin | 27321c4 | 2019-03-20 16:22:24 -0700 | [diff] [blame] | 368 | showPrimarySecurityScreen(); |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 369 | } |
Jorim Jaggi | 86b273f | 2015-07-14 18:08:43 -0700 | [diff] [blame] | 370 | mBouncerPromptReason = mCallback.getBouncerPromptReason(); |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 371 | } |
| 372 | |
Lucas Dupin | 27321c4 | 2019-03-20 16:22:24 -0700 | [diff] [blame] | 373 | private void showPrimarySecurityScreen() { |
| 374 | mKeyguardView.showPrimarySecurityScreen(); |
Lucas Dupin | 27321c4 | 2019-03-20 16:22:24 -0700 | [diff] [blame] | 375 | } |
| 376 | |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 377 | /** |
| 378 | * Current notification panel expansion |
| 379 | * @param fraction 0 when notification panel is collapsed and 1 when expanded. |
| 380 | * @see StatusBarKeyguardViewManager#onPanelExpansionChanged |
| 381 | */ |
| 382 | public void setExpansion(float fraction) { |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 383 | float oldExpansion = mExpansion; |
Lucas Dupin | 3d565fa | 2018-03-20 15:40:14 -0700 | [diff] [blame] | 384 | mExpansion = fraction; |
Lucas Dupin | 28dc9d7 | 2018-03-21 15:59:15 -0700 | [diff] [blame] | 385 | if (mKeyguardView != null && !mIsAnimatingAway) { |
Lucas Dupin | 0df9b7a | 2018-03-15 17:53:17 -0700 | [diff] [blame] | 386 | float alpha = MathUtils.map(ALPHA_EXPANSION_THRESHOLD, 1, 1, 0, fraction); |
| 387 | mKeyguardView.setAlpha(MathUtils.constrain(alpha, 0f, 1f)); |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 388 | mKeyguardView.setTranslationY(fraction * mKeyguardView.getHeight()); |
| 389 | } |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 390 | |
Lucas Dupin | 7065900 | 2018-04-30 15:56:52 -0700 | [diff] [blame] | 391 | if (fraction == EXPANSION_VISIBLE && oldExpansion != EXPANSION_VISIBLE) { |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 392 | onFullyShown(); |
| 393 | mExpansionCallback.onFullyShown(); |
Lucas Dupin | 7065900 | 2018-04-30 15:56:52 -0700 | [diff] [blame] | 394 | } else if (fraction == EXPANSION_HIDDEN && oldExpansion != EXPANSION_HIDDEN) { |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 395 | onFullyHidden(); |
| 396 | mExpansionCallback.onFullyHidden(); |
Lucas Dupin | 8499354 | 2018-10-11 19:23:45 -0700 | [diff] [blame] | 397 | } else if (fraction != EXPANSION_VISIBLE && oldExpansion == EXPANSION_VISIBLE) { |
| 398 | mExpansionCallback.onStartingToHide(); |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 399 | } |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 400 | } |
| 401 | |
Lucas Dupin | 6f0d71f | 2018-03-23 17:26:06 -0700 | [diff] [blame] | 402 | public boolean willDismissWithAction() { |
| 403 | return mKeyguardView != null && mKeyguardView.hasDismissActions(); |
| 404 | } |
| 405 | |
Lucas Dupin | 4c2aa39 | 2018-03-28 18:00:45 -0700 | [diff] [blame] | 406 | public int getTop() { |
| 407 | if (mKeyguardView == null) { |
| 408 | return 0; |
| 409 | } |
| 410 | |
| 411 | int top = mKeyguardView.getTop(); |
| 412 | // The password view has an extra top padding that should be ignored. |
| 413 | if (mKeyguardView.getCurrentSecurityMode() == SecurityMode.Password) { |
| 414 | View messageArea = mKeyguardView.findViewById(R.id.keyguard_message_area); |
| 415 | top += messageArea.getTop(); |
| 416 | } |
| 417 | return top; |
| 418 | } |
| 419 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 420 | protected void ensureView() { |
Lucas Dupin | f190a85 | 2017-07-31 17:11:26 -0700 | [diff] [blame] | 421 | // Removal of the view might be deferred to reduce unlock latency, |
| 422 | // in this case we need to force the removal, otherwise we'll |
| 423 | // end up in an unpredictable state. |
| 424 | boolean forceRemoval = mHandler.hasCallbacks(mRemoveViewRunnable); |
| 425 | if (mRoot == null || forceRemoval) { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 426 | inflateView(); |
| 427 | } |
| 428 | } |
| 429 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 430 | protected void inflateView() { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 431 | removeView(); |
Jorim Jaggi | fabc743 | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 432 | mHandler.removeCallbacks(mRemoveViewRunnable); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 433 | mRoot = (ViewGroup) LayoutInflater.from(mContext).inflate(R.layout.keyguard_bouncer, null); |
Lucas Dupin | 6865b71 | 2017-09-11 12:28:03 -0700 | [diff] [blame] | 434 | mKeyguardView = mRoot.findViewById(R.id.keyguard_host_view); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 435 | mKeyguardView.setLockPatternUtils(mLockPatternUtils); |
| 436 | mKeyguardView.setViewMediatorCallback(mCallback); |
| 437 | mContainer.addView(mRoot, mContainer.getChildCount()); |
Selim Cinek | cb3d45a | 2017-09-08 18:00:18 -0700 | [diff] [blame] | 438 | mStatusBarHeight = mRoot.getResources().getDimensionPixelOffset( |
| 439 | com.android.systemui.R.dimen.status_bar_height); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 440 | mRoot.setVisibility(View.INVISIBLE); |
Phil Weaver | 7d847b0 | 2018-02-13 16:02:35 -0800 | [diff] [blame] | 441 | mRoot.setAccessibilityPaneTitle(mKeyguardView.getAccessibilityTitleForCurrentMode()); |
Lucas Dupin | 6865b71 | 2017-09-11 12:28:03 -0700 | [diff] [blame] | 442 | |
| 443 | final WindowInsets rootInsets = mRoot.getRootWindowInsets(); |
| 444 | if (rootInsets != null) { |
| 445 | mRoot.dispatchApplyWindowInsets(rootInsets); |
| 446 | } |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 447 | } |
| 448 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 449 | protected void removeView() { |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 450 | if (mRoot != null && mRoot.getParent() == mContainer) { |
| 451 | mContainer.removeView(mRoot); |
| 452 | mRoot = null; |
| 453 | } |
| 454 | } |
Jorim Jaggi | e5c7a89 | 2014-04-10 20:37:32 +0200 | [diff] [blame] | 455 | |
| 456 | public boolean onBackPressed() { |
| 457 | return mKeyguardView != null && mKeyguardView.handleBackKey(); |
| 458 | } |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 459 | |
| 460 | /** |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 461 | * @return True if and only if the security method should be shown before showing the |
| 462 | * notifications on Keyguard, like SIM PIN/PUK. |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 463 | */ |
| 464 | public boolean needsFullscreenBouncer() { |
Dave Mankoff | f44b13a | 2019-10-03 17:29:58 -0400 | [diff] [blame] | 465 | SecurityMode mode = Dependency.get(KeyguardSecurityModel.class).getSecurityMode( |
| 466 | KeyguardUpdateMonitor.getCurrentUser()); |
| 467 | return mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk; |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 468 | } |
| 469 | |
| 470 | /** |
| 471 | * Like {@link #needsFullscreenBouncer}, but uses the currently visible security method, which |
| 472 | * makes this method much faster. |
| 473 | */ |
| 474 | public boolean isFullscreenBouncer() { |
| 475 | if (mKeyguardView != null) { |
| 476 | SecurityMode mode = mKeyguardView.getCurrentSecurityMode(); |
| 477 | return mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk; |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 478 | } |
| 479 | return false; |
| 480 | } |
Jorim Jaggi | 8c8bcc1 | 2014-04-16 21:36:51 +0200 | [diff] [blame] | 481 | |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 482 | /** |
| 483 | * WARNING: This method might cause Binder calls. |
| 484 | */ |
Jorim Jaggi | 1568250 | 2014-04-23 12:01:36 +0200 | [diff] [blame] | 485 | public boolean isSecure() { |
| 486 | return mKeyguardView == null || mKeyguardView.getSecurityMode() != SecurityMode.None; |
| 487 | } |
| 488 | |
Selim Cinek | 2854019 | 2016-02-19 17:25:08 -0800 | [diff] [blame] | 489 | public boolean shouldDismissOnMenuPressed() { |
| 490 | return mKeyguardView.shouldEnableMenuKey(); |
Jorim Jaggi | 8c8bcc1 | 2014-04-16 21:36:51 +0200 | [diff] [blame] | 491 | } |
Jorim Jaggi | df99351 | 2014-05-13 23:06:35 +0200 | [diff] [blame] | 492 | |
| 493 | public boolean interceptMediaKey(KeyEvent event) { |
| 494 | ensureView(); |
| 495 | return mKeyguardView.interceptMediaKey(event); |
| 496 | } |
Jorim Jaggi | 5cc8659 | 2015-06-08 14:48:28 -0700 | [diff] [blame] | 497 | |
Jorim Jaggi | 25b4d4b | 2015-08-11 15:54:06 -0700 | [diff] [blame] | 498 | public void notifyKeyguardAuthenticated(boolean strongAuth) { |
Jorim Jaggi | 5cc8659 | 2015-06-08 14:48:28 -0700 | [diff] [blame] | 499 | ensureView(); |
Vadim Tryshev | 8702ca7 | 2016-04-22 08:14:12 -0700 | [diff] [blame] | 500 | mKeyguardView.finish(strongAuth, KeyguardUpdateMonitor.getCurrentUser()); |
Jorim Jaggi | 5cc8659 | 2015-06-08 14:48:28 -0700 | [diff] [blame] | 501 | } |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 502 | |
| 503 | public void dump(PrintWriter pw) { |
| 504 | pw.println("KeyguardBouncer"); |
| 505 | pw.println(" isShowing(): " + isShowing()); |
| 506 | pw.println(" mStatusBarHeight: " + mStatusBarHeight); |
| 507 | pw.println(" mExpansion: " + mExpansion); |
| 508 | pw.println(" mKeyguardView; " + mKeyguardView); |
| 509 | pw.println(" mShowingSoon: " + mKeyguardView); |
| 510 | pw.println(" mBouncerPromptReason: " + mBouncerPromptReason); |
| 511 | pw.println(" mIsAnimatingAway: " + mIsAnimatingAway); |
| 512 | } |
| 513 | |
| 514 | public interface BouncerExpansionCallback { |
| 515 | void onFullyShown(); |
Lucas Dupin | 8499354 | 2018-10-11 19:23:45 -0700 | [diff] [blame] | 516 | void onStartingToHide(); |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 517 | void onStartingToShow(); |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 518 | void onFullyHidden(); |
| 519 | } |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 520 | } |