Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Unified Diff: chromeos/dbus/power_policy_controller.cc

Issue 16346004: Merge 203774 "chromeos: Add delay between screen off and lock." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1500/src/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/dbus/power_policy_controller.h ('k') | chromeos/dbus/power_policy_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/power_policy_controller.cc
===================================================================
--- chromeos/dbus/power_policy_controller.cc (revision 204009)
+++ chromeos/dbus/power_policy_controller.cc (working copy)
@@ -58,6 +58,8 @@
} // namespace
+const int PowerPolicyController::kScreenLockAfterOffDelayMs = 10000; // 10 sec.
+
// -1 is interpreted as "unset" by powerd, resulting in powerd's default
// delays being used instead. There are no similarly-interpreted values
// for the other fields, unfortunately (but the constructor-assigned values
@@ -147,13 +149,13 @@
delays->set_idle_warning_ms(values.ac_idle_warning_delay_ms);
delays->set_idle_ms(values.ac_idle_delay_ms);
- // If screen-locking is enabled, ensure that the screen is locked when
- // it's turned off due to user inactivity.
+ // If screen-locking is enabled, ensure that the screen is locked soon
+ // after it's turned off due to user inactivity.
+ int64 lock_ms = delays->screen_off_ms() + kScreenLockAfterOffDelayMs;
if (values.enable_screen_lock && delays->screen_off_ms() > 0 &&
- (delays->screen_lock_ms() <= 0 ||
- delays->screen_off_ms() < delays->screen_lock_ms())) {
- delays->set_screen_lock_ms(delays->screen_off_ms());
- }
+ (delays->screen_lock_ms() <= 0 || lock_ms < delays->screen_lock_ms()) &&
+ lock_ms < delays->idle_ms())
+ delays->set_screen_lock_ms(lock_ms);
delays = prefs_policy_.mutable_battery_delays();
delays->set_screen_dim_ms(values.battery_screen_dim_delay_ms);
@@ -161,11 +163,12 @@
delays->set_screen_lock_ms(values.battery_screen_lock_delay_ms);
delays->set_idle_warning_ms(values.battery_idle_warning_delay_ms);
delays->set_idle_ms(values.battery_idle_delay_ms);
+
+ lock_ms = delays->screen_off_ms() + kScreenLockAfterOffDelayMs;
if (values.enable_screen_lock && delays->screen_off_ms() > 0 &&
- (delays->screen_lock_ms() <= 0 ||
- delays->screen_off_ms() < delays->screen_lock_ms())) {
- delays->set_screen_lock_ms(delays->screen_off_ms());
- }
+ (delays->screen_lock_ms() <= 0 || lock_ms < delays->screen_lock_ms()) &&
+ lock_ms < delays->idle_ms())
+ delays->set_screen_lock_ms(lock_ms);
prefs_policy_.set_idle_action(GetProtoAction(values.idle_action));
prefs_policy_.set_lid_closed_action(GetProtoAction(values.lid_closed_action));
@@ -223,8 +226,10 @@
if (honor_screen_wake_locks_ && !screen_wake_locks_.empty()) {
policy.mutable_ac_delays()->set_screen_dim_ms(0);
policy.mutable_ac_delays()->set_screen_off_ms(0);
+ policy.mutable_ac_delays()->set_screen_lock_ms(0);
policy.mutable_battery_delays()->set_screen_dim_ms(0);
policy.mutable_battery_delays()->set_screen_off_ms(0);
+ policy.mutable_battery_delays()->set_screen_lock_ms(0);
}
if ((!screen_wake_locks_.empty() || !system_wake_locks_.empty()) &&
« no previous file with comments | « chromeos/dbus/power_policy_controller.h ('k') | chromeos/dbus/power_policy_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698