diff options
Diffstat (limited to 'policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java')
-rw-r--r-- | policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java | 94 |
1 files changed, 86 insertions, 8 deletions
diff --git a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java index ca12c87..8e7a276 100644 --- a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java +++ b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java @@ -113,6 +113,11 @@ public class LockPatternKeyguardView extends KeyguardViewBase { Pattern, /** + * Unlock by swiping a finger. + */ + Finger, + + /** * Unlock by entering a sim pin. */ SimPin, @@ -170,6 +175,12 @@ public class LockPatternKeyguardView extends KeyguardViewBase { */ private Configuration mConfiguration; + /** + * Used to dismiss the timeout dialog + */ + private AlertDialog mTimeoutDialog; + + private Runnable mRecreateRunnable = new Runnable() { public void run() { recreateScreens(); @@ -209,6 +220,17 @@ public class LockPatternKeyguardView extends KeyguardViewBase { mUpdateMonitor = updateMonitor; mLockPatternUtils = lockPatternUtils; mWindowController = controller; + mTimeoutDialog = null; + + // By design, this situation should never happen. + // If finger lock is in use, we should only allow the finger settings menu + // to delete all enrolled fingers. Other applications, like TSMDemo, should + // not get access to the database. + // + // Simply disable the finger key guard since it will fail to work in this case. + if (mLockPatternUtils.isLockFingerEnabled() && !mLockPatternUtils.savedFingerExists()) { + mLockPatternUtils.setLockFingerEnabled(false); + } int LockscreenDisableOnSecurityValue = Settings.System.getInt( mContext.getContentResolver(), Settings.System.LOCKSCREEN_DISABLE_ON_SECURITY, 3); @@ -284,6 +306,13 @@ public class LockPatternKeyguardView extends KeyguardViewBase { } public boolean isVerifyUnlockOnly() { + // This is a good place to dismiss the timeout dialog if there is one. + if (mTimeoutDialog != null) { + if (mTimeoutDialog.isShowing()) { + mTimeoutDialog.dismiss(); + } + mTimeoutDialog = null; + } return mIsVerifyUnlockOnly; } @@ -330,11 +359,13 @@ public class LockPatternKeyguardView extends KeyguardViewBase { " (enableFallback=" + mEnableFallback + ")"); final boolean usingLockPattern = mLockPatternUtils.getKeyguardStoredPasswordQuality() == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING; - if (usingLockPattern && mEnableFallback && failedAttempts == + final boolean usingLockFinger = mLockPatternUtils.getKeyguardStoredPasswordQuality() + == DevicePolicyManager.PASSWORD_QUALITY_FINGER; + if ((usingLockPattern || usingLockFinger) && mEnableFallback && failedAttempts == (LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET - LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) { showAlmostAtAccountLoginDialog(); - } else if (usingLockPattern && mEnableFallback + } else if ((usingLockPattern || usingLockFinger) && mEnableFallback && failedAttempts >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET) { mLockPatternUtils.setPermanentlyLocked(true); updateScreen(mMode); @@ -457,6 +488,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase { @Override public void onScreenTurnedOff() { + Log.d(TAG, "onScreenTurnedOff()"); mScreenOn = false; mForgotPattern = false; if (mMode == Mode.LockScreen) { @@ -468,6 +500,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase { @Override public void onScreenTurnedOn() { + Log.d(TAG, "onScreenTurnedOn()"); mScreenOn = true; if (mMode == Mode.LockScreen) { ((KeyguardScreen) mLockScreen).onResume(); @@ -566,6 +599,9 @@ public class LockPatternKeyguardView extends KeyguardViewBase { case Pattern: secure = mLockPatternUtils.isLockPatternEnabled(); break; + case Finger: + secure = mLockPatternUtils.isLockFingerEnabled(); + break; case SimPin: secure = mUpdateMonitor.getSimState() == IccCard.State.PIN_REQUIRED || mUpdateMonitor.getSimState() == IccCard.State.PUK_REQUIRED; @@ -674,6 +710,18 @@ public class LockPatternKeyguardView extends KeyguardViewBase { "createUnlockScreenFor(" + unlockMode + "): mEnableFallback=" + mEnableFallback); view.setEnableFallback(mEnableFallback); unlockView = view; + } else if (unlockMode == UnlockMode.Finger) { + FingerUnlockScreen view = new FingerUnlockScreen( + mContext, + mConfiguration, + mLockPatternUtils, + mUpdateMonitor, + mKeyguardScreenCallback, + mUpdateMonitor.getFailedAttempts()); + if (DEBUG) Log.d(TAG, + "createUnlockScreenFor(" + unlockMode + "): mEnableFallback=" + mEnableFallback); + view.setEnableFallback(mEnableFallback); + unlockView = view; } else if (unlockMode == UnlockMode.SimPin) { unlockView = new SimUnlockScreen( mContext, @@ -727,9 +775,12 @@ public class LockPatternKeyguardView extends KeyguardViewBase { if (stuckOnLockScreenBecauseSimMissing() || (simState == IccCard.State.PUK_REQUIRED)) { return Mode.LockScreen; } else { - // Disable LockScreen if security lockscreen is active and option in CMParts set - // Also don't show the slider lockscreen if pin is required - if (mLockscreenDisableOnSecurity && isSecure() || (simState == IccCard.State.PIN_REQUIRED)) { + // Show LockScreen first for any screen other than Pattern unlock and Finger unlock. + final boolean usingLockPattern = mLockPatternUtils.getKeyguardStoredPasswordQuality() + == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING; + final boolean usingLockFinger = mLockPatternUtils.getKeyguardStoredPasswordQuality() + == DevicePolicyManager.PASSWORD_QUALITY_FINGER; + if (mLockscreenDisableOnSecurity && isSecure() && (usingLockPattern || usingLockFinger) || (simState == IccCard.State.PIN_REQUIRED)) { return Mode.UnlockScreen; } else { return Mode.LockScreen; @@ -753,11 +804,14 @@ public class LockPatternKeyguardView extends KeyguardViewBase { case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC: currentMode = UnlockMode.Password; break; + case DevicePolicyManager.PASSWORD_QUALITY_FINGER: case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING: case DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED: - // "forgot pattern" button is only available in the pattern mode... + // "forgot pattern" button is only available in the pattern mode and finger mode... if (mForgotPattern || mLockPatternUtils.isPermanentlyLocked()) { currentMode = UnlockMode.Account; + } else if (mode == DevicePolicyManager.PASSWORD_QUALITY_FINGER) { + currentMode = UnlockMode.Finger; } else { currentMode = UnlockMode.Pattern; } @@ -771,10 +825,20 @@ public class LockPatternKeyguardView extends KeyguardViewBase { private void showTimeoutDialog() { int timeoutInSeconds = (int) LockPatternUtils.FAILED_ATTEMPT_TIMEOUT_MS / 1000; - String message = mContext.getString( + String message; + + if (mUnlockScreenMode == UnlockMode.Finger) { + message = mContext.getString( + R.string.lockscreen_too_many_failed_fingers_dialog_message, + mUpdateMonitor.getFailedAttempts(), + timeoutInSeconds); + } else { + message = mContext.getString( R.string.lockscreen_too_many_failed_attempts_dialog_message, mUpdateMonitor.getFailedAttempts(), timeoutInSeconds); + } + final AlertDialog dialog = new AlertDialog.Builder(mContext) .setTitle(null) .setMessage(message) @@ -787,17 +851,30 @@ public class LockPatternKeyguardView extends KeyguardViewBase { WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND); } + mTimeoutDialog = dialog; dialog.show(); } private void showAlmostAtAccountLoginDialog() { int timeoutInSeconds = (int) LockPatternUtils.FAILED_ATTEMPT_TIMEOUT_MS / 1000; - String message = mContext.getString( + String message; + + if (mUnlockScreenMode == UnlockMode.Finger) { + message = mContext.getString( + R.string.lockscreen_failed_fingers_almost_glogin, + LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET + - LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT, + LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT, + timeoutInSeconds); + } else { + message = mContext.getString( R.string.lockscreen_failed_attempts_almost_glogin, LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET - LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT, LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT, timeoutInSeconds); + } + final AlertDialog dialog = new AlertDialog.Builder(mContext) .setTitle(null) .setMessage(message) @@ -810,6 +887,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase { WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND); } + mTimeoutDialog = dialog; dialog.show(); } |