summaryrefslogtreecommitdiffstats
path: root/policy/src/com/android
diff options
context:
space:
mode:
authorJim Miller <jaggies@google.com>2012-01-06 18:24:04 -0800
committerJim Miller <jaggies@google.com>2012-01-09 17:30:58 -0800
commita4edd151c5266a2c794c95444fed67d19740cee3 (patch)
tree7008761867bb578a39fc24a23c20dc9b27471ee0 /policy/src/com/android
parent12d9954d198d29da1a15ba2c6947ce91839cbb83 (diff)
downloadframeworks_base-a4edd151c5266a2c794c95444fed67d19740cee3.zip
frameworks_base-a4edd151c5266a2c794c95444fed67d19740cee3.tar.gz
frameworks_base-a4edd151c5266a2c794c95444fed67d19740cee3.tar.bz2
Fix 4560303: Add setting to lock later when power button pressed
This adds a feature to delay locking the device when the power button is pressed. This fixes a use case where the user wants to turn off the display (e.g. to save power) but doesn't want to lock the device. For the case of a secure device (user has a pin/password/pattern), this will lock the device immediately or not based on the setting. For the non-secure case, this always "locks" the device to provide easy access to the camera while preventing unwanted input. Change-Id: Ie328485c3f7559e26896d761cbf0e69d3f4df4e2
Diffstat (limited to 'policy/src/com/android')
-rw-r--r--policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java15
1 files changed, 11 insertions, 4 deletions
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);
}