diff options
author | Brian Colonna <bcolonna@google.com> | 2012-05-04 17:42:15 -0400 |
---|---|---|
committer | Brian Colonna <bcolonna@google.com> | 2012-05-14 10:06:05 -0400 |
commit | 88240596fce58afe79a4d06752cd8f6c086e2600 (patch) | |
tree | f54ccef432ecefb3892136fe75d40dc2b8410095 /policy | |
parent | 0d607fbe546ac943de38dad33ae681b09efec6ea (diff) | |
download | frameworks_base-88240596fce58afe79a4d06752cd8f6c086e2600.zip frameworks_base-88240596fce58afe79a4d06752cd8f6c086e2600.tar.gz frameworks_base-88240596fce58afe79a4d06752cd8f6c086e2600.tar.bz2 |
Fix 6437474: Fixed black box appearing on rotation
The biometric unlock initializeView() function is called every time
the lockscreen is recreated. Since this normally happens when the
device turns off, initializeView() was covering the backup lock so the
backup lock is not exposed when the device turns back on. However,
initializeView() is also called when lockscreen is recreated due to an
orientation change.
With this change, the show() call to cover the backup lock has been
moved out of initializeView(), and the backup lock is now only covered
when the screen is turning off, preventing the backup lock from being
covered on an orientation change.
This also includes changes to prevent biometric unlock function calls
from occurring when SIM or Account unlock is in use. In fact, in any
situation where we know FUL won't be used, we don't even construct it.
This is not only more efficient, but it also cuts down on the
possibility of errors where FUL is being used when it shouldn't be.
Change-Id: Ie97761840df8de5701703d9b9b991726fb601064
Diffstat (limited to 'policy')
3 files changed, 52 insertions, 33 deletions
diff --git a/policy/src/com/android/internal/policy/impl/BiometricSensorUnlock.java b/policy/src/com/android/internal/policy/impl/BiometricSensorUnlock.java index a13ccc2..f476f82 100644 --- a/policy/src/com/android/internal/policy/impl/BiometricSensorUnlock.java +++ b/policy/src/com/android/internal/policy/impl/BiometricSensorUnlock.java @@ -21,8 +21,7 @@ import android.view.View; interface BiometricSensorUnlock { /** * Initializes the view provided for the biometric unlock UI to work within. The provided area - * completely covers the backup unlock mechanism. The view is then displayed in the same manner - * as if {@link BiometricSensorUnlock#show(long)} was called with a timeout of 0. + * completely covers the backup unlock mechanism. * @param biometricUnlockView View provided for the biometric unlock UI. */ public void initializeView(View biometricUnlockView); diff --git a/policy/src/com/android/internal/policy/impl/FaceUnlock.java b/policy/src/com/android/internal/policy/impl/FaceUnlock.java index ffdeeb1..a08b615 100644 --- a/policy/src/com/android/internal/policy/impl/FaceUnlock.java +++ b/policy/src/com/android/internal/policy/impl/FaceUnlock.java @@ -101,7 +101,6 @@ public class FaceUnlock implements BiometricSensorUnlock, Handler.Callback { public void initializeView(View biometricUnlockView) { Log.d(TAG, "initializeView()"); mFaceUnlockView = biometricUnlockView; - show(0); } /** diff --git a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java index 8320b1d..049e6ac 100644 --- a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java +++ b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java @@ -414,12 +414,6 @@ public class LockPatternKeyguardView extends KeyguardViewBase { } }; - // Indicates whether a biometric unlock method is in use - private boolean isBiometricUnlockInstalledAndSelected() { - return (mLockPatternUtils.usingBiometricWeak() && - mLockPatternUtils.isBiometricWeakInstalled()); - } - /** * @param context Used to inflate, and create views. * @param callback Keyguard callback object for pokewakelock(), etc. @@ -443,14 +437,6 @@ public class LockPatternKeyguardView extends KeyguardViewBase { sIsFirstAppearanceAfterBoot = false; mPluggedIn = mUpdateMonitor.isDevicePluggedIn(); mScreenOn = ((PowerManager)context.getSystemService(Context.POWER_SERVICE)).isScreenOn(); - - // If the biometric unlock is not being used, we don't bother constructing it. Then we can - // simply check if it is null when deciding whether we should make calls to it. - if (isBiometricUnlockInstalledAndSelected()) { - mBiometricUnlock = new FaceUnlock(context, updateMonitor, lockPatternUtils, - mKeyguardScreenCallback); - } - mUpdateMonitor.registerInfoCallback(mInfoCallback); /** @@ -848,19 +834,11 @@ public class LockPatternKeyguardView extends KeyguardViewBase { } } - // Re-create the unlock screen if necessary. This is primarily required to properly handle - // SIM state changes. This typically happens when this method is called by reset() + // Re-create the unlock screen if necessary. final UnlockMode unlockMode = getUnlockMode(); if (mode == Mode.UnlockScreen && unlockMode != UnlockMode.Unknown) { if (force || mUnlockScreen == null || unlockMode != mUnlockScreenMode) { - boolean restartBiometricUnlock = false; - if (mBiometricUnlock != null) { - restartBiometricUnlock = mBiometricUnlock.stop(); - } recreateUnlockScreen(unlockMode); - if (mBiometricUnlock != null && restartBiometricUnlock) { - maybeStartBiometricUnlock(); - } } } @@ -973,13 +951,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase { throw new IllegalArgumentException("unknown unlock mode " + unlockMode); } initializeTransportControlView(unlockView); - - if (mBiometricUnlock != null) { - // TODO: make faceLockAreaView a more general biometricUnlockView - // We will need to add our Face Unlock specific child views programmatically in - // initializeView rather than having them in the XML files. - mBiometricUnlock.initializeView(unlockView.findViewById(R.id.faceLockAreaView)); - } + initializeBiometricUnlockView(unlockView); mUnlockScreenMode = unlockMode; return unlockView; @@ -997,6 +969,55 @@ public class LockPatternKeyguardView extends KeyguardViewBase { } /** + * This returns false if there is any condition that indicates that the biometric unlock should + * not be used before the next time the unlock screen is recreated. In other words, if this + * returns false there is no need to even construct the biometric unlock. + */ + private boolean useBiometricUnlock() { + final UnlockMode unlockMode = getUnlockMode(); + final boolean backupIsTimedOut = (mUpdateMonitor.getFailedAttempts() >= + LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT); + return (mLockPatternUtils.usingBiometricWeak() && + mLockPatternUtils.isBiometricWeakInstalled() && + !mUpdateMonitor.getMaxBiometricUnlockAttemptsReached() && + !backupIsTimedOut && + (unlockMode == UnlockMode.Pattern || unlockMode == UnlockMode.Password)); + } + + private void initializeBiometricUnlockView(View view) { + boolean restartBiometricUnlock = false; + + if (mBiometricUnlock != null) { + restartBiometricUnlock = mBiometricUnlock.stop(); + } + + // If the biometric unlock is not being used, we don't bother constructing it. Then we can + // simply check if it is null when deciding whether we should make calls to it. + mBiometricUnlock = null; + if (useBiometricUnlock()) { + // TODO: make faceLockAreaView a more general biometricUnlockView + // We will need to add our Face Unlock specific child views programmatically in + // initializeView rather than having them in the XML files. + View biometricUnlockView = view.findViewById(R.id.faceLockAreaView); + if (biometricUnlockView != null) { + mBiometricUnlock = new FaceUnlock(mContext, mUpdateMonitor, mLockPatternUtils, + mKeyguardScreenCallback); + mBiometricUnlock.initializeView(biometricUnlockView); + + // If this is being called because the screen turned off, we want to cover the + // backup lock so it is covered when the screen turns back on. + if (!mScreenOn) mBiometricUnlock.show(0); + } else { + Log.w(TAG, "Couldn't find biometric unlock view"); + } + } + + if (mBiometricUnlock != null && restartBiometricUnlock) { + maybeStartBiometricUnlock(); + } + } + + /** * Given the current state of things, what should be the initial mode of * the lock screen (lock or unlock). */ |