PM: Policy for checking whether an update can start.
This policy is based on existing logic found in the following locations
through the current update engine code base:
- UpdateAttempter::CalculateUpdateParams(), which applies various device
policy attributes and sets the update params.
- UpdateAttempter::CalculateScatteringParams(), called by the former for
deciding the scatter wait period for the current update. Calls
UpdateAttempter::GenerateNewWaitingPeriod() to compute a new wait
period.
- OmahaRequestAction::IsWallClockBasedWaitingSatisfied() and
OmahaRequestAction::IsUpdateCheckCountBasedWaitingSatisfied, which
check whether a scattering derived wait period has elapsed and whether
a check threshold counter was satisfied, respectively.
- UpdateAttempter::CalculateP2PParams() and
P2PManagerImpl::IsP2PEnabled(), which decide whether P2P can be used.
- PayloadState::ComputeCandidateUrls(), where there's logic for deciding
whether HTTP downloads are allowed.
Note that this policy request is based on two others. One is the public
UpdateCheckAllowed(), whose positive return value invalidates the
current update attempt. The second is a private policy
UpdateScattering() that decides whether the current update attempt is
subject to scattering.
BUG=chromium:358323
TEST=Unit tests.
Change-Id: I889a3d1c10e1722585fdc1aa87fb6f9d627b60c7
Reviewed-on: https://chromium-review.googlesource.com/198781
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/policy_manager/default_policy.h b/policy_manager/default_policy.h
index e019950..56eedf2 100644
--- a/policy_manager/default_policy.h
+++ b/policy_manager/default_policy.h
@@ -5,6 +5,8 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_DEFAULT_POLICY_H_
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_DEFAULT_POLICY_H_
+#include <base/time/time.h>
+
#include "update_engine/policy_manager/policy.h"
namespace chromeos_policy_manager {
@@ -25,10 +27,20 @@
return EvalStatus::kSucceeded;
}
- virtual EvalStatus UpdateDownloadAndApplyAllowed(
- EvaluationContext* ec, State* state, std::string* error,
- bool* result) const override {
- *result = true;
+ virtual EvalStatus UpdateCanStart(
+ EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ UpdateCanStartResult* result,
+ const bool interactive,
+ const UpdateState& update_state) const override {
+ result->update_can_start = true;
+ result->http_allowed = false;
+ result->p2p_allowed = false;
+ result->target_channel.clear();
+ result->cannot_start_reason = UpdateCannotStartReason::kUndefined;
+ result->scatter_wait_period = base::TimeDelta();
+ result->scatter_check_threshold = 0;
return EvalStatus::kSucceeded;
}