summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-28 00:10:19 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-28 00:10:19 +0000
commite67e1c437745744da22f0e545b9953c48c3ffafb (patch)
treeb17a8e2fe02ce9fa863faa8457dc80785a65b960 /chromeos/dbus
parentedfd4932e3740f54b68298c05098b20de40c1de5 (diff)
downloadchromium_src-e67e1c437745744da22f0e545b9953c48c3ffafb.zip
chromium_src-e67e1c437745744da22f0e545b9953c48c3ffafb.tar.gz
chromium_src-e67e1c437745744da22f0e545b9953c48c3ffafb.tar.bz2
chromeos: Send separate idle actions for AC and battery.
This updates Chrome to set both the |ac_idle_action| and |battery_idle_action| fields in PowerManagementPolicy protocol buffers that it sends to powerd. They're currently both set to the same value as there's only one Chrome pref. BUG=254404 Review URL: https://chromiumcodereview.appspot.com/17939002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209033 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus')
-rw-r--r--chromeos/dbus/power_policy_controller.cc29
-rw-r--r--chromeos/dbus/power_policy_controller.h3
-rw-r--r--chromeos/dbus/power_policy_controller_unittest.cc17
3 files changed, 33 insertions, 16 deletions
diff --git a/chromeos/dbus/power_policy_controller.cc b/chromeos/dbus/power_policy_controller.cc
index 9ad9130..5edc5bd 100644
--- a/chromeos/dbus/power_policy_controller.cc
+++ b/chromeos/dbus/power_policy_controller.cc
@@ -76,7 +76,8 @@ PowerPolicyController::PrefValues::PrefValues()
battery_screen_lock_delay_ms(-1),
battery_idle_warning_delay_ms(-1),
battery_idle_delay_ms(-1),
- idle_action(ACTION_SUSPEND),
+ ac_idle_action(ACTION_SUSPEND),
+ battery_idle_action(ACTION_SUSPEND),
lid_closed_action(ACTION_SUSPEND),
use_audio_activity(true),
use_video_activity(true),
@@ -93,8 +94,10 @@ std::string PowerPolicyController::GetPolicyDebugString(
APPEND_DELAYS(str, policy.ac_delays(), "ac");
if (policy.has_battery_delays())
APPEND_DELAYS(str, policy.battery_delays(), "battery");
- if (policy.has_idle_action())
- str += base::StringPrintf("idle=%d ", policy.idle_action());
+ if (policy.has_ac_idle_action())
+ str += base::StringPrintf("ac_idle=%d ", policy.ac_idle_action());
+ if (policy.has_battery_idle_action())
+ str += base::StringPrintf("battery_idle=%d ", policy.battery_idle_action());
if (policy.has_lid_closed_action())
str += base::StringPrintf("lid_closed=%d ", policy.lid_closed_action());
if (policy.has_use_audio_activity())
@@ -170,7 +173,9 @@ void PowerPolicyController::ApplyPrefs(const PrefValues& values) {
lock_ms < delays->idle_ms())
delays->set_screen_lock_ms(lock_ms);
- prefs_policy_.set_idle_action(GetProtoAction(values.idle_action));
+ prefs_policy_.set_ac_idle_action(GetProtoAction(values.ac_idle_action));
+ prefs_policy_.set_battery_idle_action(
+ GetProtoAction(values.battery_idle_action));
prefs_policy_.set_lid_closed_action(GetProtoAction(values.lid_closed_action));
prefs_policy_.set_use_audio_activity(values.use_audio_activity);
prefs_policy_.set_use_video_activity(values.use_video_activity);
@@ -232,11 +237,17 @@ void PowerPolicyController::SendCurrentPolicy() {
policy.mutable_battery_delays()->set_screen_lock_ms(0);
}
- if ((!screen_wake_locks_.empty() || !system_wake_locks_.empty()) &&
- (!policy.has_idle_action() || policy.idle_action() ==
- power_manager::PowerManagementPolicy_Action_SUSPEND)) {
- policy.set_idle_action(
- power_manager::PowerManagementPolicy_Action_DO_NOTHING);
+ if (!screen_wake_locks_.empty() || !system_wake_locks_.empty()) {
+ if (!policy.has_ac_idle_action() || policy.ac_idle_action() ==
+ power_manager::PowerManagementPolicy_Action_SUSPEND) {
+ policy.set_ac_idle_action(
+ power_manager::PowerManagementPolicy_Action_DO_NOTHING);
+ }
+ if (!policy.has_battery_idle_action() || policy.battery_idle_action() ==
+ power_manager::PowerManagementPolicy_Action_SUSPEND) {
+ policy.set_battery_idle_action(
+ power_manager::PowerManagementPolicy_Action_DO_NOTHING);
+ }
}
for (WakeLockMap::const_iterator it = screen_wake_locks_.begin();
diff --git a/chromeos/dbus/power_policy_controller.h b/chromeos/dbus/power_policy_controller.h
index a2735a1..b24aa4a 100644
--- a/chromeos/dbus/power_policy_controller.h
+++ b/chromeos/dbus/power_policy_controller.h
@@ -47,7 +47,8 @@ class CHROMEOS_EXPORT PowerPolicyController
int battery_screen_lock_delay_ms;
int battery_idle_warning_delay_ms;
int battery_idle_delay_ms;
- Action idle_action;
+ Action ac_idle_action;
+ Action battery_idle_action;
Action lid_closed_action;
bool use_audio_activity;
bool use_video_activity;
diff --git a/chromeos/dbus/power_policy_controller_unittest.cc b/chromeos/dbus/power_policy_controller_unittest.cc
index b3b2564..d8f7078 100644
--- a/chromeos/dbus/power_policy_controller_unittest.cc
+++ b/chromeos/dbus/power_policy_controller_unittest.cc
@@ -48,7 +48,8 @@ TEST_F(PowerPolicyControllerTest, Prefs) {
prefs.battery_screen_dim_delay_ms = 300000;
prefs.battery_screen_off_delay_ms = 360000;
prefs.battery_idle_delay_ms = 420000;
- prefs.idle_action = PowerPolicyController::ACTION_SUSPEND;
+ prefs.ac_idle_action = PowerPolicyController::ACTION_SUSPEND;
+ prefs.battery_idle_action = PowerPolicyController::ACTION_STOP_SESSION;
prefs.lid_closed_action = PowerPolicyController::ACTION_SHUT_DOWN;
prefs.use_audio_activity = true;
prefs.use_video_activity = true;
@@ -68,8 +69,10 @@ TEST_F(PowerPolicyControllerTest, Prefs) {
expected_policy.mutable_battery_delays()->set_screen_lock_ms(-1);
expected_policy.mutable_battery_delays()->set_idle_warning_ms(-1);
expected_policy.mutable_battery_delays()->set_idle_ms(420000);
- expected_policy.set_idle_action(
+ expected_policy.set_ac_idle_action(
power_manager::PowerManagementPolicy_Action_SUSPEND);
+ expected_policy.set_battery_idle_action(
+ power_manager::PowerManagementPolicy_Action_STOP_SESSION);
expected_policy.set_lid_closed_action(
power_manager::PowerManagementPolicy_Action_SHUT_DOWN);
expected_policy.set_use_audio_activity(true);
@@ -137,12 +140,12 @@ TEST_F(PowerPolicyControllerTest, Prefs) {
fake_power_client_.get_policy()));
// Set the "allow screen wake locks" pref to false. The system should be
- // prevented from suspending due to user inactivity but the pref-supplied
- // screen-related delays should be left untouched.
+ // prevented from suspending due to user inactivity on AC power but the
+ // pref-supplied screen-related delays should be left untouched.
prefs.allow_screen_wake_locks = false;
policy_controller_->ApplyPrefs(prefs);
policy_controller_->AddScreenWakeLock("Screen");
- expected_policy.set_idle_action(
+ expected_policy.set_ac_idle_action(
power_manager::PowerManagementPolicy_Action_DO_NOTHING);
expected_policy.set_reason("Prefs, Screen");
EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),
@@ -155,7 +158,9 @@ TEST_F(PowerPolicyControllerTest, WakeLocks) {
const int system_id =
policy_controller_->AddSystemWakeLock(kSystemWakeLockReason);
power_manager::PowerManagementPolicy expected_policy;
- expected_policy.set_idle_action(
+ expected_policy.set_ac_idle_action(
+ power_manager::PowerManagementPolicy_Action_DO_NOTHING);
+ expected_policy.set_battery_idle_action(
power_manager::PowerManagementPolicy_Action_DO_NOTHING);
expected_policy.set_reason(kSystemWakeLockReason);
EXPECT_EQ(PowerPolicyController::GetPolicyDebugString(expected_policy),