Parse multiple packages from Omaha response.
The multi-payload info are stored in OmahaResponse and InstallPlan, but
we still can only apply the first payload for now.
Bug: 36252799
Test: mma -j
Test: update_engine_unittests
Change-Id: I5ca63944ae9082670d0e67888409374f140d4245
(cherry picked from commit 2aba8a87d4fac245a2e2d238b3159f8eabce630f)
diff --git a/payload_state.h b/payload_state.h
index 46711b6..14f0f50 100644
--- a/payload_state.h
+++ b/payload_state.h
@@ -79,7 +79,9 @@
}
inline std::string GetCurrentUrl() override {
- return candidate_urls_.size() ? candidate_urls_[url_index_] : "";
+ return candidate_urls_.size() && candidate_urls_[payload_index_].size()
+ ? candidate_urls_[payload_index_][url_index_]
+ : "";
}
inline uint32_t GetUrlFailureCount() override {
@@ -368,7 +370,9 @@
void ResetRollbackVersion();
inline uint32_t GetUrlIndex() {
- return url_index_;
+ return url_index_ ? std::min(candidate_urls_[payload_index_].size() - 1,
+ url_index_)
+ : 0;
}
// Computes the list of candidate URLs from the total list of payload URLs in
@@ -420,6 +424,9 @@
// Loads the persisted scattering wallclock-based wait period.
void LoadScatteringWaitPeriod();
+ // Get the total size of all payloads.
+ int64_t GetPayloadSize();
+
// The global state of the system.
SystemState* system_state_;
@@ -468,12 +475,15 @@
// we resume from the same value in case of a process restart.
int full_payload_attempt_number_;
+ // The index of the current payload.
+ size_t payload_index_ = 0;
+
// The index of the current URL. This type is different from the one in the
// accessor methods because PrefsInterface supports only int64_t but we want
// to provide a stronger abstraction of uint32_t. Each update to this value
// is persisted so we resume from the same value in case of a process
// restart.
- int64_t url_index_;
+ size_t url_index_;
// The count of failures encountered in the current attempt to download using
// the current URL (specified by url_index_). Each update to this value is
@@ -543,7 +553,7 @@
// The ordered list of the subset of payload URL candidates which are
// allowed as per device policy.
- std::vector<std::string> candidate_urls_;
+ std::vector<std::vector<std::string>> candidate_urls_;
// This stores a blacklisted version set as part of rollback. When we rollback
// we store the version of the os from which we are rolling back from in order