update_engine: UpdateAttempter manages lifetime of Excluder
Prior to adding the exclusion logic within various |Action|s, the
|UpdateAttempter| provides a way to access the |Excluder| encapsulated
within the |UpdateAttempter| singleton.
|PayloadState| uses |Excluder| from |UpdateAttempter| as a member.
BUG=chromium:928805
TEST=FEATURES=test emerge-$B update_engine
TEST=USE="${USE} -dlc" FEATURES=test emerge-$B update_engine
Change-Id: I63ace436e8aacd349e13004fe1e2f4dd37479978
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2190236
Tested-by: Jae Hoon Kim <[email protected]>
Reviewed-by: Amin Hassani <[email protected]>
Commit-Queue: Jae Hoon Kim <[email protected]>
Auto-Submit: Jae Hoon Kim <[email protected]>
diff --git a/mock_update_attempter.h b/mock_update_attempter.h
index fdeba52..ad34802 100644
--- a/mock_update_attempter.h
+++ b/mock_update_attempter.h
@@ -60,6 +60,8 @@
MOCK_METHOD2(SetDlcActiveValue, bool(bool, const std::string&));
+ MOCK_CONST_METHOD0(GetExcluder, ExcluderInterface*(void));
+
MOCK_METHOD0(RefreshDevicePolicy, void(void));
MOCK_CONST_METHOD0(consecutive_failed_update_checks, unsigned int(void));
diff --git a/payload_state.cc b/payload_state.cc
index 5facdff..2e07ad9 100644
--- a/payload_state.cc
+++ b/payload_state.cc
@@ -37,6 +37,7 @@
#include "update_engine/omaha_request_params.h"
#include "update_engine/payload_consumer/install_plan.h"
#include "update_engine/system_state.h"
+#include "update_engine/update_attempter.h"
using base::Time;
using base::TimeDelta;
@@ -60,6 +61,8 @@
PayloadState::PayloadState()
: prefs_(nullptr),
+ powerwash_safe_prefs_(nullptr),
+ excluder_(nullptr),
using_p2p_for_downloading_(false),
p2p_num_attempts_(0),
payload_attempt_number_(0),
@@ -79,6 +82,7 @@
system_state_ = system_state;
prefs_ = system_state_->prefs();
powerwash_safe_prefs_ = system_state_->powerwash_safe_prefs();
+ excluder_ = system_state_->update_attempter()->GetExcluder();
LoadResponseSignature();
LoadPayloadAttemptNumber();
LoadFullPayloadAttemptNumber();
diff --git a/payload_state.h b/payload_state.h
index bfe2cf0..bc4bf0d 100644
--- a/payload_state.h
+++ b/payload_state.h
@@ -24,6 +24,7 @@
#include <base/time/time.h>
#include <gtest/gtest_prod.h> // for FRIEND_TEST
+#include "update_engine/common/excluder_interface.h"
#include "update_engine/common/prefs_interface.h"
#include "update_engine/metrics_constants.h"
#include "update_engine/payload_state_interface.h"
@@ -429,6 +430,11 @@
// This object persists across powerwashes.
PrefsInterface* powerwash_safe_prefs_;
+ // Interface object with which we determine exclusion decisions for
+ // payloads/partitions during the update. This must be set by calling the
+ // Initialize method before calling any other method.
+ ExcluderInterface* excluder_;
+
// This is the current response object from Omaha.
OmahaResponse response_;
diff --git a/update_attempter.cc b/update_attempter.cc
index 7479134..5256192 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -47,6 +47,7 @@
#include "update_engine/common/clock_interface.h"
#include "update_engine/common/constants.h"
#include "update_engine/common/dlcservice_interface.h"
+#include "update_engine/common/excluder_interface.h"
#include "update_engine/common/hardware_interface.h"
#include "update_engine/common/platform_constants.h"
#include "update_engine/common/prefs.h"
@@ -1762,6 +1763,8 @@
system_state_->payload_state()->UpdateEngineStarted();
StartP2PAtStartup();
+
+ excluder_ = CreateExcluder(system_state_->prefs());
}
bool UpdateAttempter::StartP2PAtStartup() {
diff --git a/update_attempter.h b/update_attempter.h
index 1bf552b..dd958f5 100644
--- a/update_attempter.h
+++ b/update_attempter.h
@@ -37,6 +37,7 @@
#include "update_engine/client_library/include/update_engine/update_status.h"
#include "update_engine/common/action_processor.h"
#include "update_engine/common/cpu_limiter.h"
+#include "update_engine/common/excluder_interface.h"
#include "update_engine/common/proxy_resolver.h"
#include "update_engine/omaha_request_builder_xml.h"
#include "update_engine/omaha_request_params.h"
@@ -184,6 +185,9 @@
// Called at update_engine startup to do various house-keeping.
void UpdateEngineStarted();
+ // Returns the |Excluder| that is currently held onto.
+ virtual ExcluderInterface* GetExcluder() const { return excluder_.get(); }
+
// Reloads the device policy from libbrillo. Note: This method doesn't
// cause a real-time policy fetch from the policy server. It just reloads the
// latest value that libbrillo has cached. libbrillo fetches the policies
@@ -571,6 +575,9 @@
// This is the session ID used to track update flow to Omaha.
std::string session_id_;
+ // Interface for excluder.
+ std::unique_ptr<ExcluderInterface> excluder_;
+
DISALLOW_COPY_AND_ASSIGN(UpdateAttempter);
};