Permalink
Browse files

Thanks to actngrezy‎ for pointing out the commit I missed.. :)

  • Loading branch information...
1 parent 35d34b6 commit 070b19758a24a7f9e60d7d8b47eb89ec5298d101 Woodyman committed Aug 25, 2011
Showing with 40 additions and 14 deletions.
  1. +40 −14 phone/com/android/internal/policy/impl/KeyguardViewMediator.java
@@ -321,20 +321,25 @@ public void onScreenTurnedOff(int why) {
} else if (mShowing) {
notifyScreenOffLocked();
resetStateLocked();
- } else if (why == WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT) {
- // if the screen turned off because of timeout, 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)
- 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);
+ } else if (why == WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT
+ || why == WindowManagerPolicy.OFF_BECAUSE_OF_USER) {
+ final ContentResolver cr = mContext.getContentResolver();
+
+ // retrieve the correct timeout setting depending on why
+ // the screen went off
+ int timeoutDelay = (why == WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT ?
+ Settings.System.getInt(cr, Settings.System.SCREEN_LOCK_TIMEOUT_DELAY, KEYGUARD_DELAY_MS) :
+ Settings.System.getInt(cr, Settings.System.SCREEN_LOCK_SCREENOFF_DELAY, 0));
+
+ if (DEBUG) Log.d(TAG, "Lock screen timeout delay is " + String.valueOf(timeoutDelay) + "ms");
+
+ // if there is a delay, turn on the screen lock after the delay expires
+ // otherwise turn it on now
+ if (timeoutDelay > 0) {
+ delayedScreenLockOn(timeoutDelay);
+ } else {
+ doKeyguard();
+ }
} else if (why == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR) {
// Do not enable the keyguard if the prox sensor forced the screen off.
} else {
@@ -343,6 +348,27 @@ public void onScreenTurnedOff(int why) {
}
}
+ /**
+ * Handles setting an alarm to enable the screen lock after a delay
+ */
+ private void delayedScreenLockOn(int delay) {
+ final ContentResolver cr = mContext.getContentResolver();
+
+ mShowLockIcon = (Settings.System.getInt(cr, "show_status_bar_lock", 0) == 1);
+ // set an alarm to enable the screen lock 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() + delay;
+ 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);
+ }
+
/**
* Let's us know the screen was turned on.
*/

0 comments on commit 070b197

Please sign in to comment.