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

Unified Diff: powerd.cc

Issue 6733005: Backlight off should not transition to dim or off states (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/power_manager.git
Patch Set: Created 9 years, 9 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 | « backlight_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: powerd.cc
diff --git a/powerd.cc b/powerd.cc
index ac41c809c539f92050ae0f3090333670dd6f2bb8..a25dc095192164b47ee26dbac525b2b32d09f393 100644
--- a/powerd.cc
+++ b/powerd.cc
@@ -334,33 +334,39 @@ void Daemon::OnIdleEvent(bool is_idle, int64 idle_time_ms) {
void Daemon::SetIdleState(int64 idle_time_ms) {
bool changed_brightness = false;
if (idle_time_ms >= suspend_ms_) {
- LOG(INFO) << "state = kIdleSuspend";
// Note: currently this state doesn't do anything. But it can be possibly
// useful in future development. For example, if we want to implement fade
// from suspend, we would want to have this state to make sure the backlight
// is set to zero when suspended.
- changed_brightness =
- backlight_controller_->SetPowerState(BACKLIGHT_SUSPENDED);
- idle_state_ = kIdleSuspend;
- Suspend();
+ if (backlight_controller_->SetPowerState(BACKLIGHT_SUSPENDED)) {
+ idle_state_ = kIdleSuspend;
+ LOG(INFO) << "state = kIdleSuspend";
+ changed_brightness = true;
+ Suspend();
+ }
} else if (idle_time_ms >= off_ms_) {
- LOG(INFO) << "state = kIdleScreenOff";
- changed_brightness =
- backlight_controller_->SetPowerState(BACKLIGHT_IDLE_OFF);
- idle_state_ = kIdleScreenOff;
+ if (backlight_controller_->SetPowerState(BACKLIGHT_IDLE_OFF)) {
+ idle_state_ = kIdleScreenOff;
+ LOG(INFO) << "state = kIdleScreenOff";
+ changed_brightness = true;
+ }
} else if (idle_time_ms >= dim_ms_) {
- LOG(INFO) << "state = kIdleDim";
- changed_brightness = backlight_controller_->SetPowerState(BACKLIGHT_DIM);
- idle_state_ = kIdleDim;
+ if (backlight_controller_->SetPowerState(BACKLIGHT_DIM)) {
+ idle_state_ = kIdleDim;
+ LOG(INFO) << "state = kIdleDim";
+ changed_brightness = true;
+ }
} else if (idle_state_ != kIdleNormal) {
- LOG(INFO) << "state = kIdleNormal";
- changed_brightness =
- backlight_controller_->SetPowerState(BACKLIGHT_ACTIVE_ON);
- if (idle_state_ == kIdleSuspend) {
- util::CreateStatusFile(FilePath(run_dir_).Append(util::kUserActiveFile));
- suspender_.CancelSuspend();
+ if (backlight_controller_->SetPowerState(BACKLIGHT_ACTIVE_ON)) {
+ if (idle_state_ == kIdleSuspend) {
+ util::CreateStatusFile(FilePath(run_dir_)
+ .Append(util::kUserActiveFile));
+ suspender_.CancelSuspend();
+ }
+ idle_state_ = kIdleNormal;
+ LOG(INFO) << "state = kIdleNormal";
+ changed_brightness = true;
}
- idle_state_ = kIdleNormal;
}
if (idle_time_ms >= lock_ms_ && util::LoggedIn() &&
idle_state_ != kIdleSuspend) {
« no previous file with comments | « backlight_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698