@@ -1140,14 +1140,25 @@ public int getMinimumHeight() {
11401140
11411141 // Everything below pertains to FaceLock - might want to separate this out
11421142
1143- // Only pattern and pin unlock screens actually have a view for the FaceLock area, so it's not
1144- // uncommon for it to not exist. But if it does exist, we need to make sure it's shown (hiding
1145- // the fallback) if FaceLock is enabled, and make sure it's hidden (showing the unlock) if
1146- // FaceLock is disabled
1143+ // Take care of FaceLock area when layout is created
11471144 private void initializeFaceLockAreaView (View view ) {
1148- mFaceLockAreaView = view .findViewById (R .id .faceLockAreaView );
1149- if (mFaceLockAreaView == null ) {
1150- if (DEBUG ) Log .d (TAG , "Layout does not have faceLockAreaView" );
1145+ if (mLockPatternUtils .usingBiometricWeak () &&
1146+ mLockPatternUtils .isBiometricWeakInstalled ()) {
1147+ mFaceLockAreaView = view .findViewById (R .id .faceLockAreaView );
1148+ if (mFaceLockAreaView == null ) {
1149+ Log .e (TAG , "Layout does not have faceLockAreaView and FaceLock is enabled" );
1150+ } else {
1151+ if (mBoundToFaceLockService ) {
1152+ // If we are creating a layout when we are already bound to FaceLock, then we
1153+ // are undergoing an orientation change. Stop FaceLock and restart it in the
1154+ // new location.
1155+ if (DEBUG ) Log .d (TAG , "Restarting FL - creating view while already bound" );
1156+ stopAndUnbindFromFaceLock ();
1157+ activateFaceLockIfAble ();
1158+ }
1159+ }
1160+ } else {
1161+ mFaceLockAreaView = null ; // Set to null if not using FaceLock
11511162 }
11521163 }
11531164
@@ -1164,7 +1175,7 @@ public boolean handleMessage(Message msg) {
11641175 break ;
11651176 case MSG_HIDE_FACELOCK_AREA_VIEW :
11661177 if (mFaceLockAreaView != null ) {
1167- mFaceLockAreaView .setVisibility (View .GONE );
1178+ mFaceLockAreaView .setVisibility (View .INVISIBLE );
11681179 }
11691180 break ;
11701181 default :
@@ -1200,7 +1211,8 @@ private void showFaceLockAreaWithTimeout(long timeoutMillis) {
12001211 mHandler .sendEmptyMessageDelayed (MSG_HIDE_FACELOCK_AREA_VIEW , timeoutMillis );
12011212 }
12021213
1203- // Binds to FaceLock service, but does not tell it to start
1214+ // Binds to FaceLock service. This call does not tell it to start, but it causes the service
1215+ // to call the onServiceConnected callback, which then starts FaceLock.
12041216 public void bindToFaceLock () {
12051217 if (mLockPatternUtils .usingBiometricWeak () &&
12061218 mLockPatternUtils .isBiometricWeakInstalled ()) {
@@ -1236,9 +1248,10 @@ public void stopAndUnbindFromFaceLock() {
12361248 if (DEBUG ) Log .d (TAG , "after unbind from FaceLock service" );
12371249 mBoundToFaceLockService = false ;
12381250 } else {
1239- // This could probably happen after the session when someone activates FaceLock
1240- // because it wasn't active when the phone was turned on
1241- Log .w (TAG , "Attempt to unbind from FaceLock when not bound" );
1251+ // This is usually not an error when this happens. Sometimes we will tell it to
1252+ // unbind multiple times because it's called from both onWindowFocusChanged and
1253+ // onDetachedFromWindow.
1254+ if (DEBUG ) Log .d (TAG , "Attempt to unbind from FaceLock when not bound" );
12421255 }
12431256 }
12441257 }
0 commit comments