power: Add wake lock based logic to re-suspend after dark resume
This is a rework of https://crrev.com/c/1302866 monitoring all wake
locks rather than just ARC++ wake locks.
This change adds functionality to support lock screen notifications for
ARC++, Assistant on Chrome OS and other future clients. It adds a new
module that listens to dark resume events from the power manager. It -
1. Starts a timer to check for any current app suspension wake locks.
2. After the timer in 1 expires, if no app suspension wake lock is
acquired the power manager is requested to re-suspend the system. If an
app suspension wake lock is acquired then another hard timeout timer is
set and also an observer to the wake lock being released is set.
3. If the wake lock is released, the system is re-suspended immediately.
4. If the hard timeout in 2 expires and a wake lock is still acquired
then the system is re-suspended immediately.
5. If the system transitions to a full resume all dark resume related
state and timers are cleared.
On top of this change -
1. Changes were added to fix linker errors by declaring static constants
in the source file as well.
2. Refactored some functions in the test code.
BUG=chromium:898297
TEST=Unit tests and end to end test with Android applications and
Assistant.
Change-Id: I695a7dc666b26fce00f6b0f5d0d2017f6556f83a
Reviewed-on: https://chromium-review.googlesource.com/c/1372477
Commit-Queue: Abhishek Bhardwaj <[email protected]>
Reviewed-by: Ken Rockot <[email protected]>
Reviewed-by: Dan Erat <[email protected]>
Cr-Commit-Position: refs/heads/master@{#635849}
diff --git a/chromeos/BUILD.gn b/chromeos/BUILD.gn
index 5e09fb6..7279b61 100644
--- a/chromeos/BUILD.gn
+++ b/chromeos/BUILD.gn
@@ -33,9 +33,12 @@
":chromeos_export",
"//base",
"//base:i18n",
+ "//chromeos/dbus",
"//components/policy/proto",
"//google_apis",
+ "//services/device/public/mojom",
"//services/network/public/cpp:cpp",
+ "//services/service_manager/public/cpp",
"//third_party/protobuf:protobuf_lite",
]
sources = [
@@ -75,6 +78,8 @@
"process_proxy/process_proxy_registry.h",
"system/cpu_temperature_reader.cc",
"system/cpu_temperature_reader.h",
+ "system/dark_resume_controller.cc",
+ "system/dark_resume_controller.h",
"system/devicemode.cc",
"system/devicemode.h",
"system/factory_ping_embargo_check.cc",
@@ -206,8 +211,11 @@
"//mojo/core/embedder",
"//net",
"//net:test_support",
+ "//services/device/public/cpp/test:test_support",
+ "//services/device/public/mojom",
"//services/network:test_support",
"//services/network/public/cpp",
+ "//services/service_manager/public/cpp/test:test_support",
"//testing/gmock",
"//testing/gtest",
"//third_party/icu",
@@ -228,6 +236,7 @@
"process_proxy/process_output_watcher_unittest.cc",
"process_proxy/process_proxy_unittest.cc",
"system/cpu_temperature_reader_unittest.cc",
+ "system/dark_resume_controller_unittest.cc",
"system/factory_ping_embargo_check_unittest.cc",
"system/name_value_pairs_parser_unittest.cc",
"test/run_all_unittests.cc",