| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "power_manager/powerd.h" | 5 #include "power_manager/powerd.h" |
| 6 | 6 |
| 7 #include <gdk/gdkx.h> | 7 #include <gdk/gdkx.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <X11/extensions/dpms.h> | 9 #include <X11/extensions/dpms.h> |
| 10 #include <X11/keysym.h> | 10 #include <X11/keysym.h> |
| 11 #include <X11/XF86keysym.h> | 11 #include <X11/XF86keysym.h> |
| 12 #include <sys/inotify.h> | 12 #include <sys/inotify.h> |
| 13 | 13 |
| 14 #include <algorithm> | 14 #include <algorithm> |
| 15 #include <string> | 15 #include <string> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "base/file_util.h" | 18 #include "base/file_util.h" |
| 19 #include "base/logging.h" | 19 #include "base/logging.h" |
| 20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 21 #include "chromeos/dbus/dbus.h" | 21 #include "chromeos/dbus/dbus.h" |
| 22 #include "chromeos/dbus/service_constants.h" | 22 #include "chromeos/dbus/service_constants.h" |
| 23 #include "cros/chromeos_wm_ipc_enums.h" | 23 #include "cros/chromeos_wm_ipc_enums.h" |
| 24 #include "power_manager/monitor_reconfigure.h" |
| 24 #include "power_manager/power_button_handler.h" | 25 #include "power_manager/power_button_handler.h" |
| 25 #include "power_manager/power_constants.h" | 26 #include "power_manager/power_constants.h" |
| 26 #include "power_manager/util.h" | 27 #include "power_manager/util.h" |
| 27 | 28 |
| 28 using std::max; | 29 using std::max; |
| 29 using std::min; | 30 using std::min; |
| 30 using std::string; | 31 using std::string; |
| 31 using std::vector; | 32 using std::vector; |
| 32 | 33 |
| 33 namespace power_manager { | 34 namespace power_manager { |
| 34 | 35 |
| 35 // The minimum delta between timers to avoid timer precision issues | 36 // The minimum delta between timers to avoid timer precision issues |
| 36 static const int64 kFuzzMS = 100; | 37 static const int64 kFuzzMS = 100; |
| 37 | 38 |
| 38 // The minimum delta between timers when we want to give a user time to react | 39 // The minimum delta between timers when we want to give a user time to react |
| 39 static const int64 kReactMS = 30000; | 40 static const int64 kReactMS = 30000; |
| 40 | 41 |
| 41 static const char kTaggedFilePath[] = "/var/lib/power_manager"; | 42 static const char kTaggedFilePath[] = "/var/lib/power_manager"; |
| 42 | 43 |
| 43 // Daemon: Main power manager. Adjusts device status based on whether the | 44 // Daemon: Main power manager. Adjusts device status based on whether the |
| 44 // user is idle and on video activity indicator from the window manager. | 45 // user is idle and on video activity indicator from the window manager. |
| 45 // This daemon is responsible for dimming of the backlight, turning | 46 // This daemon is responsible for dimming of the backlight, turning |
| 46 // the screen off, and suspending to RAM. The daemon also has the | 47 // the screen off, and suspending to RAM. The daemon also has the |
| 47 // capability of shutting the system down. | 48 // capability of shutting the system down. |
| 48 | 49 |
| 49 Daemon::Daemon(BacklightController* backlight_controller, | 50 Daemon::Daemon(BacklightController* backlight_controller, |
| 50 PowerPrefs* prefs, | 51 PowerPrefs* prefs, |
| 51 MetricsLibraryInterface* metrics_lib, | 52 MetricsLibraryInterface* metrics_lib, |
| 52 VideoDetectorInterface* video_detector, | 53 VideoDetectorInterface* video_detector, |
| 54 MonitorReconfigureMain* monitor_reconfigure, |
| 53 const FilePath& run_dir) | 55 const FilePath& run_dir) |
| 54 : backlight_controller_(backlight_controller), | 56 : backlight_controller_(backlight_controller), |
| 55 prefs_(prefs), | 57 prefs_(prefs), |
| 56 metrics_lib_(metrics_lib), | 58 metrics_lib_(metrics_lib), |
| 57 video_detector_(video_detector), | 59 video_detector_(video_detector), |
| 60 monitor_reconfigure_(monitor_reconfigure), |
| 58 low_battery_suspend_percent_(0), | 61 low_battery_suspend_percent_(0), |
| 59 clean_shutdown_initiated_(false), | 62 clean_shutdown_initiated_(false), |
| 60 low_battery_(false), | 63 low_battery_(false), |
| 61 enforce_lock_(false), | 64 enforce_lock_(false), |
| 62 use_xscreensaver_(false), | 65 use_xscreensaver_(false), |
| 63 plugged_state_(kPowerUnknown), | 66 plugged_state_(kPowerUnknown), |
| 64 idle_state_(kIdleUnknown), | 67 idle_state_(kIdleUnknown), |
| 65 file_tagger_(FilePath(kTaggedFilePath)), | 68 file_tagger_(FilePath(kTaggedFilePath)), |
| 66 shutdown_state_(kShutdownNone), | 69 shutdown_state_(kShutdownNone), |
| 67 suspender_(&locker_, &file_tagger_), | 70 suspender_(&locker_, &file_tagger_), |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 dbus_message_append_args(signal, | 699 dbus_message_append_args(signal, |
| 697 DBUS_TYPE_INT32, &brightness, | 700 DBUS_TYPE_INT32, &brightness, |
| 698 DBUS_TYPE_BOOLEAN, &user_initiated_int, | 701 DBUS_TYPE_BOOLEAN, &user_initiated_int, |
| 699 DBUS_TYPE_INVALID); | 702 DBUS_TYPE_INVALID); |
| 700 dbus_g_proxy_send(proxy.gproxy(), signal, NULL); | 703 dbus_g_proxy_send(proxy.gproxy(), signal, NULL); |
| 701 dbus_message_unref(signal); | 704 dbus_message_unref(signal); |
| 702 } | 705 } |
| 703 | 706 |
| 704 void Daemon::HandleResume() { | 707 void Daemon::HandleResume() { |
| 705 file_tagger_.HandleResumeEvent(); | 708 file_tagger_.HandleResumeEvent(); |
| 706 backlight_controller_->SetPowerState(BACKLIGHT_ACTIVE_ON); | 709 // Monitor reconfigure will set the backlight if needed. |
| 710 monitor_reconfigure_->Run(); |
| 707 } | 711 } |
| 708 | 712 |
| 709 } // namespace power_manager | 713 } // namespace power_manager |
| OLD | NEW |