Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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 | */ |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 16 | package com.android.keyguard; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 17 | |
Jason Monk | ea03be1 | 2017-12-04 11:08:41 -0500 | [diff] [blame] | 18 | import static com.android.internal.util.LatencyTracker.ACTION_CHECK_CREDENTIAL; |
| 19 | import static com.android.internal.util.LatencyTracker.ACTION_CHECK_CREDENTIAL_UNLOCKED; |
Jorim Jaggi | ed3032b | 2016-10-07 16:49:34 +0200 | [diff] [blame] | 20 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 21 | import android.content.Context; |
Jason Chang | 1e4a4bd | 2018-05-22 17:30:19 +0800 | [diff] [blame] | 22 | import android.content.res.ColorStateList; |
Jim Miller | 5737534 | 2012-09-09 15:20:31 -0700 | [diff] [blame] | 23 | import android.graphics.Rect; |
Xiyuan Xia | 6e38058 | 2015-05-05 15:16:08 -0700 | [diff] [blame] | 24 | import android.os.AsyncTask; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 25 | import android.os.CountDownTimer; |
| 26 | import android.os.SystemClock; |
Selim Cinek | 3018197 | 2014-05-30 03:33:06 +0200 | [diff] [blame] | 27 | import android.text.TextUtils; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 28 | import android.util.AttributeSet; |
| 29 | import android.util.Log; |
| 30 | import android.view.MotionEvent; |
| 31 | import android.view.View; |
Selim Cinek | 3018197 | 2014-05-30 03:33:06 +0200 | [diff] [blame] | 32 | import android.view.ViewGroup; |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 33 | import android.view.animation.AnimationUtils; |
Selim Cinek | 3018197 | 2014-05-30 03:33:06 +0200 | [diff] [blame] | 34 | import android.view.animation.Interpolator; |
Jim Miller | 3af630c | 2012-09-26 14:29:18 -0700 | [diff] [blame] | 35 | import android.widget.LinearLayout; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 36 | |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 37 | import com.android.internal.annotations.VisibleForTesting; |
Jason Monk | ea03be1 | 2017-12-04 11:08:41 -0500 | [diff] [blame] | 38 | import com.android.internal.util.LatencyTracker; |
Xiyuan Xia | 6e38058 | 2015-05-05 15:16:08 -0700 | [diff] [blame] | 39 | import com.android.internal.widget.LockPatternChecker; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 40 | import com.android.internal.widget.LockPatternUtils; |
| 41 | import com.android.internal.widget.LockPatternView; |
Jorim Jaggi | 5673353 | 2015-06-09 15:25:40 -0700 | [diff] [blame] | 42 | import com.android.settingslib.animation.AppearAnimationCreator; |
| 43 | import com.android.settingslib.animation.AppearAnimationUtils; |
| 44 | import com.android.settingslib.animation.DisappearAnimationUtils; |
Sunny Goyal | 87fccf0 | 2019-08-13 17:39:10 -0700 | [diff] [blame] | 45 | import com.android.systemui.R; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 46 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 47 | import java.util.List; |
| 48 | |
Selim Cinek | 3018197 | 2014-05-30 03:33:06 +0200 | [diff] [blame] | 49 | public class KeyguardPatternView extends LinearLayout implements KeyguardSecurityView, |
Andrew Lee | 72b46d4 | 2015-01-30 13:23:21 -0800 | [diff] [blame] | 50 | AppearAnimationCreator<LockPatternView.CellState>, |
| 51 | EmergencyButton.EmergencyButtonCallback { |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 52 | |
| 53 | private static final String TAG = "SecurityPatternView"; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 54 | private static final boolean DEBUG = KeyguardConstants.DEBUG; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 55 | |
| 56 | // how long before we clear the wrong pattern |
| 57 | private static final int PATTERN_CLEAR_TIMEOUT_MS = 2000; |
| 58 | |
| 59 | // how long we stay awake after each key beyond MIN_PATTERN_BEFORE_POKE_WAKELOCK |
| 60 | private static final int UNLOCK_PATTERN_WAKE_INTERVAL_MS = 7000; |
| 61 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 62 | // how many cells the user has to cross before we poke the wakelock |
| 63 | private static final int MIN_PATTERN_BEFORE_POKE_WAKELOCK = 2; |
| 64 | |
Jorim Jaggi | e8fde5d | 2016-06-30 23:41:37 -0700 | [diff] [blame] | 65 | // How much we scale up the duration of the disappear animation when the current user is locked |
| 66 | public static final float DISAPPEAR_MULTIPLIER_LOCKED = 1.5f; |
| 67 | |
Lucas Dupin | abb18f4 | 2019-05-20 19:10:22 -0700 | [diff] [blame] | 68 | // Extra padding, in pixels, that should eat touch events. |
| 69 | private static final int PATTERNS_TOUCH_AREA_EXTENSION = 40; |
| 70 | |
Adrian Roos | 7c11f8b | 2014-03-10 17:00:11 +0100 | [diff] [blame] | 71 | private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; |
Selim Cinek | 3018197 | 2014-05-30 03:33:06 +0200 | [diff] [blame] | 72 | private final AppearAnimationUtils mAppearAnimationUtils; |
Selim Cinek | f9c0e8f | 2014-11-11 13:41:02 +0100 | [diff] [blame] | 73 | private final DisappearAnimationUtils mDisappearAnimationUtils; |
Jorim Jaggi | e8fde5d | 2016-06-30 23:41:37 -0700 | [diff] [blame] | 74 | private final DisappearAnimationUtils mDisappearAnimationUtilsLocked; |
Lucas Dupin | 727890f | 2019-05-15 14:32:50 -0700 | [diff] [blame] | 75 | private final int[] mTmpPosition = new int[2]; |
| 76 | private final Rect mTempRect = new Rect(); |
| 77 | private final Rect mLockPatternScreenBounds = new Rect(); |
Adrian Roos | 7c11f8b | 2014-03-10 17:00:11 +0100 | [diff] [blame] | 78 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 79 | private CountDownTimer mCountdownTimer = null; |
| 80 | private LockPatternUtils mLockPatternUtils; |
Xiyuan Xia | 6e38058 | 2015-05-05 15:16:08 -0700 | [diff] [blame] | 81 | private AsyncTask<?, ?, ?> mPendingLockCheck; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 82 | private LockPatternView mLockPatternView; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 83 | private KeyguardSecurityCallback mCallback; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 84 | |
| 85 | /** |
| 86 | * Keeps track of the last time we poked the wake lock during dispatching of the touch event. |
| 87 | * Initialized to something guaranteed to make us poke the wakelock when the user starts |
| 88 | * drawing the pattern. |
| 89 | * @see #dispatchTouchEvent(android.view.MotionEvent) |
| 90 | */ |
| 91 | private long mLastPokeTime = -UNLOCK_PATTERN_WAKE_INTERVAL_MS; |
| 92 | |
| 93 | /** |
| 94 | * Useful for clearing out the wrong pattern after a delay |
| 95 | */ |
| 96 | private Runnable mCancelPatternRunnable = new Runnable() { |
Jim Miller | 51e3a67 | 2015-07-31 18:42:53 -0700 | [diff] [blame] | 97 | @Override |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 98 | public void run() { |
| 99 | mLockPatternView.clearPattern(); |
| 100 | } |
| 101 | }; |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 102 | @VisibleForTesting |
| 103 | KeyguardMessageArea mSecurityMessageDisplay; |
Chris Wren | c0ae9e6 | 2012-11-05 13:16:31 -0500 | [diff] [blame] | 104 | private View mEcaView; |
Jorim Jaggi | 6b88cdf | 2014-12-22 20:56:50 +0100 | [diff] [blame] | 105 | private ViewGroup mContainer; |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 106 | private int mDisappearYTranslation; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 107 | |
| 108 | enum FooterMode { |
| 109 | Normal, |
| 110 | ForgotLockPattern, |
| 111 | VerifyUnlocked |
| 112 | } |
| 113 | |
| 114 | public KeyguardPatternView(Context context) { |
| 115 | this(context, null); |
| 116 | } |
| 117 | |
| 118 | public KeyguardPatternView(Context context, AttributeSet attrs) { |
| 119 | super(context, attrs); |
Adrian Roos | 7c11f8b | 2014-03-10 17:00:11 +0100 | [diff] [blame] | 120 | mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext); |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 121 | mAppearAnimationUtils = new AppearAnimationUtils(context, |
Selim Cinek | f9c0e8f | 2014-11-11 13:41:02 +0100 | [diff] [blame] | 122 | AppearAnimationUtils.DEFAULT_APPEAR_DURATION, 1.5f /* translationScale */, |
| 123 | 2.0f /* delayScale */, AnimationUtils.loadInterpolator( |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 124 | mContext, android.R.interpolator.linear_out_slow_in)); |
Selim Cinek | f9c0e8f | 2014-11-11 13:41:02 +0100 | [diff] [blame] | 125 | mDisappearAnimationUtils = new DisappearAnimationUtils(context, |
| 126 | 125, 1.2f /* translationScale */, |
Jorim Jaggi | 94f6f061 | 2015-06-25 14:47:24 -0700 | [diff] [blame] | 127 | 0.6f /* delayScale */, AnimationUtils.loadInterpolator( |
Selim Cinek | f9c0e8f | 2014-11-11 13:41:02 +0100 | [diff] [blame] | 128 | mContext, android.R.interpolator.fast_out_linear_in)); |
Jorim Jaggi | e8fde5d | 2016-06-30 23:41:37 -0700 | [diff] [blame] | 129 | mDisappearAnimationUtilsLocked = new DisappearAnimationUtils(context, |
| 130 | (long) (125 * DISAPPEAR_MULTIPLIER_LOCKED), 1.2f /* translationScale */, |
| 131 | 0.6f /* delayScale */, AnimationUtils.loadInterpolator( |
| 132 | mContext, android.R.interpolator.fast_out_linear_in)); |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 133 | mDisappearYTranslation = getResources().getDimensionPixelSize( |
| 134 | R.dimen.disappear_y_translation); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 135 | } |
| 136 | |
Jim Miller | 51e3a67 | 2015-07-31 18:42:53 -0700 | [diff] [blame] | 137 | @Override |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 138 | public void setKeyguardCallback(KeyguardSecurityCallback callback) { |
| 139 | mCallback = callback; |
| 140 | } |
| 141 | |
Jim Miller | 51e3a67 | 2015-07-31 18:42:53 -0700 | [diff] [blame] | 142 | @Override |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 143 | public void setLockPatternUtils(LockPatternUtils utils) { |
| 144 | mLockPatternUtils = utils; |
| 145 | } |
| 146 | |
| 147 | @Override |
| 148 | protected void onFinishInflate() { |
| 149 | super.onFinishInflate(); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 150 | mLockPatternUtils = mLockPatternUtils == null |
| 151 | ? new LockPatternUtils(mContext) : mLockPatternUtils; |
| 152 | |
Alan Viverette | 51efddb | 2017-04-05 10:00:01 -0400 | [diff] [blame] | 153 | mLockPatternView = findViewById(R.id.lockPatternView); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 154 | mLockPatternView.setSaveEnabled(false); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 155 | mLockPatternView.setOnPatternListener(new UnlockPatternListener()); |
Lucas Dupin | e173274 | 2018-08-23 18:26:49 -0700 | [diff] [blame] | 156 | mLockPatternView.setInStealthMode(!mLockPatternUtils.isVisiblePatternEnabled( |
| 157 | KeyguardUpdateMonitor.getCurrentUser())); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 158 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 159 | // vibrate mode will be the same for the life of this screen |
| 160 | mLockPatternView.setTactileFeedbackEnabled(mLockPatternUtils.isTactileFeedbackEnabled()); |
| 161 | |
Chris Wren | c0ae9e6 | 2012-11-05 13:16:31 -0500 | [diff] [blame] | 162 | mEcaView = findViewById(R.id.keyguard_selector_fade_container); |
Alan Viverette | 51efddb | 2017-04-05 10:00:01 -0400 | [diff] [blame] | 163 | mContainer = findViewById(R.id.container); |
Andrew Lee | 72b46d4 | 2015-01-30 13:23:21 -0800 | [diff] [blame] | 164 | |
Alan Viverette | 51efddb | 2017-04-05 10:00:01 -0400 | [diff] [blame] | 165 | EmergencyButton button = findViewById(R.id.emergency_call_button); |
Andrew Lee | f98f7b9 | 2015-02-02 15:50:29 -0800 | [diff] [blame] | 166 | if (button != null) { |
| 167 | button.setCallback(this); |
| 168 | } |
Jian Jin | 44e4d82 | 2018-04-06 12:40:50 -0700 | [diff] [blame] | 169 | |
| 170 | View cancelBtn = findViewById(R.id.cancel_button); |
| 171 | if (cancelBtn != null) { |
| 172 | cancelBtn.setOnClickListener(view -> { |
| 173 | mCallback.reset(); |
Aarthi Balachander | 0a427ef | 2018-07-13 15:00:58 -0700 | [diff] [blame] | 174 | mCallback.onCancelClicked(); |
Jian Jin | 44e4d82 | 2018-04-06 12:40:50 -0700 | [diff] [blame] | 175 | }); |
| 176 | } |
Andrew Lee | 72b46d4 | 2015-01-30 13:23:21 -0800 | [diff] [blame] | 177 | } |
| 178 | |
Jim Miller | 51e3a67 | 2015-07-31 18:42:53 -0700 | [diff] [blame] | 179 | @Override |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 180 | protected void onAttachedToWindow() { |
| 181 | super.onAttachedToWindow(); |
| 182 | mSecurityMessageDisplay = KeyguardMessageArea.findSecurityMessageDisplay(this); |
| 183 | } |
| 184 | |
| 185 | @Override |
Andrew Lee | 72b46d4 | 2015-01-30 13:23:21 -0800 | [diff] [blame] | 186 | public void onEmergencyButtonClickedWhenInCall() { |
| 187 | mCallback.reset(); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 188 | } |
| 189 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 190 | @Override |
Jim Miller | d2b82f7 | 2012-09-18 20:52:55 -0700 | [diff] [blame] | 191 | public boolean onTouchEvent(MotionEvent ev) { |
| 192 | boolean result = super.onTouchEvent(ev); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 193 | // as long as the user is entering a pattern (i.e sending a touch event that was handled |
| 194 | // by this screen), keep poking the wake lock so that the screen will stay on. |
| 195 | final long elapsed = SystemClock.elapsedRealtime() - mLastPokeTime; |
| 196 | if (result && (elapsed > (UNLOCK_PATTERN_WAKE_INTERVAL_MS - 100))) { |
| 197 | mLastPokeTime = SystemClock.elapsedRealtime(); |
| 198 | } |
Jim Miller | 5737534 | 2012-09-09 15:20:31 -0700 | [diff] [blame] | 199 | mTempRect.set(0, 0, 0, 0); |
| 200 | offsetRectIntoDescendantCoords(mLockPatternView, mTempRect); |
| 201 | ev.offsetLocation(mTempRect.left, mTempRect.top); |
| 202 | result = mLockPatternView.dispatchTouchEvent(ev) || result; |
| 203 | ev.offsetLocation(-mTempRect.left, -mTempRect.top); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 204 | return result; |
| 205 | } |
| 206 | |
Jim Miller | 51e3a67 | 2015-07-31 18:42:53 -0700 | [diff] [blame] | 207 | @Override |
Lucas Dupin | 727890f | 2019-05-15 14:32:50 -0700 | [diff] [blame] | 208 | protected void onLayout(boolean changed, int l, int t, int r, int b) { |
| 209 | super.onLayout(changed, l, t, r, b); |
| 210 | mLockPatternView.getLocationOnScreen(mTmpPosition); |
Lucas Dupin | abb18f4 | 2019-05-20 19:10:22 -0700 | [diff] [blame] | 211 | mLockPatternScreenBounds.set(mTmpPosition[0] - PATTERNS_TOUCH_AREA_EXTENSION, |
| 212 | mTmpPosition[1] - PATTERNS_TOUCH_AREA_EXTENSION, |
| 213 | mTmpPosition[0] + mLockPatternView.getWidth() + PATTERNS_TOUCH_AREA_EXTENSION, |
| 214 | mTmpPosition[1] + mLockPatternView.getHeight() + PATTERNS_TOUCH_AREA_EXTENSION); |
Lucas Dupin | 727890f | 2019-05-15 14:32:50 -0700 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | @Override |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 218 | public void reset() { |
| 219 | // reset lock pattern |
Toni Barzic | 17fdb13 | 2015-10-16 13:38:11 -0700 | [diff] [blame] | 220 | mLockPatternView.setInStealthMode(!mLockPatternUtils.isVisiblePatternEnabled( |
| 221 | KeyguardUpdateMonitor.getCurrentUser())); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 222 | mLockPatternView.enableInput(); |
| 223 | mLockPatternView.setEnabled(true); |
| 224 | mLockPatternView.clearPattern(); |
| 225 | |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 226 | if (mSecurityMessageDisplay == null) { |
| 227 | return; |
| 228 | } |
| 229 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 230 | // if the user is currently locked out, enforce it. |
Adrian Roos | 8150d2a | 2015-04-16 17:11:20 -0700 | [diff] [blame] | 231 | long deadline = mLockPatternUtils.getLockoutAttemptDeadline( |
Adrian Roos | d6aa6cb | 2015-04-16 19:31:29 -0700 | [diff] [blame] | 232 | KeyguardUpdateMonitor.getCurrentUser()); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 233 | if (deadline != 0) { |
| 234 | handleAttemptLockout(deadline); |
| 235 | } else { |
Danielle Millett | 1625e87 | 2012-11-01 15:00:12 -0400 | [diff] [blame] | 236 | displayDefaultSecurityMessage(); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 237 | } |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 238 | } |
| 239 | |
Danielle Millett | 1625e87 | 2012-11-01 15:00:12 -0400 | [diff] [blame] | 240 | private void displayDefaultSecurityMessage() { |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 241 | if (mSecurityMessageDisplay != null) { |
| 242 | mSecurityMessageDisplay.setMessage(""); |
| 243 | } |
Danielle Millett | 1625e87 | 2012-11-01 15:00:12 -0400 | [diff] [blame] | 244 | } |
| 245 | |
Adam Cohen | 6fb841f | 2012-10-24 13:15:38 -0700 | [diff] [blame] | 246 | @Override |
| 247 | public void showUsabilityHint() { |
| 248 | } |
| 249 | |
Lucas Dupin | 7156bc7 | 2019-05-03 19:37:39 -0700 | [diff] [blame] | 250 | @Override |
| 251 | public boolean disallowInterceptTouch(MotionEvent event) { |
Lucas Dupin | fc8de93 | 2019-06-13 14:20:52 -0700 | [diff] [blame] | 252 | return !mLockPatternView.isEmpty() |
| 253 | || mLockPatternScreenBounds.contains((int) event.getRawX(), (int) event.getRawY()); |
Lucas Dupin | 7156bc7 | 2019-05-03 19:37:39 -0700 | [diff] [blame] | 254 | } |
| 255 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 256 | /** TODO: hook this up */ |
| 257 | public void cleanUp() { |
| 258 | if (DEBUG) Log.v(TAG, "Cleanup() called on " + this); |
| 259 | mLockPatternUtils = null; |
| 260 | mLockPatternView.setOnPatternListener(null); |
| 261 | } |
| 262 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 263 | private class UnlockPatternListener implements LockPatternView.OnPatternListener { |
| 264 | |
Jim Miller | 51e3a67 | 2015-07-31 18:42:53 -0700 | [diff] [blame] | 265 | @Override |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 266 | public void onPatternStart() { |
| 267 | mLockPatternView.removeCallbacks(mCancelPatternRunnable); |
Adrian Roos | db327e9 | 2016-10-12 16:41:28 -0700 | [diff] [blame] | 268 | mSecurityMessageDisplay.setMessage(""); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 269 | } |
| 270 | |
Jim Miller | 51e3a67 | 2015-07-31 18:42:53 -0700 | [diff] [blame] | 271 | @Override |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 272 | public void onPatternCleared() { |
| 273 | } |
| 274 | |
Jim Miller | 51e3a67 | 2015-07-31 18:42:53 -0700 | [diff] [blame] | 275 | @Override |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 276 | public void onPatternCellAdded(List<LockPatternView.Cell> pattern) { |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 277 | mCallback.userActivity(); |
Lucas Dupin | ccf6721 | 2019-08-07 12:53:02 -0700 | [diff] [blame] | 278 | mCallback.onUserInput(); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 279 | } |
| 280 | |
Jim Miller | 51e3a67 | 2015-07-31 18:42:53 -0700 | [diff] [blame] | 281 | @Override |
Xiyuan Xia | 6e38058 | 2015-05-05 15:16:08 -0700 | [diff] [blame] | 282 | public void onPatternDetected(final List<LockPatternView.Cell> pattern) { |
| 283 | mLockPatternView.disableInput(); |
| 284 | if (mPendingLockCheck != null) { |
| 285 | mPendingLockCheck.cancel(false); |
| 286 | } |
| 287 | |
Xiyuan Xia | ce64cea | 2016-01-06 08:51:16 -0800 | [diff] [blame] | 288 | final int userId = KeyguardUpdateMonitor.getCurrentUser(); |
Andres Morales | 2397427 | 2015-05-14 22:42:26 -0700 | [diff] [blame] | 289 | if (pattern.size() < LockPatternUtils.MIN_PATTERN_REGISTER_FAIL) { |
| 290 | mLockPatternView.enableInput(); |
Xiyuan Xia | ce64cea | 2016-01-06 08:51:16 -0800 | [diff] [blame] | 291 | onPatternChecked(userId, false, 0, false /* not valid - too short */); |
Andres Morales | 2397427 | 2015-05-14 22:42:26 -0700 | [diff] [blame] | 292 | return; |
| 293 | } |
| 294 | |
Jorim Jaggi | ed3032b | 2016-10-07 16:49:34 +0200 | [diff] [blame] | 295 | if (LatencyTracker.isEnabled(mContext)) { |
| 296 | LatencyTracker.getInstance(mContext).onActionStart(ACTION_CHECK_CREDENTIAL); |
| 297 | LatencyTracker.getInstance(mContext).onActionStart(ACTION_CHECK_CREDENTIAL_UNLOCKED); |
| 298 | } |
Xiyuan Xia | 6e38058 | 2015-05-05 15:16:08 -0700 | [diff] [blame] | 299 | mPendingLockCheck = LockPatternChecker.checkPattern( |
| 300 | mLockPatternUtils, |
| 301 | pattern, |
Xiyuan Xia | ce64cea | 2016-01-06 08:51:16 -0800 | [diff] [blame] | 302 | userId, |
Xiyuan Xia | 6e38058 | 2015-05-05 15:16:08 -0700 | [diff] [blame] | 303 | new LockPatternChecker.OnCheckCallback() { |
Jorim Jaggi | e8fde5d | 2016-06-30 23:41:37 -0700 | [diff] [blame] | 304 | |
| 305 | @Override |
| 306 | public void onEarlyMatched() { |
Jorim Jaggi | ed3032b | 2016-10-07 16:49:34 +0200 | [diff] [blame] | 307 | if (LatencyTracker.isEnabled(mContext)) { |
| 308 | LatencyTracker.getInstance(mContext).onActionEnd( |
| 309 | ACTION_CHECK_CREDENTIAL); |
| 310 | } |
Jorim Jaggi | e8fde5d | 2016-06-30 23:41:37 -0700 | [diff] [blame] | 311 | onPatternChecked(userId, true /* matched */, 0 /* timeoutMs */, |
| 312 | true /* isValidPattern */); |
| 313 | } |
| 314 | |
Xiyuan Xia | 6e38058 | 2015-05-05 15:16:08 -0700 | [diff] [blame] | 315 | @Override |
Andres Morales | 2397427 | 2015-05-14 22:42:26 -0700 | [diff] [blame] | 316 | public void onChecked(boolean matched, int timeoutMs) { |
Jorim Jaggi | ed3032b | 2016-10-07 16:49:34 +0200 | [diff] [blame] | 317 | if (LatencyTracker.isEnabled(mContext)) { |
| 318 | LatencyTracker.getInstance(mContext).onActionEnd( |
| 319 | ACTION_CHECK_CREDENTIAL_UNLOCKED); |
| 320 | } |
Xiyuan Xia | 6e38058 | 2015-05-05 15:16:08 -0700 | [diff] [blame] | 321 | mLockPatternView.enableInput(); |
| 322 | mPendingLockCheck = null; |
Jorim Jaggi | e8fde5d | 2016-06-30 23:41:37 -0700 | [diff] [blame] | 323 | if (!matched) { |
| 324 | onPatternChecked(userId, false /* matched */, timeoutMs, |
| 325 | true /* isValidPattern */); |
| 326 | } |
Xiyuan Xia | 6e38058 | 2015-05-05 15:16:08 -0700 | [diff] [blame] | 327 | } |
Jorim Jaggi | ed3032b | 2016-10-07 16:49:34 +0200 | [diff] [blame] | 328 | |
| 329 | @Override |
| 330 | public void onCancelled() { |
| 331 | // We already got dismissed with the early matched callback, so we |
| 332 | // cancelled the check. However, we still need to note down the latency. |
| 333 | if (LatencyTracker.isEnabled(mContext)) { |
| 334 | LatencyTracker.getInstance(mContext).onActionEnd( |
| 335 | ACTION_CHECK_CREDENTIAL_UNLOCKED); |
| 336 | } |
| 337 | } |
Xiyuan Xia | 6e38058 | 2015-05-05 15:16:08 -0700 | [diff] [blame] | 338 | }); |
Jim Miller | 51e3a67 | 2015-07-31 18:42:53 -0700 | [diff] [blame] | 339 | if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) { |
| 340 | mCallback.userActivity(); |
Lucas Dupin | ccf6721 | 2019-08-07 12:53:02 -0700 | [diff] [blame] | 341 | mCallback.onUserInput(); |
Jim Miller | 51e3a67 | 2015-07-31 18:42:53 -0700 | [diff] [blame] | 342 | } |
Xiyuan Xia | 6e38058 | 2015-05-05 15:16:08 -0700 | [diff] [blame] | 343 | } |
| 344 | |
Xiyuan Xia | ce64cea | 2016-01-06 08:51:16 -0800 | [diff] [blame] | 345 | private void onPatternChecked(int userId, boolean matched, int timeoutMs, |
| 346 | boolean isValidPattern) { |
| 347 | boolean dismissKeyguard = KeyguardUpdateMonitor.getCurrentUser() == userId; |
Xiyuan Xia | 6e38058 | 2015-05-05 15:16:08 -0700 | [diff] [blame] | 348 | if (matched) { |
Xiyuan Xia | ce64cea | 2016-01-06 08:51:16 -0800 | [diff] [blame] | 349 | mCallback.reportUnlockAttempt(userId, true, 0); |
| 350 | if (dismissKeyguard) { |
| 351 | mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct); |
Vadim Tryshev | 8702ca7 | 2016-04-22 08:14:12 -0700 | [diff] [blame] | 352 | mCallback.dismiss(true, userId); |
Xiyuan Xia | ce64cea | 2016-01-06 08:51:16 -0800 | [diff] [blame] | 353 | } |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 354 | } else { |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 355 | mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong); |
Jim Miller | 51e3a67 | 2015-07-31 18:42:53 -0700 | [diff] [blame] | 356 | if (isValidPattern) { |
Xiyuan Xia | ce64cea | 2016-01-06 08:51:16 -0800 | [diff] [blame] | 357 | mCallback.reportUnlockAttempt(userId, false, timeoutMs); |
Jim Miller | 51e3a67 | 2015-07-31 18:42:53 -0700 | [diff] [blame] | 358 | if (timeoutMs > 0) { |
| 359 | long deadline = mLockPatternUtils.setLockoutAttemptDeadline( |
Xiyuan Xia | ce64cea | 2016-01-06 08:51:16 -0800 | [diff] [blame] | 360 | userId, timeoutMs); |
Jim Miller | 51e3a67 | 2015-07-31 18:42:53 -0700 | [diff] [blame] | 361 | handleAttemptLockout(deadline); |
| 362 | } |
| 363 | } |
| 364 | if (timeoutMs == 0) { |
Adrian Roos | db327e9 | 2016-10-12 16:41:28 -0700 | [diff] [blame] | 365 | mSecurityMessageDisplay.setMessage(R.string.kg_wrong_pattern); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 366 | mLockPatternView.postDelayed(mCancelPatternRunnable, PATTERN_CLEAR_TIMEOUT_MS); |
| 367 | } |
| 368 | } |
| 369 | } |
| 370 | } |
| 371 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 372 | private void handleAttemptLockout(long elapsedRealtimeDeadline) { |
| 373 | mLockPatternView.clearPattern(); |
| 374 | mLockPatternView.setEnabled(false); |
| 375 | final long elapsedRealtime = SystemClock.elapsedRealtime(); |
Hidenari Koshimae | 5be868c | 2014-08-21 11:27:33 +0200 | [diff] [blame] | 376 | final long secondsInFuture = (long) Math.ceil( |
| 377 | (elapsedRealtimeDeadline - elapsedRealtime) / 1000.0); |
| 378 | mCountdownTimer = new CountDownTimer(secondsInFuture * 1000, 1000) { |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 379 | |
| 380 | @Override |
| 381 | public void onTick(long millisUntilFinished) { |
Hidenari Koshimae | 5be868c | 2014-08-21 11:27:33 +0200 | [diff] [blame] | 382 | final int secondsRemaining = (int) Math.round(millisUntilFinished / 1000.0); |
Kevin Chyn | e01c5e1 | 2017-08-29 19:04:25 -0700 | [diff] [blame] | 383 | mSecurityMessageDisplay.setMessage(mContext.getResources().getQuantityString( |
| 384 | R.plurals.kg_too_many_failed_attempts_countdown, |
| 385 | secondsRemaining, secondsRemaining)); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | @Override |
| 389 | public void onFinish() { |
| 390 | mLockPatternView.setEnabled(true); |
Danielle Millett | 1625e87 | 2012-11-01 15:00:12 -0400 | [diff] [blame] | 391 | displayDefaultSecurityMessage(); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 392 | } |
| 393 | |
| 394 | }.start(); |
| 395 | } |
| 396 | |
| 397 | @Override |
| 398 | public boolean needsInput() { |
| 399 | return false; |
| 400 | } |
| 401 | |
| 402 | @Override |
| 403 | public void onPause() { |
| 404 | if (mCountdownTimer != null) { |
| 405 | mCountdownTimer.cancel(); |
| 406 | mCountdownTimer = null; |
| 407 | } |
Xiyuan Xia | 6e38058 | 2015-05-05 15:16:08 -0700 | [diff] [blame] | 408 | if (mPendingLockCheck != null) { |
| 409 | mPendingLockCheck.cancel(false); |
| 410 | mPendingLockCheck = null; |
| 411 | } |
Lucas Dupin | c6b50c6 | 2018-10-09 20:00:35 -0700 | [diff] [blame] | 412 | displayDefaultSecurityMessage(); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | @Override |
Chris Wren | a042ac9 | 2012-11-07 11:37:06 -0500 | [diff] [blame] | 416 | public void onResume(int reason) { |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | @Override |
| 420 | public KeyguardSecurityCallback getCallback() { |
| 421 | return mCallback; |
| 422 | } |
Chris Wren | c0ae9e6 | 2012-11-05 13:16:31 -0500 | [diff] [blame] | 423 | |
| 424 | @Override |
Selim Cinek | 3122fa8 | 2015-06-18 01:38:59 -0700 | [diff] [blame] | 425 | public void showPromptReason(int reason) { |
| 426 | switch (reason) { |
| 427 | case PROMPT_REASON_RESTART: |
Adrian Roos | db327e9 | 2016-10-12 16:41:28 -0700 | [diff] [blame] | 428 | mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_restart_pattern); |
Selim Cinek | 3122fa8 | 2015-06-18 01:38:59 -0700 | [diff] [blame] | 429 | break; |
Jorim Jaggi | 25b4d4b | 2015-08-11 15:54:06 -0700 | [diff] [blame] | 430 | case PROMPT_REASON_TIMEOUT: |
Adrian Roos | db327e9 | 2016-10-12 16:41:28 -0700 | [diff] [blame] | 431 | mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_timeout_pattern); |
Jorim Jaggi | 25b4d4b | 2015-08-11 15:54:06 -0700 | [diff] [blame] | 432 | break; |
Adrian Roos | d6d253a | 2016-04-13 13:06:21 -0700 | [diff] [blame] | 433 | case PROMPT_REASON_DEVICE_ADMIN: |
Adrian Roos | db327e9 | 2016-10-12 16:41:28 -0700 | [diff] [blame] | 434 | mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_device_admin); |
Adrian Roos | d6d253a | 2016-04-13 13:06:21 -0700 | [diff] [blame] | 435 | break; |
| 436 | case PROMPT_REASON_USER_REQUEST: |
Adrian Roos | db327e9 | 2016-10-12 16:41:28 -0700 | [diff] [blame] | 437 | mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_user_request); |
Adrian Roos | d6d253a | 2016-04-13 13:06:21 -0700 | [diff] [blame] | 438 | break; |
Adrian Roos | c13723f | 2016-01-12 20:29:03 +0100 | [diff] [blame] | 439 | case PROMPT_REASON_NONE: |
| 440 | break; |
Selim Cinek | 3122fa8 | 2015-06-18 01:38:59 -0700 | [diff] [blame] | 441 | default: |
Adrian Roos | db327e9 | 2016-10-12 16:41:28 -0700 | [diff] [blame] | 442 | mSecurityMessageDisplay.setMessage(R.string.kg_prompt_reason_timeout_pattern); |
Jorim Jaggi | 25b4d4b | 2015-08-11 15:54:06 -0700 | [diff] [blame] | 443 | break; |
Selim Cinek | 3122fa8 | 2015-06-18 01:38:59 -0700 | [diff] [blame] | 444 | } |
| 445 | } |
| 446 | |
| 447 | @Override |
Jason Chang | 1e4a4bd | 2018-05-22 17:30:19 +0800 | [diff] [blame] | 448 | public void showMessage(CharSequence message, ColorStateList colorState) { |
Lucas Dupin | 51996bb | 2019-05-16 17:56:43 -0700 | [diff] [blame] | 449 | if (colorState != null) { |
| 450 | mSecurityMessageDisplay.setNextMessageColor(colorState); |
| 451 | } |
Adrian Roos | db327e9 | 2016-10-12 16:41:28 -0700 | [diff] [blame] | 452 | mSecurityMessageDisplay.setMessage(message); |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | @Override |
Jorim Jaggi | c14f829 | 2014-05-27 02:25:45 +0200 | [diff] [blame] | 456 | public void startAppearAnimation() { |
Selim Cinek | 3018197 | 2014-05-30 03:33:06 +0200 | [diff] [blame] | 457 | enableClipping(false); |
Jorim Jaggi | fb28c0e | 2014-08-22 16:28:42 +0200 | [diff] [blame] | 458 | setAlpha(1f); |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 459 | setTranslationY(mAppearAnimationUtils.getStartTranslation()); |
Jorim Jaggi | 613f55f | 2015-07-16 15:30:10 -0700 | [diff] [blame] | 460 | AppearAnimationUtils.startTranslationYAnimation(this, 0 /* delay */, 500 /* duration */, |
| 461 | 0, mAppearAnimationUtils.getInterpolator()); |
Jorim Jaggi | 5673353 | 2015-06-09 15:25:40 -0700 | [diff] [blame] | 462 | mAppearAnimationUtils.startAnimation2d( |
Selim Cinek | 3018197 | 2014-05-30 03:33:06 +0200 | [diff] [blame] | 463 | mLockPatternView.getCellStates(), |
| 464 | new Runnable() { |
| 465 | @Override |
| 466 | public void run() { |
| 467 | enableClipping(true); |
| 468 | } |
| 469 | }, |
| 470 | this); |
Selim Cinek | 3122fa8 | 2015-06-18 01:38:59 -0700 | [diff] [blame] | 471 | if (!TextUtils.isEmpty(mSecurityMessageDisplay.getText())) { |
| 472 | mAppearAnimationUtils.createAnimation(mSecurityMessageDisplay, 0, |
Jorim Jaggi | 98f8530 | 2014-08-07 17:45:04 +0200 | [diff] [blame] | 473 | AppearAnimationUtils.DEFAULT_APPEAR_DURATION, |
Selim Cinek | 3018197 | 2014-05-30 03:33:06 +0200 | [diff] [blame] | 474 | mAppearAnimationUtils.getStartTranslation(), |
Selim Cinek | f9c0e8f | 2014-11-11 13:41:02 +0100 | [diff] [blame] | 475 | true /* appearing */, |
Selim Cinek | 3018197 | 2014-05-30 03:33:06 +0200 | [diff] [blame] | 476 | mAppearAnimationUtils.getInterpolator(), |
| 477 | null /* finishRunnable */); |
| 478 | } |
| 479 | } |
| 480 | |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 481 | @Override |
Selim Cinek | f9c0e8f | 2014-11-11 13:41:02 +0100 | [diff] [blame] | 482 | public boolean startDisappearAnimation(final Runnable finishRunnable) { |
Jorim Jaggi | 031f795 | 2016-09-01 16:39:26 -0700 | [diff] [blame] | 483 | float durationMultiplier = mKeyguardUpdateMonitor.needsSlowUnlockTransition() |
| 484 | ? DISAPPEAR_MULTIPLIER_LOCKED |
| 485 | : 1f; |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 486 | mLockPatternView.clearPattern(); |
Selim Cinek | f9c0e8f | 2014-11-11 13:41:02 +0100 | [diff] [blame] | 487 | enableClipping(false); |
| 488 | setTranslationY(0); |
Jorim Jaggi | e8fde5d | 2016-06-30 23:41:37 -0700 | [diff] [blame] | 489 | AppearAnimationUtils.startTranslationYAnimation(this, 0 /* delay */, |
| 490 | (long) (300 * durationMultiplier), |
Jorim Jaggi | 613f55f | 2015-07-16 15:30:10 -0700 | [diff] [blame] | 491 | -mDisappearAnimationUtils.getStartTranslation(), |
| 492 | mDisappearAnimationUtils.getInterpolator()); |
Jorim Jaggi | e8fde5d | 2016-06-30 23:41:37 -0700 | [diff] [blame] | 493 | |
Jorim Jaggi | 031f795 | 2016-09-01 16:39:26 -0700 | [diff] [blame] | 494 | DisappearAnimationUtils disappearAnimationUtils = mKeyguardUpdateMonitor |
| 495 | .needsSlowUnlockTransition() |
| 496 | ? mDisappearAnimationUtilsLocked |
| 497 | : mDisappearAnimationUtils; |
Jorim Jaggi | e8fde5d | 2016-06-30 23:41:37 -0700 | [diff] [blame] | 498 | disappearAnimationUtils.startAnimation2d(mLockPatternView.getCellStates(), |
| 499 | () -> { |
| 500 | enableClipping(true); |
| 501 | if (finishRunnable != null) { |
| 502 | finishRunnable.run(); |
Selim Cinek | f9c0e8f | 2014-11-11 13:41:02 +0100 | [diff] [blame] | 503 | } |
| 504 | }, KeyguardPatternView.this); |
Selim Cinek | 3122fa8 | 2015-06-18 01:38:59 -0700 | [diff] [blame] | 505 | if (!TextUtils.isEmpty(mSecurityMessageDisplay.getText())) { |
| 506 | mDisappearAnimationUtils.createAnimation(mSecurityMessageDisplay, 0, |
Jorim Jaggi | e8fde5d | 2016-06-30 23:41:37 -0700 | [diff] [blame] | 507 | (long) (200 * durationMultiplier), |
Selim Cinek | f9c0e8f | 2014-11-11 13:41:02 +0100 | [diff] [blame] | 508 | - mDisappearAnimationUtils.getStartTranslation() * 3, |
| 509 | false /* appearing */, |
| 510 | mDisappearAnimationUtils.getInterpolator(), |
| 511 | null /* finishRunnable */); |
| 512 | } |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 513 | return true; |
| 514 | } |
| 515 | |
Selim Cinek | 3018197 | 2014-05-30 03:33:06 +0200 | [diff] [blame] | 516 | private void enableClipping(boolean enable) { |
| 517 | setClipChildren(enable); |
Jorim Jaggi | 6b88cdf | 2014-12-22 20:56:50 +0100 | [diff] [blame] | 518 | mContainer.setClipToPadding(enable); |
| 519 | mContainer.setClipChildren(enable); |
Selim Cinek | 3018197 | 2014-05-30 03:33:06 +0200 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | @Override |
| 523 | public void createAnimation(final LockPatternView.CellState animatedCell, long delay, |
Selim Cinek | f9c0e8f | 2014-11-11 13:41:02 +0100 | [diff] [blame] | 524 | long duration, float translationY, final boolean appearing, |
| 525 | Interpolator interpolator, |
Selim Cinek | 3018197 | 2014-05-30 03:33:06 +0200 | [diff] [blame] | 526 | final Runnable finishListener) { |
Jorim Jaggi | 613f55f | 2015-07-16 15:30:10 -0700 | [diff] [blame] | 527 | mLockPatternView.startCellStateAnimation(animatedCell, |
| 528 | 1f, appearing ? 1f : 0f, /* alpha */ |
| 529 | appearing ? translationY : 0f, appearing ? 0f : translationY, /* translation */ |
| 530 | appearing ? 0f : 1f, 1f /* scale */, |
| 531 | delay, duration, interpolator, finishListener); |
Selim Cinek | 3018197 | 2014-05-30 03:33:06 +0200 | [diff] [blame] | 532 | if (finishListener != null) { |
Selim Cinek | 3018197 | 2014-05-30 03:33:06 +0200 | [diff] [blame] | 533 | // Also animate the Emergency call |
Selim Cinek | f9c0e8f | 2014-11-11 13:41:02 +0100 | [diff] [blame] | 534 | mAppearAnimationUtils.createAnimation(mEcaView, delay, duration, translationY, |
| 535 | appearing, interpolator, null); |
Selim Cinek | 3018197 | 2014-05-30 03:33:06 +0200 | [diff] [blame] | 536 | } |
Jorim Jaggi | c14f829 | 2014-05-27 02:25:45 +0200 | [diff] [blame] | 537 | } |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 538 | |
| 539 | @Override |
| 540 | public boolean hasOverlappingRendering() { |
| 541 | return false; |
| 542 | } |
Phil Weaver | 7d847b0 | 2018-02-13 16:02:35 -0800 | [diff] [blame] | 543 | |
| 544 | @Override |
| 545 | public CharSequence getTitle() { |
| 546 | return getContext().getString( |
| 547 | com.android.internal.R.string.keyguard_accessibility_pattern_unlock); |
| 548 | } |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 549 | } |