Loading core/java/android/provider/Settings.java +8 −0 Original line number Diff line number Diff line Loading @@ -2420,6 +2420,14 @@ public final class Settings { public static final String LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED = "lock_pattern_tactile_feedback_enabled"; /** * This preference allows the device to be locked given time after screen goes off, * subject to current DeviceAdmin policy limits. * @hide */ public static final String LOCK_SCREEN_LOCK_AFTER_TIMEOUT = "lock_screen_lock_after_timeout"; /** * Whether assisted GPS should be enabled or not. * @hide Loading policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java +49 −12 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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()} Loading Loading @@ -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) { Loading Loading @@ -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, Loading Loading @@ -326,7 +332,37 @@ 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; 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, Loading @@ -335,6 +371,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback, 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 { Loading services/java/com/android/server/PowerManagerService.java +2 −1 Original line number Diff line number Diff line Loading @@ -2456,7 +2456,8 @@ class PowerManagerService extends IPowerManager.Stub } mKeylightDelay = LONG_KEYLIGHT_DELAY; if (totalDelay < 0) { mScreenOffDelay = Integer.MAX_VALUE; // negative number means stay on as long as possible. mScreenOffDelay = mMaximumScreenOffTimeout; } else if (mKeylightDelay < totalDelay) { // subtract the time that the keylight delay. This will give us the // remainder of the time that we need to sleep to get the accurate Loading Loading
core/java/android/provider/Settings.java +8 −0 Original line number Diff line number Diff line Loading @@ -2420,6 +2420,14 @@ public final class Settings { public static final String LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED = "lock_pattern_tactile_feedback_enabled"; /** * This preference allows the device to be locked given time after screen goes off, * subject to current DeviceAdmin policy limits. * @hide */ public static final String LOCK_SCREEN_LOCK_AFTER_TIMEOUT = "lock_screen_lock_after_timeout"; /** * Whether assisted GPS should be enabled or not. * @hide Loading
policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java +49 −12 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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()} Loading Loading @@ -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) { Loading Loading @@ -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, Loading Loading @@ -326,7 +332,37 @@ 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; 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, Loading @@ -335,6 +371,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback, 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 { Loading
services/java/com/android/server/PowerManagerService.java +2 −1 Original line number Diff line number Diff line Loading @@ -2456,7 +2456,8 @@ class PowerManagerService extends IPowerManager.Stub } mKeylightDelay = LONG_KEYLIGHT_DELAY; if (totalDelay < 0) { mScreenOffDelay = Integer.MAX_VALUE; // negative number means stay on as long as possible. mScreenOffDelay = mMaximumScreenOffTimeout; } else if (mKeylightDelay < totalDelay) { // subtract the time that the keylight delay. This will give us the // remainder of the time that we need to sleep to get the accurate Loading