PolicyManager: UpdateCheckAllowed policy initial implementation.
This patch implements the UpdateCheckAllowed policy for ChromeOS
using the same logic we had on update_check_scheduler.cc. It checks
for updates onces every 45 minutes and does an exponential backoff
up to 4 hours when the update check fails. Some other parts of the
policy are not implemented, such as retry an update check with a
short delay on certain failures.
BUG=chromium:358269
TEST=Unittests added to the policy.
Change-Id: Ief8deff47fd6490bd70a22ba20abed05fcc37ab4
Reviewed-on: https://chromium-review.googlesource.com/197595
Reviewed-by: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/policy_manager/policy.h b/policy_manager/policy.h
index 7c7ec0c..334a5bd 100644
--- a/policy_manager/policy.h
+++ b/policy_manager/policy.h
@@ -5,6 +5,8 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_H_
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_H_
+#include <string>
+
#include "update_engine/policy_manager/evaluation_context.h"
#include "update_engine/policy_manager/state.h"
@@ -17,6 +19,15 @@
kAskMeAgainLater,
};
+std::string ToString(EvalStatus status);
+
+// Parameters of an update check. These parameters are determined by the
+// UpdateCheckAllowed policy.
+struct UpdateCheckParams {
+ bool updates_enabled; // Whether the auto-updates are enabled on this build.
+};
+
+
// The Policy class is an interface to the ensemble of policy requests that the
// client can make. A derived class includes the policy implementations of
// these.
@@ -36,9 +47,9 @@
// UpdateCheckAllowed returns whether it is allowed to request an update check
// to Omaha.
- virtual EvalStatus UpdateCheckAllowed(EvaluationContext* ec, State* state,
- std::string* error,
- bool* result) const = 0;
+ virtual EvalStatus UpdateCheckAllowed(
+ EvaluationContext* ec, State* state, std::string* error,
+ UpdateCheckParams* result) const = 0;
// Returns whether an update can be downloaded/applied.
virtual EvalStatus UpdateDownloadAndApplyAllowed(EvaluationContext* ec,