update_engine: Add restricted intervals monitor
This CL introduces class UpdateTimeRestrictionsMonitor responsible
for tracking the restricted time intervals from
DeviceAutoUpdateTimeRestrictions policy during which update
download is not allowed.
It reads the policy, chooses the next interval according to
current time and notifies the delegate when it starts.
UpdateTimeRestrictionsMonitor is also able to detect and handle
changes in restricted intervals during its lifetime.
This monitor would be used in a follow up CL to cancel the
download process during a restricted interval.
This class would be short lived with its lifetime restricted to during
the DownloadAction so that it can notify the delegate when restricted
interval starts which would then cancel the update process.
Resuming the update process when interval ends would be handled by the
next auto update after interval end as update engine checkpoints the
download progress.
BUG=chromium:1117450
TEST=FEATURES=test emerge-${BOARD} update_engine
Change-Id: Ia7190a488efecf1de53c6396ff67a2b7ef10aa57
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2560619
Tested-by: Saurabh Nijhara <snijhara@google.com>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Jae Hoon Kim <kimjae@chromium.org>
Commit-Queue: Saurabh Nijhara <snijhara@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 6c99a60..582e515 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -236,6 +236,7 @@
"update_manager/staging_utils.cc",
"update_manager/state_factory.cc",
"update_manager/update_manager.cc",
+ "update_manager/update_time_restrictions_monitor.cc",
"update_manager/update_time_restrictions_policy_impl.cc",
"update_manager/weekly_time.cc",
"update_status_utils.cc",
@@ -537,6 +538,7 @@
"update_manager/real_updater_provider_unittest.cc",
"update_manager/staging_utils_unittest.cc",
"update_manager/update_manager_unittest.cc",
+ "update_manager/update_time_restrictions_monitor_unittest.cc",
"update_manager/update_time_restrictions_policy_impl_unittest.cc",
"update_manager/variable_unittest.cc",
"update_manager/weekly_time_unittest.cc",