diff options
author | David van Tonder <david.vantonder@gmail.com> | 2012-04-28 11:58:16 -0400 |
---|---|---|
committer | David van Tonder <david.vantonder@gmail.com> | 2012-04-28 11:58:16 -0400 |
commit | a11b2ddc79cc25f6bf5fad17d4d3908af68a94a2 (patch) | |
tree | 9d032ab11cbfa2002513cb63177d4bbe5c6eaec8 /policy | |
parent | 690f7075b6720497ae9ae709304cca4c9b17d3d2 (diff) | |
download | frameworks_base-a11b2ddc79cc25f6bf5fad17d4d3908af68a94a2.zip frameworks_base-a11b2ddc79cc25f6bf5fad17d4d3908af68a94a2.tar.gz frameworks_base-a11b2ddc79cc25f6bf5fad17d4d3908af68a94a2.tar.bz2 |
Framework: Slide lock delay support (Part 1 of 2)
This commit adds the framework support for the Slide lock delay settings while
retaining the security integrity of AOSP.
Change-Id: Ib023025535c022213dc13de82b0ffae9a53d9ef5
Diffstat (limited to 'policy')
-rw-r--r-- | policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java index 09d411f..8976c3c 100644 --- a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java +++ b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java @@ -122,7 +122,6 @@ public class KeyguardViewMediator implements KeyguardViewCallback, */ protected static final int AWAKE_INTERVAL_DEFAULT_MS = 10000; - /** * The default amount of time we stay awake (used for all key input) when * the keyboard is open @@ -356,11 +355,21 @@ 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(); + // Prepare for handling Lock/Slide lock delay and timeout + boolean lockImmediately = false; + final ContentResolver cr = mContext.getContentResolver(); + boolean separateSlideLockTimeoutEnabled = Settings.System.getInt(cr, + Settings.System.SCREEN_LOCK_SLIDE_DELAY_TOGGLE, 0) == 1; + if (mLockPatternUtils.isSecure()) { + // Lock immediately based on setting if secure (user has a pin/pattern/password) + // This is retained as-is to ensue AOSP security integrity is maintained + lockImmediately = true; + } else { + // Unless a separate slide lock timeout is enabled, this "locks" the device when + // not secure to provide easy access to the camera while preventing unwanted input + lockImmediately = separateSlideLockTimeoutEnabled ? false + : mLockPatternUtils.getPowerButtonInstantlyLocks(); + } if (mExitSecureCallback != null) { if (DEBUG) Log.d(TAG, "pending exit secure callback cancelled"); @@ -375,11 +384,9 @@ public class KeyguardViewMediator implements KeyguardViewCallback, } 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) - final ContentResolver cr = mContext.getContentResolver(); + // 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) // From DisplaySettings long displayTimeout = Settings.System.getInt(cr, SCREEN_OFF_TIMEOUT, @@ -390,17 +397,33 @@ public class KeyguardViewMediator implements KeyguardViewCallback, Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, KEYGUARD_LOCK_AFTER_DELAY_DEFAULT); + // From CyanogenMod specific Settings + int slideLockTimeoutDelay = (why == WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT ? Settings.System + .getInt(cr, Settings.System.SCREEN_LOCK_SLIDE_TIMEOUT_DELAY, + KEYGUARD_LOCK_AFTER_DELAY_DEFAULT) : Settings.System.getInt(cr, + Settings.System.SCREEN_LOCK_SLIDE_SCREENOFF_DELAY, 0)); + // From DevicePolicyAdmin final long policyTimeout = mLockPatternUtils.getDevicePolicyManager() .getMaximumTimeToLock(null); + if (DEBUG) Log.d(TAG, "Security lock screen timeout delay is " + lockAfterTimeout + + " ms; slide lock screen timeout delay is " + + slideLockTimeoutDelay + + " ms; Separate slide lock delay settings considered: " + + separateSlideLockTimeoutEnabled + + "; Policy timeout is " + + policyTimeout + + " ms"); + long timeout; if (policyTimeout > 0) { // policy in effect. Make sure we don't go beyond policy limit. displayTimeout = Math.max(displayTimeout, 0); // ignore negative values timeout = Math.min(policyTimeout - displayTimeout, lockAfterTimeout); } else { - timeout = lockAfterTimeout; + // Not sure lockAfterTimeout is needed any more but keeping it for AOSP compatibility + timeout = separateSlideLockTimeoutEnabled ? slideLockTimeoutDelay : lockAfterTimeout; } if (timeout <= 0) { |