update_engine: Add Update Time Restrictions
Implementation for the update time restrictions policy where the admin
is allowed to choose time interval in which updates will not be checked.
- Adds WeeklyTime and WeeklyTimeInterval classes to update_engine to be
able to easily do interval range checking and time operations easily in
the policy. Added the wiring so the classes can be used as Values and
BoxedValues.
- Adds disallowed_intervals member to device_policy_provider, since this
contains the policy dictated disallowed intervals. The intervals are
obtained from libpolicy, a function was added to convert them to the
new WeeklyTime classes. Added the corresponding changes to the device
policy provider header and interface.
- Added the policy to chromeos_policy.cc so that it's taken into account
in UpdateCheckAllowed.
BUG=chromium:852860
TEST=cros_workon_make update_engine --test
Change-Id: If62a2b3650adf149ba87790345e1eb62f0e1bb1f
Reviewed-on: https://chromium-review.googlesource.com/1119397
Commit-Ready: Adolfo Higueros <adokar@google.com>
Tested-by: Adolfo Higueros <adokar@google.com>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
diff --git a/update_manager/boxed_value.cc b/update_manager/boxed_value.cc
index b2505ee..971e9b7 100644
--- a/update_manager/boxed_value.cc
+++ b/update_manager/boxed_value.cc
@@ -29,6 +29,7 @@
#include "update_engine/update_manager/rollback_prefs.h"
#include "update_engine/update_manager/shill_provider.h"
#include "update_engine/update_manager/updater_provider.h"
+#include "update_engine/update_manager/weekly_time.h"
using chromeos_update_engine::ConnectionTethering;
using chromeos_update_engine::ConnectionType;
@@ -211,4 +212,23 @@
return retval;
}
+template <>
+string BoxedValue::ValuePrinter<WeeklyTimeInterval>(const void* value) {
+ const WeeklyTimeInterval* val =
+ reinterpret_cast<const WeeklyTimeInterval*>(value);
+ return val->ToString();
+}
+
+template <>
+string BoxedValue::ValuePrinter<WeeklyTimeIntervalVector>(const void* value) {
+ const WeeklyTimeIntervalVector* val =
+ reinterpret_cast<const WeeklyTimeIntervalVector*>(value);
+
+ string retval = "Disallowed intervals:\n";
+ for (const auto& interval : *val) {
+ retval += interval.ToString() + "\n";
+ }
+ return retval;
+}
+
} // namespace chromeos_update_manager