Introduce PayloadVersion struct for version information.
This new little struct encapsulates the version information (major and
minor version numbers) and the zlib fingerprint information. Now,
instead of querying throughout if the version number is certain value,
we ask the PayloadVersion struct whether certain operation is allowed in
that version or not. This moves the logic of what's supported and
what's not to a single place and eliminates the need to pass several
booleans to the helper functions.
Bug: 24578399
TEST=Unittest still pass.
(cherry picked from commit a4073ef63482fd08c3678982f7d153360b088094)
Change-Id: I756d0c2cc217d23df1822f961bb7d82f64974fa9
diff --git a/payload_generator/payload_file.cc b/payload_generator/payload_file.cc
index d268ab8..de81a39 100644
--- a/payload_generator/payload_file.cc
+++ b/payload_generator/payload_file.cc
@@ -59,10 +59,9 @@
} // namespace
bool PayloadFile::Init(const PayloadGenerationConfig& config) {
- major_version_ = config.major_version;
- TEST_AND_RETURN_FALSE(major_version_ == kChromeOSMajorPayloadVersion ||
- major_version_ == kBrilloMajorPayloadVersion);
- manifest_.set_minor_version(config.minor_version);
+ TEST_AND_RETURN_FALSE(config.version.Validate());
+ major_version_ = config.version.major;
+ manifest_.set_minor_version(config.version.minor);
if (!config.source.ImageInfoIsEmpty())
*(manifest_.mutable_old_image_info()) = config.source.image_info;
@@ -288,7 +287,7 @@
ScopedFileWriterCloser writer_closer(&writer);
uint64_t out_file_size = 0;
- for (auto& part: part_vec_) {
+ for (auto& part : part_vec_) {
for (AnnotatedOperation& aop : part.aops) {
if (!aop.op.has_data_offset())
continue;