blob: 41ec3b00f8a68872d1bc2add28b472ab6a2840ab [file] [log] [blame]
Jim Miller5a8daad2014-01-14 18:57:03 -08001/*
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 */
Jim Miller5ecd8112013-01-09 18:50:26 -080016package com.android.keyguard;
Jim Miller838906b2012-10-19 18:41:25 -070017
Jim Miller7751ff62014-01-14 18:57:03 -080018import android.app.Activity;
19import android.app.AlertDialog;
Amith Yamasani3a3d2122014-10-29 11:41:31 -070020import android.app.admin.DevicePolicyManager;
Jim Miller838906b2012-10-19 18:41:25 -070021import android.content.Context;
Amith Yamasani3a3d2122014-10-29 11:41:31 -070022import android.os.UserHandle;
Jim Miller838906b2012-10-19 18:41:25 -070023import android.util.AttributeSet;
Jim Miller7751ff62014-01-14 18:57:03 -080024import android.util.Log;
25import android.util.Slog;
26import android.view.LayoutInflater;
Chris Wren052999f2012-11-02 14:36:56 -040027import android.view.View;
Jim Miller7751ff62014-01-14 18:57:03 -080028import android.view.WindowManager;
Jim Miller838906b2012-10-19 18:41:25 -070029import android.widget.FrameLayout;
30
Jim Miller7751ff62014-01-14 18:57:03 -080031import com.android.internal.widget.LockPatternUtils;
32import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
33
34public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSecurityView {
Jorim Jaggi5cf17872014-03-26 18:31:48 +010035 private static final boolean DEBUG = KeyguardConstants.DEBUG;
Jim Miller7751ff62014-01-14 18:57:03 -080036 private static final String TAG = "KeyguardSecurityView";
Amith Yamasani3a3d2122014-10-29 11:41:31 -070037
38 private static final int USER_TYPE_PRIMARY = 1;
39 private static final int USER_TYPE_WORK_PROFILE = 2;
40 private static final int USER_TYPE_SECONDARY_USER = 3;
41
Jim Miller7751ff62014-01-14 18:57:03 -080042 private KeyguardSecurityModel mSecurityModel;
Jim Miller7751ff62014-01-14 18:57:03 -080043 private LockPatternUtils mLockPatternUtils;
44
45 private KeyguardSecurityViewFlipper mSecurityViewFlipper;
46 private boolean mIsVerifyUnlockOnly;
47 private SecurityMode mCurrentSecuritySelection = SecurityMode.Invalid;
Jim Miller7751ff62014-01-14 18:57:03 -080048 private SecurityCallback mSecurityCallback;
49
Adrian Roos336be7f2014-05-19 17:11:18 +020050 private final KeyguardUpdateMonitor mUpdateMonitor;
51
Jim Miller7751ff62014-01-14 18:57:03 -080052 // Used to notify the container when something interesting happens.
53 public interface SecurityCallback {
Jim Millerba7d94b2014-02-05 17:30:50 -080054 public boolean dismiss(boolean authenticated);
Jorim Jaggib690f0d2014-07-03 23:25:44 +020055 public void userActivity();
Jim Millerba7d94b2014-02-05 17:30:50 -080056 public void onSecurityModeChanged(SecurityMode securityMode, boolean needsInput);
Jim Miller7751ff62014-01-14 18:57:03 -080057 public void finish();
Andrew Lee72b46d42015-01-30 13:23:21 -080058 public void reset();
Jim Miller7751ff62014-01-14 18:57:03 -080059 }
60
Jim Miller838906b2012-10-19 18:41:25 -070061 public KeyguardSecurityContainer(Context context, AttributeSet attrs) {
62 this(context, attrs, 0);
63 }
64
65 public KeyguardSecurityContainer(Context context) {
Esteban Talaverafe0f24c2014-08-06 16:20:56 +010066 this(context, null, 0);
Jim Miller838906b2012-10-19 18:41:25 -070067 }
68
69 public KeyguardSecurityContainer(Context context, AttributeSet attrs, int defStyle) {
70 super(context, attrs, defStyle);
Jim Miller7751ff62014-01-14 18:57:03 -080071 mSecurityModel = new KeyguardSecurityModel(context);
72 mLockPatternUtils = new LockPatternUtils(context);
Adrian Roos336be7f2014-05-19 17:11:18 +020073 mUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
Chris Wrenc3451462012-10-30 11:22:58 -040074 }
75
Jim Miller7751ff62014-01-14 18:57:03 -080076 public void setSecurityCallback(SecurityCallback callback) {
77 mSecurityCallback = callback;
78 }
79
80 @Override
81 public void onResume(int reason) {
Jorim Jaggif4797922014-08-04 22:49:41 +020082 if (mCurrentSecuritySelection != SecurityMode.None) {
83 getSecurityView(mCurrentSecuritySelection).onResume(reason);
84 }
Jim Miller7751ff62014-01-14 18:57:03 -080085 }
86
87 @Override
88 public void onPause() {
Jorim Jaggif4797922014-08-04 22:49:41 +020089 if (mCurrentSecuritySelection != SecurityMode.None) {
90 getSecurityView(mCurrentSecuritySelection).onPause();
91 }
Jim Miller7751ff62014-01-14 18:57:03 -080092 }
93
Jorim Jaggic14f8292014-05-27 02:25:45 +020094 public void startAppearAnimation() {
Jorim Jaggif4797922014-08-04 22:49:41 +020095 if (mCurrentSecuritySelection != SecurityMode.None) {
96 getSecurityView(mCurrentSecuritySelection).startAppearAnimation();
97 }
Jorim Jaggic14f8292014-05-27 02:25:45 +020098 }
99
Jorim Jaggi76a16232014-08-08 17:00:47 +0200100 public boolean startDisappearAnimation(Runnable onFinishRunnable) {
101 if (mCurrentSecuritySelection != SecurityMode.None) {
102 return getSecurityView(mCurrentSecuritySelection).startDisappearAnimation(
103 onFinishRunnable);
104 }
105 return false;
106 }
107
Jim Miller7751ff62014-01-14 18:57:03 -0800108 public void announceCurrentSecurityMethod() {
109 View v = (View) getSecurityView(mCurrentSecuritySelection);
110 if (v != null) {
111 v.announceForAccessibility(v.getContentDescription());
112 }
113 }
114
Jorim Jaggic1dff8c2015-02-02 14:45:39 +0100115 public CharSequence getCurrentSecurityModeContentDescription() {
116 View v = (View) getSecurityView(mCurrentSecuritySelection);
117 if (v != null) {
118 return v.getContentDescription();
119 }
120 return "";
121 }
122
Jim Miller7751ff62014-01-14 18:57:03 -0800123 private KeyguardSecurityView getSecurityView(SecurityMode securityMode) {
124 final int securityViewIdForMode = getSecurityViewIdForMode(securityMode);
125 KeyguardSecurityView view = null;
126 final int children = mSecurityViewFlipper.getChildCount();
127 for (int child = 0; child < children; child++) {
128 if (mSecurityViewFlipper.getChildAt(child).getId() == securityViewIdForMode) {
129 view = ((KeyguardSecurityView)mSecurityViewFlipper.getChildAt(child));
130 break;
131 }
132 }
133 int layoutId = getLayoutIdFor(securityMode);
134 if (view == null && layoutId != 0) {
135 final LayoutInflater inflater = LayoutInflater.from(mContext);
136 if (DEBUG) Log.v(TAG, "inflating id = " + layoutId);
137 View v = inflater.inflate(layoutId, mSecurityViewFlipper, false);
138 mSecurityViewFlipper.addView(v);
Jorim Jaggi6b88cdf2014-12-22 20:56:50 +0100139 updateSecurityView(v);
Jim Miller7751ff62014-01-14 18:57:03 -0800140 view = (KeyguardSecurityView)v;
141 }
142
Jim Miller7751ff62014-01-14 18:57:03 -0800143 return view;
144 }
145
Jorim Jaggi6b88cdf2014-12-22 20:56:50 +0100146 private void updateSecurityView(View view) {
Jim Miller7751ff62014-01-14 18:57:03 -0800147 if (view instanceof KeyguardSecurityView) {
148 KeyguardSecurityView ksv = (KeyguardSecurityView) view;
149 ksv.setKeyguardCallback(mCallback);
150 ksv.setLockPatternUtils(mLockPatternUtils);
Jim Miller7751ff62014-01-14 18:57:03 -0800151 } else {
152 Log.w(TAG, "View " + view + " is not a KeyguardSecurityView");
153 }
154 }
155
156 protected void onFinishInflate() {
157 mSecurityViewFlipper = (KeyguardSecurityViewFlipper) findViewById(R.id.view_flipper);
158 mSecurityViewFlipper.setLockPatternUtils(mLockPatternUtils);
159 }
160
161 public void setLockPatternUtils(LockPatternUtils utils) {
162 mLockPatternUtils = utils;
163 mSecurityModel.setLockPatternUtils(utils);
164 mSecurityViewFlipper.setLockPatternUtils(mLockPatternUtils);
165 }
166
167 private void showDialog(String title, String message) {
168 final AlertDialog dialog = new AlertDialog.Builder(mContext)
169 .setTitle(title)
170 .setMessage(message)
171 .setNeutralButton(R.string.ok, null)
172 .create();
173 if (!(mContext instanceof Activity)) {
174 dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
175 }
176 dialog.show();
177 }
178
179 private void showTimeoutDialog() {
180 int timeoutInSeconds = (int) LockPatternUtils.FAILED_ATTEMPT_TIMEOUT_MS / 1000;
181 int messageId = 0;
182
183 switch (mSecurityModel.getSecurityMode()) {
184 case Pattern:
185 messageId = R.string.kg_too_many_failed_pattern_attempts_dialog_message;
186 break;
187 case PIN:
188 messageId = R.string.kg_too_many_failed_pin_attempts_dialog_message;
189 break;
190 case Password:
191 messageId = R.string.kg_too_many_failed_password_attempts_dialog_message;
192 break;
193 // These don't have timeout dialogs.
Jim Miller7751ff62014-01-14 18:57:03 -0800194 case Invalid:
195 case None:
196 case SimPin:
197 case SimPuk:
198 break;
199 }
200
201 if (messageId != 0) {
202 final String message = mContext.getString(messageId,
203 KeyguardUpdateMonitor.getInstance(mContext).getFailedUnlockAttempts(),
204 timeoutInSeconds);
205 showDialog(null, message);
206 }
207 }
208
Amith Yamasani3a3d2122014-10-29 11:41:31 -0700209 private void showAlmostAtWipeDialog(int attempts, int remaining, int userType) {
210 String message = null;
211 switch (userType) {
212 case USER_TYPE_PRIMARY:
213 message = mContext.getString(R.string.kg_failed_attempts_almost_at_wipe,
214 attempts, remaining);
215 break;
216 case USER_TYPE_SECONDARY_USER:
217 message = mContext.getString(R.string.kg_failed_attempts_almost_at_erase_user,
218 attempts, remaining);
219 break;
220 case USER_TYPE_WORK_PROFILE:
221 message = mContext.getString(R.string.kg_failed_attempts_almost_at_erase_profile,
222 attempts, remaining);
223 break;
224 }
Jim Miller7751ff62014-01-14 18:57:03 -0800225 showDialog(null, message);
226 }
227
Amith Yamasani3a3d2122014-10-29 11:41:31 -0700228 private void showWipeDialog(int attempts, int userType) {
229 String message = null;
230 switch (userType) {
231 case USER_TYPE_PRIMARY:
232 message = mContext.getString(R.string.kg_failed_attempts_now_wiping,
233 attempts);
234 break;
235 case USER_TYPE_SECONDARY_USER:
236 message = mContext.getString(R.string.kg_failed_attempts_now_erasing_user,
237 attempts);
238 break;
239 case USER_TYPE_WORK_PROFILE:
240 message = mContext.getString(R.string.kg_failed_attempts_now_erasing_profile,
241 attempts);
242 break;
243 }
Jim Miller7751ff62014-01-14 18:57:03 -0800244 showDialog(null, message);
245 }
246
247 private void showAlmostAtAccountLoginDialog() {
248 final int timeoutInSeconds = (int) LockPatternUtils.FAILED_ATTEMPT_TIMEOUT_MS / 1000;
249 final int count = LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET
250 - LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT;
251 String message = mContext.getString(R.string.kg_failed_attempts_almost_at_login,
252 count, LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT, timeoutInSeconds);
253 showDialog(null, message);
254 }
255
256 private void reportFailedUnlockAttempt() {
257 final KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
258 final int failedAttempts = monitor.getFailedUnlockAttempts() + 1; // +1 for this time
259
260 if (DEBUG) Log.d(TAG, "reportFailedPatternAttempt: #" + failedAttempts);
261
262 SecurityMode mode = mSecurityModel.getSecurityMode();
263 final boolean usingPattern = mode == KeyguardSecurityModel.SecurityMode.Pattern;
Amith Yamasani3a3d2122014-10-29 11:41:31 -0700264 final int currentUser = mLockPatternUtils.getCurrentUser();
265 final DevicePolicyManager dpm = mLockPatternUtils.getDevicePolicyManager();
266 final int failedAttemptsBeforeWipe =
267 dpm.getMaximumFailedPasswordsForWipe(null, currentUser);
Jim Miller7751ff62014-01-14 18:57:03 -0800268
269 final int failedAttemptWarning = LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET
270 - LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT;
271
272 final int remainingBeforeWipe = failedAttemptsBeforeWipe > 0 ?
273 (failedAttemptsBeforeWipe - failedAttempts)
274 : Integer.MAX_VALUE; // because DPM returns 0 if no restriction
Jim Miller7751ff62014-01-14 18:57:03 -0800275 boolean showTimeout = false;
276 if (remainingBeforeWipe < LockPatternUtils.FAILED_ATTEMPTS_BEFORE_WIPE_GRACE) {
Esteban Talaverafe0f24c2014-08-06 16:20:56 +0100277 // The user has installed a DevicePolicyManager that requests a user/profile to be wiped
278 // N attempts. Once we get below the grace period, we post this dialog every time as a
279 // clear warning until the deletion fires.
Amith Yamasani3a3d2122014-10-29 11:41:31 -0700280 // Check which profile has the strictest policy for failed password attempts
281 final int expiringUser = dpm.getProfileWithMinimumFailedPasswordsForWipe(currentUser);
282 int userType = USER_TYPE_PRIMARY;
283 if (expiringUser == currentUser) {
284 if (expiringUser != UserHandle.USER_OWNER) {
285 userType = USER_TYPE_SECONDARY_USER;
286 }
287 } else if (expiringUser != UserHandle.USER_NULL) {
288 userType = USER_TYPE_WORK_PROFILE;
289 } // If USER_NULL, which shouldn't happen, leave it as USER_TYPE_PRIMARY
Jim Miller7751ff62014-01-14 18:57:03 -0800290 if (remainingBeforeWipe > 0) {
Amith Yamasani3a3d2122014-10-29 11:41:31 -0700291 showAlmostAtWipeDialog(failedAttempts, remainingBeforeWipe, userType);
Jim Miller7751ff62014-01-14 18:57:03 -0800292 } else {
293 // Too many attempts. The device will be wiped shortly.
Amith Yamasani3a3d2122014-10-29 11:41:31 -0700294 Slog.i(TAG, "Too many unlock attempts; user " + expiringUser + " will be wiped!");
295 showWipeDialog(failedAttempts, userType);
Jim Miller7751ff62014-01-14 18:57:03 -0800296 }
297 } else {
298 showTimeout =
299 (failedAttempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) == 0;
Jim Miller7751ff62014-01-14 18:57:03 -0800300 }
301 monitor.reportFailedUnlockAttempt();
302 mLockPatternUtils.reportFailedPasswordAttempt();
303 if (showTimeout) {
304 showTimeoutDialog();
305 }
306 }
307
308 /**
309 * Shows the primary security screen for the user. This will be either the multi-selector
310 * or the user's security method.
311 * @param turningOff true if the device is being turned off
312 */
313 void showPrimarySecurityScreen(boolean turningOff) {
314 SecurityMode securityMode = mSecurityModel.getSecurityMode();
315 if (DEBUG) Log.v(TAG, "showPrimarySecurityScreen(turningOff=" + turningOff + ")");
Jim Miller7751ff62014-01-14 18:57:03 -0800316 showSecurityScreen(securityMode);
317 }
318
319 /**
Jim Millerba7d94b2014-02-05 17:30:50 -0800320 * Shows the next security screen if there is one.
321 * @param authenticated true if the user entered the correct authentication
Jim Millerba7d94b2014-02-05 17:30:50 -0800322 * @return true if keyguard is done
323 */
Jim Miller7751ff62014-01-14 18:57:03 -0800324 boolean showNextSecurityScreenOrFinish(boolean authenticated) {
325 if (DEBUG) Log.d(TAG, "showNextSecurityScreenOrFinish(" + authenticated + ")");
326 boolean finish = false;
Adrian Roos336be7f2014-05-19 17:11:18 +0200327 if (mUpdateMonitor.getUserHasTrust(mLockPatternUtils.getCurrentUser())) {
328 finish = true;
329 } else if (SecurityMode.None == mCurrentSecuritySelection) {
Jim Miller7751ff62014-01-14 18:57:03 -0800330 SecurityMode securityMode = mSecurityModel.getSecurityMode();
Jim Miller7751ff62014-01-14 18:57:03 -0800331 if (SecurityMode.None == securityMode) {
332 finish = true; // no security required
333 } else {
334 showSecurityScreen(securityMode); // switch to the alternate security view
335 }
336 } else if (authenticated) {
337 switch (mCurrentSecuritySelection) {
338 case Pattern:
339 case Password:
340 case PIN:
Jim Miller7751ff62014-01-14 18:57:03 -0800341 finish = true;
342 break;
343
344 case SimPin:
345 case SimPuk:
346 // Shortcut for SIM PIN/PUK to go to directly to user's security screen or home
347 SecurityMode securityMode = mSecurityModel.getSecurityMode();
348 if (securityMode != SecurityMode.None) {
349 showSecurityScreen(securityMode);
350 } else {
351 finish = true;
352 }
353 break;
354
355 default:
356 Log.v(TAG, "Bad security screen " + mCurrentSecuritySelection + ", fail safe");
357 showPrimarySecurityScreen(false);
358 break;
359 }
Jim Miller7751ff62014-01-14 18:57:03 -0800360 }
361 if (finish) {
362 mSecurityCallback.finish();
363 }
364 return finish;
365 }
366
367 /**
368 * Switches to the given security view unless it's already being shown, in which case
369 * this is a no-op.
370 *
371 * @param securityMode
372 */
373 private void showSecurityScreen(SecurityMode securityMode) {
374 if (DEBUG) Log.d(TAG, "showSecurityScreen(" + securityMode + ")");
375
376 if (securityMode == mCurrentSecuritySelection) return;
377
378 KeyguardSecurityView oldView = getSecurityView(mCurrentSecuritySelection);
379 KeyguardSecurityView newView = getSecurityView(securityMode);
380
381 // Emulate Activity life cycle
382 if (oldView != null) {
383 oldView.onPause();
384 oldView.setKeyguardCallback(mNullCallback); // ignore requests from old view
385 }
Jorim Jaggif4797922014-08-04 22:49:41 +0200386 if (securityMode != SecurityMode.None) {
387 newView.onResume(KeyguardSecurityView.VIEW_REVEALED);
388 newView.setKeyguardCallback(mCallback);
389 }
Jim Miller7751ff62014-01-14 18:57:03 -0800390
391 // Find and show this child.
392 final int childCount = mSecurityViewFlipper.getChildCount();
393
394 final int securityViewIdForMode = getSecurityViewIdForMode(securityMode);
395 for (int i = 0; i < childCount; i++) {
396 if (mSecurityViewFlipper.getChildAt(i).getId() == securityViewIdForMode) {
397 mSecurityViewFlipper.setDisplayedChild(i);
398 break;
399 }
400 }
401
402 mCurrentSecuritySelection = securityMode;
Jorim Jaggif4797922014-08-04 22:49:41 +0200403 mSecurityCallback.onSecurityModeChanged(securityMode,
404 securityMode != SecurityMode.None && newView.needsInput());
Jim Miller7751ff62014-01-14 18:57:03 -0800405 }
406
407 private KeyguardSecurityViewFlipper getFlipper() {
Chris Wren052999f2012-11-02 14:36:56 -0400408 for (int i = 0; i < getChildCount(); i++) {
409 View child = getChildAt(i);
410 if (child instanceof KeyguardSecurityViewFlipper) {
Chris Wrenc0ae9e62012-11-05 13:16:31 -0500411 return (KeyguardSecurityViewFlipper) child;
Chris Wren052999f2012-11-02 14:36:56 -0400412 }
413 }
414 return null;
415 }
416
Jim Miller7751ff62014-01-14 18:57:03 -0800417 private KeyguardSecurityCallback mCallback = new KeyguardSecurityCallback() {
Jorim Jaggib690f0d2014-07-03 23:25:44 +0200418 public void userActivity() {
Jim Miller7751ff62014-01-14 18:57:03 -0800419 if (mSecurityCallback != null) {
Jorim Jaggib690f0d2014-07-03 23:25:44 +0200420 mSecurityCallback.userActivity();
Jim Miller7751ff62014-01-14 18:57:03 -0800421 }
422 }
423
424 public void dismiss(boolean authenticated) {
425 mSecurityCallback.dismiss(authenticated);
426 }
427
428 public boolean isVerifyUnlockOnly() {
429 return mIsVerifyUnlockOnly;
430 }
431
432 public void reportUnlockAttempt(boolean success) {
433 KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
434 if (success) {
435 monitor.clearFailedUnlockAttempts();
436 mLockPatternUtils.reportSuccessfulPasswordAttempt();
437 } else {
Jorim Jaggia29e81b2014-12-19 19:26:06 +0100438 KeyguardSecurityContainer.this.reportFailedUnlockAttempt();
Jim Miller7751ff62014-01-14 18:57:03 -0800439 }
440 }
441
Andrew Lee72b46d42015-01-30 13:23:21 -0800442 public void reset() {
443 mSecurityCallback.reset();
444 }
Jim Miller7751ff62014-01-14 18:57:03 -0800445 };
446
447 // The following is used to ignore callbacks from SecurityViews that are no longer current
448 // (e.g. face unlock). This avoids unwanted asynchronous events from messing with the
449 // state for the current security method.
450 private KeyguardSecurityCallback mNullCallback = new KeyguardSecurityCallback() {
451 @Override
Jorim Jaggib690f0d2014-07-03 23:25:44 +0200452 public void userActivity() { }
Jim Miller7751ff62014-01-14 18:57:03 -0800453 @Override
Jim Miller7751ff62014-01-14 18:57:03 -0800454 public void reportUnlockAttempt(boolean success) { }
455 @Override
456 public boolean isVerifyUnlockOnly() { return false; }
457 @Override
458 public void dismiss(boolean securityVerified) { }
Andrew Lee72b46d42015-01-30 13:23:21 -0800459 @Override
460 public void reset() {}
Jim Miller7751ff62014-01-14 18:57:03 -0800461 };
462
463 private int getSecurityViewIdForMode(SecurityMode securityMode) {
464 switch (securityMode) {
Jim Miller7751ff62014-01-14 18:57:03 -0800465 case Pattern: return R.id.keyguard_pattern_view;
466 case PIN: return R.id.keyguard_pin_view;
467 case Password: return R.id.keyguard_password_view;
Jim Miller7751ff62014-01-14 18:57:03 -0800468 case SimPin: return R.id.keyguard_sim_pin_view;
469 case SimPuk: return R.id.keyguard_sim_puk_view;
470 }
471 return 0;
472 }
473
474 private int getLayoutIdFor(SecurityMode securityMode) {
475 switch (securityMode) {
Jim Miller7751ff62014-01-14 18:57:03 -0800476 case Pattern: return R.layout.keyguard_pattern_view;
477 case PIN: return R.layout.keyguard_pin_view;
478 case Password: return R.layout.keyguard_password_view;
Jim Miller7751ff62014-01-14 18:57:03 -0800479 case SimPin: return R.layout.keyguard_sim_pin_view;
480 case SimPuk: return R.layout.keyguard_sim_puk_view;
481 default:
482 return 0;
483 }
484 }
485
486 public SecurityMode getSecurityMode() {
487 return mSecurityModel.getSecurityMode();
488 }
489
Jorim Jaggi95e89ca2014-11-24 20:12:50 +0100490 public SecurityMode getCurrentSecurityMode() {
491 return mCurrentSecuritySelection;
492 }
493
Jim Miller7751ff62014-01-14 18:57:03 -0800494 public void verifyUnlock() {
495 mIsVerifyUnlockOnly = true;
496 showSecurityScreen(getSecurityMode());
497 }
498
499 public SecurityMode getCurrentSecuritySelection() {
500 return mCurrentSecuritySelection;
501 }
502
503 public void dismiss(boolean authenticated) {
504 mCallback.dismiss(authenticated);
505 }
506
507 public boolean needsInput() {
508 return mSecurityViewFlipper.needsInput();
509 }
510
511 @Override
512 public void setKeyguardCallback(KeyguardSecurityCallback callback) {
513 mSecurityViewFlipper.setKeyguardCallback(callback);
514 }
515
516 @Override
517 public void reset() {
518 mSecurityViewFlipper.reset();
519 }
520
521 @Override
522 public KeyguardSecurityCallback getCallback() {
523 return mSecurityViewFlipper.getCallback();
524 }
525
526 @Override
527 public void showUsabilityHint() {
528 mSecurityViewFlipper.showUsabilityHint();
529 }
530
Jim Miller838906b2012-10-19 18:41:25 -0700531}
Chris Wrenc0ae9e62012-11-05 13:16:31 -0500532