diff options
author | Jim Miller <jaggies@google.com> | 2010-08-30 21:21:34 -0700 |
---|---|---|
committer | Jim Miller <jaggies@google.com> | 2010-09-01 21:00:30 -0700 |
commit | bc4603b0b1f1242387655274e39649882ca391d1 (patch) | |
tree | 2fa809bcb70cae54ca0a5fae704bade74d728c64 /policy | |
parent | 5486dcb00a44f6367a880cf7ea7f699bfa1e15cb (diff) | |
download | frameworks_base-bc4603b0b1f1242387655274e39649882ca391d1.zip frameworks_base-bc4603b0b1f1242387655274e39649882ca391d1.tar.gz frameworks_base-bc4603b0b1f1242387655274e39649882ca391d1.tar.bz2 |
Fix 2579224: Add a separate timeout for lockscreen vs display
This change adds a second timeout to the SecuritySettings page
separate from the standard display timeout.
Change-Id: I41fe10e31688308f52695ad3ee30a4b0507112bd
Diffstat (limited to 'policy')
-rw-r--r-- | policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java | 61 |
1 files changed, 49 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 88203c3..d19f318 100644 --- a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java +++ b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java @@ -16,6 +16,8 @@ package com.android.internal.policy.impl; +import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT; + import com.android.internal.telephony.IccCard; import com.android.internal.widget.LockPatternUtils; @@ -41,6 +43,7 @@ import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemProperties; import android.provider.Settings; +import android.provider.Settings.SettingNotFoundException; import android.telephony.TelephonyManager; import android.util.Config; import android.util.EventLog; @@ -93,6 +96,7 @@ import android.view.WindowManagerPolicy; */ public class KeyguardViewMediator implements KeyguardViewCallback, KeyguardUpdateMonitor.SimStateCallback { + private static final int KEYGUARD_DISPLAY_TIMEOUT_DELAY_DEFAULT = 30000; private final static boolean DEBUG = false && Config.LOGD; private final static boolean DBG_WAKE = DEBUG || true; @@ -133,7 +137,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback, * turning on the keyguard (i.e, the user has this much time to turn * the screen back on without having to face the keyguard). */ - private static final int KEYGUARD_DELAY_MS = 5000; + private static final int KEYGUARD_LOCK_AFTER_DELAY_DEFAULT = 5000; /** * How long we'll wait for the {@link KeyguardViewCallback#keyguardDoneDrawing()} @@ -244,6 +248,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback, * the keyguard. */ private boolean mWaitingUntilKeyguardVisible = false; + private LockPatternUtils mLockPatternUtils; public KeyguardViewMediator(Context context, PhoneWindowManager callback, LocalPowerManager powerManager) { @@ -275,8 +280,9 @@ public class KeyguardViewMediator implements KeyguardViewCallback, mUpdateMonitor.registerSimStateCallback(this); - mKeyguardViewProperties = new LockPatternKeyguardViewProperties( - new LockPatternUtils(mContext), mUpdateMonitor); + mLockPatternUtils = new LockPatternUtils(mContext); + mKeyguardViewProperties + = new LockPatternKeyguardViewProperties(mLockPatternUtils, mUpdateMonitor); mKeyguardViewManager = new KeyguardViewManager( context, WindowManagerImpl.getDefault(), this, @@ -326,15 +332,46 @@ public class KeyguardViewMediator implements KeyguardViewCallback, // 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) - long when = SystemClock.elapsedRealtime() + KEYGUARD_DELAY_MS; - Intent intent = new Intent(DELAYED_KEYGUARD_ACTION); - intent.putExtra("seq", mDelayedShowingSequence); - PendingIntent sender = PendingIntent.getBroadcast(mContext, - 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); - mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, when, - sender); - if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = " - + mDelayedShowingSequence); + final ContentResolver cr = mContext.getContentResolver(); + + // From DisplaySettings + long displayTimeout = Settings.System.getInt(cr, SCREEN_OFF_TIMEOUT, + KEYGUARD_DISPLAY_TIMEOUT_DELAY_DEFAULT); + + // From SecuritySettings + final long lockAfterTimeout = Settings.Secure.getInt(cr, + Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, + KEYGUARD_LOCK_AFTER_DELAY_DEFAULT); + + // From DevicePolicyAdmin + final long policyTimeout = mLockPatternUtils.getDevicePolicyManager() + .getMaximumTimeToLock(null); + + 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; + } + + if (timeout <= 0) { + // Lock now + mSuppressNextLockSound = true; + doKeyguard(); + } else { + // Lock in the future + long when = SystemClock.elapsedRealtime() + timeout; + Intent intent = new Intent(DELAYED_KEYGUARD_ACTION); + intent.putExtra("seq", mDelayedShowingSequence); + PendingIntent sender = PendingIntent.getBroadcast(mContext, + 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); + mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, when, + sender); + if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = " + + mDelayedShowingSequence); + } } else if (why == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR) { // Do not enable the keyguard if the prox sensor forced the screen off. } else { |