From 9d20405e5117f05dfd3049798cd36a74142a6822 Mon Sep 17 00:00:00 2001 From: Brian Colonna Date: Tue, 18 Oct 2011 16:27:34 -0400 Subject: Fix 5433466 - FU out of position during orientation change If you turn the device from portrait to landscape mode and immediately invoke the lockscreen, it will come up in landscape mode and switch to the desired portrait mode within a couple of seconds. Previously, Face Unlock would come up in landscape mode, but its position would not change once lockscreen corrected itself, causing Face Unlock to be partly off the screen. This has been fixed by checking if we are already bound to Face Unlock when the layout is created. If this is true, then the layout is being created due to a change in orientation, and we stop Face Unlock, and restart it at the new position. This commit also adds a fix where we now use INVISIBLE for the Face Unlock area when it is not showing instead of using GONE. The dimensions of the Face Unlock area is 0-by-0 when set to GONE, and we want to avoid the possibility for the Face Unlock service being assigned a zero area. I'm not sure if this was ever causing problems, but it certainly is not the intended behavior. Also cleaned up some comments and logging. Change-Id: I68deb49cb26dafb5c238167d0c23f0eed2cfb75a --- .../policy/impl/LockPatternKeyguardView.java | 37 +++++++++++++++------- 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'policy/src') diff --git a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java index 96998af..1f594e5 100644 --- a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java +++ b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java @@ -1136,14 +1136,25 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler // Everything below pertains to FaceLock - might want to separate this out - // Only pattern and pin unlock screens actually have a view for the FaceLock area, so it's not - // uncommon for it to not exist. But if it does exist, we need to make sure it's shown (hiding - // the fallback) if FaceLock is enabled, and make sure it's hidden (showing the unlock) if - // FaceLock is disabled + // Take care of FaceLock area when layout is created private void initializeFaceLockAreaView(View view) { - mFaceLockAreaView = view.findViewById(R.id.faceLockAreaView); - if (mFaceLockAreaView == null) { - if (DEBUG) Log.d(TAG, "Layout does not have faceLockAreaView"); + if (mLockPatternUtils.usingBiometricWeak() && + mLockPatternUtils.isBiometricWeakInstalled()) { + mFaceLockAreaView = view.findViewById(R.id.faceLockAreaView); + if (mFaceLockAreaView == null) { + Log.e(TAG, "Layout does not have faceLockAreaView and FaceLock is enabled"); + } else { + if (mBoundToFaceLockService) { + // If we are creating a layout when we are already bound to FaceLock, then we + // are undergoing an orientation change. Stop FaceLock and restart it in the + // new location. + if (DEBUG) Log.d(TAG, "Restarting FL - creating view while already bound"); + stopAndUnbindFromFaceLock(); + activateFaceLockIfAble(); + } + } + } else { + mFaceLockAreaView = null; // Set to null if not using FaceLock } } @@ -1160,7 +1171,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler break; case MSG_HIDE_FACELOCK_AREA_VIEW: if (mFaceLockAreaView != null) { - mFaceLockAreaView.setVisibility(View.GONE); + mFaceLockAreaView.setVisibility(View.INVISIBLE); } break; default: @@ -1196,7 +1207,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler mHandler.sendEmptyMessageDelayed(MSG_HIDE_FACELOCK_AREA_VIEW, timeoutMillis); } - // Binds to FaceLock service, but does not tell it to start + // Binds to FaceLock service. This call does not tell it to start, but it causes the service + // to call the onServiceConnected callback, which then starts FaceLock. public void bindToFaceLock() { if (mLockPatternUtils.usingBiometricWeak() && mLockPatternUtils.isBiometricWeakInstalled()) { @@ -1232,9 +1244,10 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler if (DEBUG) Log.d(TAG, "after unbind from FaceLock service"); mBoundToFaceLockService = false; } else { - // This could probably happen after the session when someone activates FaceLock - // because it wasn't active when the phone was turned on - Log.w(TAG, "Attempt to unbind from FaceLock when not bound"); + // This is usually not an error when this happens. Sometimes we will tell it to + // unbind multiple times because it's called from both onWindowFocusChanged and + // onDetachedFromWindow. + if (DEBUG) Log.d(TAG, "Attempt to unbind from FaceLock when not bound"); } } } -- cgit v1.1