@@ -504,6 +504,9 @@ public void onScreenTurnedOff() {
504504 } else {
505505 ((KeyguardScreen ) mUnlockScreen ).onPause ();
506506 }
507+
508+ // When screen is turned off, need to unbind from FaceLock service if using FaceLock
509+ stopAndUnbindFromFaceLock ();
507510 }
508511
509512 @ Override
@@ -514,6 +517,14 @@ public void onScreenTurnedOn() {
514517 } else {
515518 ((KeyguardScreen ) mUnlockScreen ).onResume ();
516519 }
520+
521+ // When screen is turned on, need to bind to FaceLock service if we are using FaceLock
522+ // But only if not dealing with a call
523+ if (mUpdateMonitor .getPhoneState () == TelephonyManager .CALL_STATE_IDLE ) {
524+ bindToFaceLock ();
525+ } else {
526+ mHandler .sendEmptyMessage (MSG_HIDE_FACELOCK_AREA_VIEW );
527+ }
517528 }
518529
519530 private void recreateLockScreen () {
@@ -543,6 +554,11 @@ private void recreateUnlockScreen(UnlockMode unlockMode) {
543554 @ Override
544555 protected void onDetachedFromWindow () {
545556 removeCallbacks (mRecreateRunnable );
557+
558+ // When view is hidden, need to unbind from FaceLock service if we are using FaceLock
559+ // e.g., when device becomes unlocked
560+ stopAndUnbindFromFaceLock ();
561+
546562 super .onDetachedFromWindow ();
547563 }
548564
@@ -952,8 +968,9 @@ public int getMinimumHeight() {
952968 // Everything below pertains to FaceLock - might want to separate this out
953969
954970 // Only pattern and pin unlock screens actually have a view for the FaceLock area, so it's not
955- // uncommon for it to not exist. But if it does exist, we need to make sure it's showing if
956- // FaceLock is enabled, and make sure it's not showing if FaceLock is disabled
971+ // uncommon for it to not exist. But if it does exist, we need to make sure it's shown (hiding
972+ // the fallback) if FaceLock is enabled, and make sure it's hidden (showing the unlock) if
973+ // FaceLock is disabled
957974 private void initializeFaceLockAreaView (View view ) {
958975 mFaceLockAreaView = view .findViewById (R .id .faceLockAreaView );
959976 if (mFaceLockAreaView == null ) {
@@ -997,9 +1014,7 @@ public void bindToFaceLock() {
9971014 if (DEBUG ) Log .d (TAG , "after bind to FaceLock service" );
9981015 mBoundToFaceLockService = true ;
9991016 } else {
1000- // On startup I've seen onScreenTurnedOn() get called twice without
1001- // onScreenTurnedOff() being called in between, which can cause this (bcolonna)
1002- if (DEBUG ) Log .w (TAG , "Attempt to bind to FaceLock when already bound" );
1017+ Log .w (TAG , "Attempt to bind to FaceLock when already bound" );
10031018 }
10041019 }
10051020 }
@@ -1017,7 +1032,7 @@ public void stopAndUnbindFromFaceLock() {
10171032 } else {
10181033 // This could probably happen after the session when someone activates FaceLock
10191034 // because it wasn't active when the phone was turned on
1020- if ( DEBUG ) Log .w (TAG , "Attempt to unbind from FaceLock when not bound" );
1035+ Log .w (TAG , "Attempt to unbind from FaceLock when not bound" );
10211036 }
10221037 }
10231038 }
@@ -1048,7 +1063,7 @@ public void onServiceDisconnected(ComponentName className) {
10481063 mFaceLockService = null ;
10491064 mFaceLockServiceRunning = false ;
10501065 }
1051- if ( DEBUG ) Log .w (TAG , "Unexpected disconnect from FaceLock service" );
1066+ Log .w (TAG , "Unexpected disconnect from FaceLock service" );
10521067 }
10531068 };
10541069
@@ -1099,36 +1114,21 @@ public void stopFaceLock()
10991114 // Stops the FaceLock UI and indicates that the phone should be unlocked
11001115 @ Override
11011116 public void unlock () {
1102- if (DEBUG ) Log .d (TAG , "FaceLock unlock" );
1103- // Note that we don't hide the client FaceLockAreaView because we want to keep the
1104- // lock screen covered while the phone is unlocked
1105-
1117+ if (DEBUG ) Log .d (TAG , "FaceLock unlock()" );
1118+ mHandler .sendEmptyMessage (MSG_SHOW_FACELOCK_AREA_VIEW ); // Keep fallback covered
11061119 stopFaceLock ();
1120+
11071121 mKeyguardScreenCallback .keyguardDone (true );
11081122 mKeyguardScreenCallback .reportSuccessfulUnlockAttempt ();
11091123 }
11101124
11111125 // Stops the FaceLock UI and exposes the backup method without unlocking
1126+ // This means either the user has cancelled out or FaceLock failed to recognize them
11121127 @ Override
11131128 public void cancel () {
1114- // In this case, either the user has cancelled out, or FaceLock failed to recognize them
1115- if (DEBUG ) Log .d (TAG , "FaceLock cancel" );
1116- // Here we hide the client FaceLockViewArea to expose the underlying backup method
1117- mHandler .sendEmptyMessage (MSG_HIDE_FACELOCK_AREA_VIEW );
1118- stopFaceLock ();
1119- }
1120-
1121- // Stops the FaceLock UI and puts the phone to sleep
1122- @ Override
1123- public void sleepDevice () {
1124- // In this case, it appears the phone has been turned on accidentally
1125- if (DEBUG ) Log .d (TAG , "FaceLock accidental turn on" );
1126- // Here we hide the client FaceLockViewArea to expose the underlying backup method
1127- mHandler .sendEmptyMessage (MSG_HIDE_FACELOCK_AREA_VIEW );
1129+ if (DEBUG ) Log .d (TAG , "FaceLock cancel()" );
1130+ mHandler .sendEmptyMessage (MSG_HIDE_FACELOCK_AREA_VIEW ); // Expose fallback
11281131 stopFaceLock ();
1129- // TODO(bcolonna): how do we put the phone back to sleep (i.e., turn off the screen)
1130- // TODO(bcolonna): this should be removed once the service is no longer calling it
1131- // because we are just going to let the lockscreen timeout
11321132 }
11331133 };
11341134}
0 commit comments