@@ -79,7 +79,7 @@ public class KeyguardHostView extends KeyguardViewBase {
7979 private boolean mEnableMenuKey ;
8080 private boolean mIsVerifyUnlockOnly ;
8181 private boolean mEnableFallback ; // TODO: This should get the value from KeyguardPatternView
82- private SecurityMode mCurrentSecuritySelection = SecurityMode .None ;
82+ private SecurityMode mCurrentSecuritySelection = SecurityMode .Invalid ;
8383
8484 protected Runnable mLaunchRunnable ;
8585
@@ -433,7 +433,8 @@ void showPrimarySecurityScreen(boolean turningOff) {
433433 */
434434 private void showBackupSecurityScreen () {
435435 if (DEBUG ) Log .d (TAG , "showBackupSecurity()" );
436- showSecurityScreen (mSecurityModel .getBackupSecurityMode ());
436+ SecurityMode backup = mSecurityModel .getBackupSecurityMode (mCurrentSecuritySelection );
437+ showSecurityScreen (backup );
437438 }
438439
439440 public boolean showNextSecurityScreenIfPresent () {
@@ -543,6 +544,45 @@ public void run() {
543544
544545 private KeyguardStatusViewManager mKeyguardStatusViewManager ;
545546
547+ // Used to ignore callbacks from methods that are no longer current (e.g. face unlock).
548+ // This avoids unwanted asynchronous events from messing with the state.
549+ private KeyguardSecurityCallback mNullCallback = new KeyguardSecurityCallback () {
550+
551+ @ Override
552+ public void userActivity (long timeout ) {
553+ }
554+
555+ @ Override
556+ public void showBackupSecurity () {
557+ }
558+
559+ @ Override
560+ public void setOnDismissRunnable (Runnable runnable ) {
561+ }
562+
563+ @ Override
564+ public void reportSuccessfulUnlockAttempt () {
565+ }
566+
567+ @ Override
568+ public void reportFailedUnlockAttempt () {
569+ }
570+
571+ @ Override
572+ public boolean isVerifyUnlockOnly () {
573+ return false ;
574+ }
575+
576+ @ Override
577+ public int getFailedAttempts () {
578+ return 0 ;
579+ }
580+
581+ @ Override
582+ public void dismiss (boolean securityVerified ) {
583+ }
584+ };
585+
546586 @ Override
547587 public void reset () {
548588 mIsVerifyUnlockOnly = false ;
@@ -568,9 +608,10 @@ private KeyguardSecurityView getSecurityView(SecurityMode securityMode) {
568608 }
569609 }
570610 boolean simPukFullScreen = getResources ().getBoolean (R .bool .kg_sim_puk_account_full_screen );
571- if (view == null ) {
611+ int layoutId = getLayoutIdFor (securityMode );
612+ if (view == null && layoutId != 0 ) {
572613 final LayoutInflater inflater = LayoutInflater .from (mContext );
573- View v = inflater .inflate (getLayoutIdFor ( securityMode ) , this , false );
614+ View v = inflater .inflate (layoutId , this , false );
574615 mSecurityViewContainer .addView (v );
575616 updateSecurityView (v );
576617
@@ -617,8 +658,12 @@ private void showSecurityScreen(SecurityMode securityMode) {
617658 KeyguardSecurityView newView = getSecurityView (securityMode );
618659
619660 // Emulate Activity life cycle
620- oldView .onPause ();
661+ if (oldView != null ) {
662+ oldView .onPause ();
663+ oldView .setKeyguardCallback (mNullCallback ); // ignore requests from old view
664+ }
621665 newView .onResume ();
666+ newView .setKeyguardCallback (mCallback );
622667
623668 final boolean needsInput = newView .needsInput ();
624669 if (mViewMediatorCallback != null ) {
@@ -749,7 +794,7 @@ private int getLayoutIdFor(SecurityMode securityMode) {
749794 case SimPin : return R .layout .keyguard_sim_pin_view ;
750795 case SimPuk : return R .layout .keyguard_sim_puk_view ;
751796 default :
752- throw new RuntimeException ( "No layout for securityMode " + securityMode ) ;
797+ return 0 ;
753798 }
754799 }
755800
0 commit comments