diff options
| author | Jim Miller <jaggies@google.com> | 2012-01-10 10:34:51 -0800 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2012-01-10 10:34:51 -0800 |
| commit | 5437c220e239dc6276942990bc81c1388cfb176c (patch) | |
| tree | e7324a7a036e03808450d39970e2586dae43cac8 | |
| parent | 251f0485440cc8202308ce6c00cbc56b207ded55 (diff) | |
| parent | d3872f55045b7ce7be7dd7ae5fff37d7988bdcb2 (diff) | |
| download | frameworks_base-5437c220e239dc6276942990bc81c1388cfb176c.zip frameworks_base-5437c220e239dc6276942990bc81c1388cfb176c.tar.gz frameworks_base-5437c220e239dc6276942990bc81c1388cfb176c.tar.bz2 | |
am d3872f55: am 62fad768: Merge "Fix 4560303: Add setting to lock later when power button pressed" into ics-mr1
* commit 'd3872f55045b7ce7be7dd7ae5fff37d7988bdcb2':
Fix 4560303: Add setting to lock later when power button pressed
| -rw-r--r-- | core/java/com/android/internal/widget/LockPatternUtils.java | 27 | ||||
| -rw-r--r-- | policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java | 15 |
2 files changed, 30 insertions, 12 deletions
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index adb0ac9..905a171 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -117,6 +117,8 @@ public class LockPatternUtils { = "lockscreen.biometric_weak_fallback"; public final static String BIOMETRIC_WEAK_EVER_CHOSEN_KEY = "lockscreen.biometricweakeverchosen"; + public final static String LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS + = "lockscreen.power_button_instantly_locks"; private final static String PASSWORD_HISTORY_KEY = "lockscreen.passwordhistory"; @@ -335,7 +337,7 @@ public class LockPatternUtils { * @return True if the user has ever chosen a pattern. */ public boolean isPatternEverChosen() { - return getBoolean(PATTERN_EVER_CHOSEN_KEY); + return getBoolean(PATTERN_EVER_CHOSEN_KEY, false); } /** @@ -345,7 +347,7 @@ public class LockPatternUtils { * @return True if the user has ever chosen biometric weak. */ public boolean isBiometricWeakEverChosen() { - return getBoolean(BIOMETRIC_WEAK_EVER_CHOSEN_KEY); + return getBoolean(BIOMETRIC_WEAK_EVER_CHOSEN_KEY, false); } /** @@ -845,7 +847,7 @@ public class LockPatternUtils { getLong(PASSWORD_TYPE_ALTERNATE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING; - return getBoolean(Settings.Secure.LOCK_PATTERN_ENABLED) + return getBoolean(Settings.Secure.LOCK_PATTERN_ENABLED, false) && (getLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING || (usingBiometricWeak() && backupEnabled)); @@ -891,7 +893,7 @@ public class LockPatternUtils { * @return Whether the visible pattern is enabled. */ public boolean isVisiblePatternEnabled() { - return getBoolean(Settings.Secure.LOCK_PATTERN_VISIBLE); + return getBoolean(Settings.Secure.LOCK_PATTERN_VISIBLE, false); } /** @@ -905,7 +907,7 @@ public class LockPatternUtils { * @return Whether tactile feedback for the pattern is enabled. */ public boolean isTactileFeedbackEnabled() { - return getBoolean(Settings.Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED); + return getBoolean(Settings.Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED, false); } /** @@ -946,7 +948,7 @@ public class LockPatternUtils { * attempts. */ public boolean isPermanentlyLocked() { - return getBoolean(LOCKOUT_PERMANENT_KEY); + return getBoolean(LOCKOUT_PERMANENT_KEY, false); } /** @@ -989,9 +991,10 @@ public class LockPatternUtils { return nextAlarm; } - private boolean getBoolean(String secureSettingKey) { + private boolean getBoolean(String secureSettingKey, boolean defaultValue) { return 1 == - android.provider.Settings.Secure.getInt(mContentResolver, secureSettingKey, 0); + android.provider.Settings.Secure.getInt(mContentResolver, secureSettingKey, + defaultValue ? 1 : 0); } private void setBoolean(String secureSettingKey, boolean enabled) { @@ -1092,4 +1095,12 @@ public class LockPatternUtils { mContext.startActivity(intent); } + public void setPowerButtonInstantlyLocks(boolean enabled) { + setBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, enabled); + } + + public boolean getPowerButtonInstantlyLocks() { + return getBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, true); + } + } diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java index b514689..52d6d24 100644 --- a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java +++ b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java @@ -350,6 +350,12 @@ public class KeyguardViewMediator implements KeyguardViewCallback, mScreenOn = false; if (DEBUG) Log.d(TAG, "onScreenTurnedOff(" + why + ")"); + // Lock immediately based on setting if secure (user has a pin/pattern/password). + // This also "locks" the device when not secure to provide easy access to the + // camera while preventing unwanted input. + final boolean lockImmediately = + mLockPatternUtils.getPowerButtonInstantlyLocks() || !mLockPatternUtils.isSecure(); + if (mExitSecureCallback != null) { if (DEBUG) Log.d(TAG, "pending exit secure callback cancelled"); mExitSecureCallback.onKeyguardExitResult(false); @@ -360,8 +366,10 @@ public class KeyguardViewMediator implements KeyguardViewCallback, } else if (mShowing) { notifyScreenOffLocked(); resetStateLocked(); - } else if (why == WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT) { - // if the screen turned off because of timeout, set an alarm + } else if (why == WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT + || (why == WindowManagerPolicy.OFF_BECAUSE_OF_USER && !lockImmediately)) { + // if the screen turned off because of timeout or the user hit the power button + // and we don't need to lock immediately, set an alarm // to enable it a little bit later (i.e, give the user a chance // to turn the screen back on within a certain window without // having to unlock the screen) @@ -400,8 +408,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback, intent.putExtra("seq", mDelayedShowingSequence); PendingIntent sender = PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); - mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, when, - sender); + mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, when, sender); if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = " + mDelayedShowingSequence); } |
