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/metrics_constants.h" | 24 #include "power_manager/metrics_constants.h" |
| 25 #include "power_manager/monitor_reconfigure.h" |
25 #include "power_manager/power_button_handler.h" | 26 #include "power_manager/power_button_handler.h" |
26 #include "power_manager/power_constants.h" | 27 #include "power_manager/power_constants.h" |
27 #include "power_manager/util.h" | 28 #include "power_manager/util.h" |
28 | 29 |
29 using std::max; | 30 using std::max; |
30 using std::min; | 31 using std::min; |
31 using std::string; | 32 using std::string; |
32 using std::vector; | 33 using std::vector; |
33 | 34 |
34 namespace power_manager { | 35 namespace power_manager { |
35 | 36 |
36 // The minimum delta between timers to avoid timer precision issues | 37 // The minimum delta between timers to avoid timer precision issues |
37 static const int64 kFuzzMS = 100; | 38 static const int64 kFuzzMS = 100; |
38 | 39 |
39 // The minimum delta between timers when we want to give a user time to react | 40 // The minimum delta between timers when we want to give a user time to react |
40 static const int64 kReactMS = 30000; | 41 static const int64 kReactMS = 30000; |
41 | 42 |
42 static const char kTaggedFilePath[] = "/var/lib/power_manager"; | 43 static const char kTaggedFilePath[] = "/var/lib/power_manager"; |
43 | 44 |
44 // Daemon: Main power manager. Adjusts device status based on whether the | 45 // Daemon: Main power manager. Adjusts device status based on whether the |
45 // user is idle and on video activity indicator from the window manager. | 46 // user is idle and on video activity indicator from the window manager. |
46 // This daemon is responsible for dimming of the backlight, turning | 47 // This daemon is responsible for dimming of the backlight, turning |
47 // the screen off, and suspending to RAM. The daemon also has the | 48 // the screen off, and suspending to RAM. The daemon also has the |
48 // capability of shutting the system down. | 49 // capability of shutting the system down. |
49 | 50 |
50 Daemon::Daemon(BacklightController* backlight_controller, | 51 Daemon::Daemon(BacklightController* backlight_controller, |
51 PowerPrefs* prefs, | 52 PowerPrefs* prefs, |
52 MetricsLibraryInterface* metrics_lib, | 53 MetricsLibraryInterface* metrics_lib, |
53 VideoDetectorInterface* video_detector, | 54 VideoDetectorInterface* video_detector, |
| 55 MonitorReconfigure* monitor_reconfigure, |
54 const FilePath& run_dir) | 56 const FilePath& run_dir) |
55 : backlight_controller_(backlight_controller), | 57 : backlight_controller_(backlight_controller), |
56 prefs_(prefs), | 58 prefs_(prefs), |
57 metrics_lib_(metrics_lib), | 59 metrics_lib_(metrics_lib), |
58 video_detector_(video_detector), | 60 video_detector_(video_detector), |
| 61 monitor_reconfigure_(monitor_reconfigure), |
59 low_battery_suspend_percent_(0), | 62 low_battery_suspend_percent_(0), |
60 clean_shutdown_initiated_(false), | 63 clean_shutdown_initiated_(false), |
61 low_battery_(false), | 64 low_battery_(false), |
62 enforce_lock_(false), | 65 enforce_lock_(false), |
63 use_xscreensaver_(false), | 66 use_xscreensaver_(false), |
64 plugged_state_(kPowerUnknown), | 67 plugged_state_(kPowerUnknown), |
65 idle_state_(kIdleUnknown), | 68 idle_state_(kIdleUnknown), |
66 file_tagger_(FilePath(kTaggedFilePath)), | 69 file_tagger_(FilePath(kTaggedFilePath)), |
67 shutdown_state_(kShutdownNone), | 70 shutdown_state_(kShutdownNone), |
68 suspender_(&locker_, &file_tagger_), | 71 suspender_(&locker_, &file_tagger_), |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 dbus_message_append_args(signal, | 700 dbus_message_append_args(signal, |
698 DBUS_TYPE_INT32, &brightness, | 701 DBUS_TYPE_INT32, &brightness, |
699 DBUS_TYPE_BOOLEAN, &user_initiated_int, | 702 DBUS_TYPE_BOOLEAN, &user_initiated_int, |
700 DBUS_TYPE_INVALID); | 703 DBUS_TYPE_INVALID); |
701 dbus_g_proxy_send(proxy.gproxy(), signal, NULL); | 704 dbus_g_proxy_send(proxy.gproxy(), signal, NULL); |
702 dbus_message_unref(signal); | 705 dbus_message_unref(signal); |
703 } | 706 } |
704 | 707 |
705 void Daemon::HandleResume() { | 708 void Daemon::HandleResume() { |
706 file_tagger_.HandleResumeEvent(); | 709 file_tagger_.HandleResumeEvent(); |
707 backlight_controller_->SetPowerState(BACKLIGHT_ACTIVE_ON); | 710 // Monitor reconfigure will set the backlight if needed. |
| 711 monitor_reconfigure_->Run(); |
708 } | 712 } |
709 | 713 |
710 } // namespace power_manager | 714 } // namespace power_manager |
OLD | NEW |