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

Unified Diff: powerman.cc

Issue 6712052: Allow the lid to be ignored using the use_lid pref (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/power_manager.git@master
Patch Set: Add default use_lid to config directory 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 | « power_constants.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: powerman.cc
diff --git a/powerman.cc b/powerman.cc
index c9fb3436ffd221fcde73eb92c227fa6a33930cac..b19f57b5dbd1a1f14a78142c96988348c13144ec 100644
--- a/powerman.cc
+++ b/powerman.cc
@@ -32,6 +32,7 @@ PowerManDaemon::PowerManDaemon(PowerPrefs* prefs,
MetricsLibraryInterface* metrics_lib,
const FilePath& run_dir)
: loop_(NULL),
+ use_input_for_lid_(1),
prefs_(prefs),
lidstate_(kLidOpened),
metrics_lib_(metrics_lib),
@@ -52,13 +53,16 @@ PowerManDaemon::~PowerManDaemon() {
void PowerManDaemon::Init() {
int input_lidstate = 0;
+ int64 use_input_for_lid;
CHECK(prefs_->GetInt64(kRetrySuspendMs, &retry_suspend_ms_));
CHECK(prefs_->GetInt64(kRetrySuspendAttempts, &retry_suspend_attempts_));
+ CHECK(prefs_->GetInt64(kUseLid, &use_input_for_lid));
// Retrys will occur no more than once a minute.
CHECK_GE(retry_suspend_ms_, 60000);
// Only 1-10 retries prior to just shutting down.
CHECK_GT(retry_suspend_attempts_, 0);
CHECK_LE(retry_suspend_attempts_, 10);
+ use_input_for_lid_ = 1 == use_input_for_lid;
loop_ = g_main_loop_new(NULL, false);
// Acquire a handle to the console for VT switch locking ioctl.
CHECK(GetConsole());
@@ -129,6 +133,10 @@ void PowerManDaemon::OnInputEvent(void* object, InputType type, int value) {
<< (daemon->powerd_state_ == kPowerManagerDead?
"dead":(daemon->powerd_state_ == kPowerManagerAlive?
"alive":"unknown"));
+ if (!daemon->use_input_for_lid_) {
+ LOG(INFO) << "Ignoring lid.";
+ break;
+ }
if (daemon->lidstate_ == kLidClosed) {
if (daemon->powerd_state_ != kPowerManagerAlive) {
// powerd is not alive so act on its behalf.
« no previous file with comments | « power_constants.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698