blob: 5af77830e64237f05378d4f89ce4d57337d01fcd [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
Jim Miller7751ff62014-01-14 18:57:03 -0800269 final int remainingBeforeWipe = failedAttemptsBeforeWipe > 0 ?
270 (failedAttemptsBeforeWipe - failedAttempts)
271 : Integer.MAX_VALUE; // because DPM returns 0 if no restriction
Jim Miller7751ff62014-01-14 18:57:03 -0800272 boolean showTimeout = false;
273 if (remainingBeforeWipe < LockPatternUtils.FAILED_ATTEMPTS_BEFORE_WIPE_GRACE) {
Esteban Talaverafe0f24c2014-08-06 16:20:56 +0100274 // The user has installed a DevicePolicyManager that requests a user/profile to be wiped
275 // N attempts. Once we get below the grace period, we post this dialog every time as a
276 // clear warning until the deletion fires.
Amith Yamasani3a3d2122014-10-29 11:41:31 -0700277 // Check which profile has the strictest policy for failed password attempts
278 final int expiringUser = dpm.getProfileWithMinimumFailedPasswordsForWipe(currentUser);
279 int userType = USER_TYPE_PRIMARY;
280 if (expiringUser == currentUser) {
281 if (expiringUser != UserHandle.USER_OWNER) {
282 userType = USER_TYPE_SECONDARY_USER;
283 }
284 } else if (expiringUser != UserHandle.USER_NULL) {
285 userType = USER_TYPE_WORK_PROFILE;
286 } // If USER_NULL, which shouldn't happen, leave it as USER_TYPE_PRIMARY
Jim Miller7751ff62014-01-14 18:57:03 -0800287 if (remainingBeforeWipe > 0) {
Amith Yamasani3a3d2122014-10-29 11:41:31 -0700288 showAlmostAtWipeDialog(failedAttempts, remainingBeforeWipe, userType);
Jim Miller7751ff62014-01-14 18:57:03 -0800289 } else {
290 // Too many attempts. The device will be wiped shortly.
Amith Yamasani3a3d2122014-10-29 11:41:31 -0700291 Slog.i(TAG, "Too many unlock attempts; user " + expiringUser + " will be wiped!");
292 showWipeDialog(failedAttempts, userType);
Jim Miller7751ff62014-01-14 18:57:03 -0800293 }
294 } else {
295 showTimeout =
296 (failedAttempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) == 0;
Jim Miller7751ff62014-01-14 18:57:03 -0800297 }
298 monitor.reportFailedUnlockAttempt();
299 mLockPatternUtils.reportFailedPasswordAttempt();
300 if (showTimeout) {
301 showTimeoutDialog();
302 }
303 }
304
305 /**
306 * Shows the primary security screen for the user. This will be either the multi-selector
307 * or the user's security method.
308 * @param turningOff true if the device is being turned off
309 */
310 void showPrimarySecurityScreen(boolean turningOff) {
311 SecurityMode securityMode = mSecurityModel.getSecurityMode();
312 if (DEBUG) Log.v(TAG, "showPrimarySecurityScreen(turningOff=" + turningOff + ")");
Jim Miller7751ff62014-01-14 18:57:03 -0800313 showSecurityScreen(securityMode);
314 }
315
316 /**
Jim Millerba7d94b2014-02-05 17:30:50 -0800317 * Shows the next security screen if there is one.
318 * @param authenticated true if the user entered the correct authentication
Jim Millerba7d94b2014-02-05 17:30:50 -0800319 * @return true if keyguard is done
320 */
Jim Miller7751ff62014-01-14 18:57:03 -0800321 boolean showNextSecurityScreenOrFinish(boolean authenticated) {
322 if (DEBUG) Log.d(TAG, "showNextSecurityScreenOrFinish(" + authenticated + ")");
323 boolean finish = false;
Adrian Roos336be7f2014-05-19 17:11:18 +0200324 if (mUpdateMonitor.getUserHasTrust(mLockPatternUtils.getCurrentUser())) {
325 finish = true;
326 } else if (SecurityMode.None == mCurrentSecuritySelection) {
Jim Miller7751ff62014-01-14 18:57:03 -0800327 SecurityMode securityMode = mSecurityModel.getSecurityMode();
Jim Miller7751ff62014-01-14 18:57:03 -0800328 if (SecurityMode.None == securityMode) {
329 finish = true; // no security required
330 } else {
331 showSecurityScreen(securityMode); // switch to the alternate security view
332 }
333 } else if (authenticated) {
334 switch (mCurrentSecuritySelection) {
335 case Pattern:
336 case Password:
337 case PIN:
Jim Miller7751ff62014-01-14 18:57:03 -0800338 finish = true;
339 break;
340
341 case SimPin:
342 case SimPuk:
343 // Shortcut for SIM PIN/PUK to go to directly to user's security screen or home
344 SecurityMode securityMode = mSecurityModel.getSecurityMode();
345 if (securityMode != SecurityMode.None) {
346 showSecurityScreen(securityMode);
347 } else {
348 finish = true;
349 }
350 break;
351
352 default:
353 Log.v(TAG, "Bad security screen " + mCurrentSecuritySelection + ", fail safe");
354 showPrimarySecurityScreen(false);
355 break;
356 }
Jim Miller7751ff62014-01-14 18:57:03 -0800357 }
358 if (finish) {
359 mSecurityCallback.finish();
360 }
361 return finish;
362 }
363
364 /**
365 * Switches to the given security view unless it's already being shown, in which case
366 * this is a no-op.
367 *
368 * @param securityMode
369 */
370 private void showSecurityScreen(SecurityMode securityMode) {
371 if (DEBUG) Log.d(TAG, "showSecurityScreen(" + securityMode + ")");
372
373 if (securityMode == mCurrentSecuritySelection) return;
374
375 KeyguardSecurityView oldView = getSecurityView(mCurrentSecuritySelection);
376 KeyguardSecurityView newView = getSecurityView(securityMode);
377
378 // Emulate Activity life cycle
379 if (oldView != null) {
380 oldView.onPause();
381 oldView.setKeyguardCallback(mNullCallback); // ignore requests from old view
382 }
Jorim Jaggif4797922014-08-04 22:49:41 +0200383 if (securityMode != SecurityMode.None) {
384 newView.onResume(KeyguardSecurityView.VIEW_REVEALED);
385 newView.setKeyguardCallback(mCallback);
386 }
Jim Miller7751ff62014-01-14 18:57:03 -0800387
388 // Find and show this child.
389 final int childCount = mSecurityViewFlipper.getChildCount();
390
391 final int securityViewIdForMode = getSecurityViewIdForMode(securityMode);
392 for (int i = 0; i < childCount; i++) {
393 if (mSecurityViewFlipper.getChildAt(i).getId() == securityViewIdForMode) {
394 mSecurityViewFlipper.setDisplayedChild(i);
395 break;
396 }
397 }
398
399 mCurrentSecuritySelection = securityMode;
Jorim Jaggif4797922014-08-04 22:49:41 +0200400 mSecurityCallback.onSecurityModeChanged(securityMode,
401 securityMode != SecurityMode.None && newView.needsInput());
Jim Miller7751ff62014-01-14 18:57:03 -0800402 }
403
404 private KeyguardSecurityViewFlipper getFlipper() {
Chris Wren052999f2012-11-02 14:36:56 -0400405 for (int i = 0; i < getChildCount(); i++) {
406 View child = getChildAt(i);
407 if (child instanceof KeyguardSecurityViewFlipper) {
Chris Wrenc0ae9e62012-11-05 13:16:31 -0500408 return (KeyguardSecurityViewFlipper) child;
Chris Wren052999f2012-11-02 14:36:56 -0400409 }
410 }
411 return null;
412 }
413
Jim Miller7751ff62014-01-14 18:57:03 -0800414 private KeyguardSecurityCallback mCallback = new KeyguardSecurityCallback() {
Jorim Jaggib690f0d2014-07-03 23:25:44 +0200415 public void userActivity() {
Jim Miller7751ff62014-01-14 18:57:03 -0800416 if (mSecurityCallback != null) {
Jorim Jaggib690f0d2014-07-03 23:25:44 +0200417 mSecurityCallback.userActivity();
Jim Miller7751ff62014-01-14 18:57:03 -0800418 }
419 }
420
421 public void dismiss(boolean authenticated) {
422 mSecurityCallback.dismiss(authenticated);
423 }
424
425 public boolean isVerifyUnlockOnly() {
426 return mIsVerifyUnlockOnly;
427 }
428
429 public void reportUnlockAttempt(boolean success) {
430 KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
431 if (success) {
432 monitor.clearFailedUnlockAttempts();
433 mLockPatternUtils.reportSuccessfulPasswordAttempt();
434 } else {
Jorim Jaggia29e81b2014-12-19 19:26:06 +0100435 KeyguardSecurityContainer.this.reportFailedUnlockAttempt();
Jim Miller7751ff62014-01-14 18:57:03 -0800436 }
437 }
438
Andrew Lee72b46d42015-01-30 13:23:21 -0800439 public void reset() {
440 mSecurityCallback.reset();
441 }
Jim Miller7751ff62014-01-14 18:57:03 -0800442 };
443
444 // The following is used to ignore callbacks from SecurityViews that are no longer current
445 // (e.g. face unlock). This avoids unwanted asynchronous events from messing with the
446 // state for the current security method.
447 private KeyguardSecurityCallback mNullCallback = new KeyguardSecurityCallback() {
448 @Override
Jorim Jaggib690f0d2014-07-03 23:25:44 +0200449 public void userActivity() { }
Jim Miller7751ff62014-01-14 18:57:03 -0800450 @Override
Jim Miller7751ff62014-01-14 18:57:03 -0800451 public void reportUnlockAttempt(boolean success) { }
452 @Override
453 public boolean isVerifyUnlockOnly() { return false; }
454 @Override
455 public void dismiss(boolean securityVerified) { }
Andrew Lee72b46d42015-01-30 13:23:21 -0800456 @Override
457 public void reset() {}
Jim Miller7751ff62014-01-14 18:57:03 -0800458 };
459
460 private int getSecurityViewIdForMode(SecurityMode securityMode) {
461 switch (securityMode) {
Jim Miller7751ff62014-01-14 18:57:03 -0800462 case Pattern: return R.id.keyguard_pattern_view;
463 case PIN: return R.id.keyguard_pin_view;
464 case Password: return R.id.keyguard_password_view;
Jim Miller7751ff62014-01-14 18:57:03 -0800465 case SimPin: return R.id.keyguard_sim_pin_view;
466 case SimPuk: return R.id.keyguard_sim_puk_view;
467 }
468 return 0;
469 }
470
471 private int getLayoutIdFor(SecurityMode securityMode) {
472 switch (securityMode) {
Jim Miller7751ff62014-01-14 18:57:03 -0800473 case Pattern: return R.layout.keyguard_pattern_view;
474 case PIN: return R.layout.keyguard_pin_view;
475 case Password: return R.layout.keyguard_password_view;
Jim Miller7751ff62014-01-14 18:57:03 -0800476 case SimPin: return R.layout.keyguard_sim_pin_view;
477 case SimPuk: return R.layout.keyguard_sim_puk_view;
478 default:
479 return 0;
480 }
481 }
482
483 public SecurityMode getSecurityMode() {
484 return mSecurityModel.getSecurityMode();
485 }
486
Jorim Jaggi95e89ca2014-11-24 20:12:50 +0100487 public SecurityMode getCurrentSecurityMode() {
488 return mCurrentSecuritySelection;
489 }
490
Jim Miller7751ff62014-01-14 18:57:03 -0800491 public void verifyUnlock() {
492 mIsVerifyUnlockOnly = true;
493 showSecurityScreen(getSecurityMode());
494 }
495
496 public SecurityMode getCurrentSecuritySelection() {
497 return mCurrentSecuritySelection;
498 }
499
500 public void dismiss(boolean authenticated) {
501 mCallback.dismiss(authenticated);
502 }
503
504 public boolean needsInput() {
505 return mSecurityViewFlipper.needsInput();
506 }
507
508 @Override
509 public void setKeyguardCallback(KeyguardSecurityCallback callback) {
510 mSecurityViewFlipper.setKeyguardCallback(callback);
511 }
512
513 @Override
514 public void reset() {
515 mSecurityViewFlipper.reset();
516 }
517
518 @Override
519 public KeyguardSecurityCallback getCallback() {
520 return mSecurityViewFlipper.getCallback();
521 }
522
523 @Override
524 public void showUsabilityHint() {
525 mSecurityViewFlipper.showUsabilityHint();
526 }
527
Jim Miller838906b2012-10-19 18:41:25 -0700528}
Chris Wrenc0ae9e62012-11-05 13:16:31 -0500529