Skip writing empty SPL string into update manifest
If field is empty, no need to waste space storing it in protobuf.
Test: generate OTA, make sure SPL field is unset
Bug: 244525514
Change-Id: I43630efaf7c082541af786657110c345c4f6ee17
diff --git a/payload_generator/payload_file.cc b/payload_generator/payload_file.cc
index 0ef747a..f404c79 100644
--- a/payload_generator/payload_file.cc
+++ b/payload_generator/payload_file.cc
@@ -66,7 +66,9 @@
manifest_.set_minor_version(config.version.minor);
manifest_.set_block_size(config.block_size);
manifest_.set_max_timestamp(config.max_timestamp);
- manifest_.set_security_patch_level(config.security_patch_level);
+ if (!config.security_patch_level.empty()) {
+ manifest_.set_security_patch_level(config.security_patch_level);
+ }
if (config.target.dynamic_partition_metadata != nullptr)
*(manifest_.mutable_dynamic_partition_metadata()) =
diff --git a/payload_generator/payload_properties_unittest.cc b/payload_generator/payload_properties_unittest.cc
index 0d62681..0ff364f 100644
--- a/payload_generator/payload_properties_unittest.cc
+++ b/payload_generator/payload_properties_unittest.cc
@@ -104,9 +104,9 @@
"{"
R"("is_delta":true,)"
R"("metadata_signature":"",)"
- R"("metadata_size":168,)"
- R"("sha256_hex":"6rXHDjFO8k8mNtIbLhimWOifecVI1Ts230Ia1DyNuPY=",)"
- R"("size":214,)"
+ R"("metadata_size":165,)"
+ R"("sha256_hex":"cV7kfZBH3K0B6QJHxxykDh6b6x0WgVOmc63whPLOy7U=",)"
+ R"("size":211,)"
R"("version":2)"
"}";
string json;
@@ -118,10 +118,10 @@
// Validate the hash of file and metadata are within the output.
TEST_F(PayloadPropertiesTest, GetPropertiesAsKeyValueTestHash) {
constexpr char kKeyValueProperties[] =
- "FILE_HASH=6rXHDjFO8k8mNtIbLhimWOifecVI1Ts230Ia1DyNuPY=\n"
- "FILE_SIZE=214\n"
- "METADATA_HASH=wq2nRZ7o/aqEeVWcc2Z+bebLYEI8quPEnXHlyLtdW9Y=\n"
- "METADATA_SIZE=168\n";
+ "FILE_HASH=cV7kfZBH3K0B6QJHxxykDh6b6x0WgVOmc63whPLOy7U=\n"
+ "FILE_SIZE=211\n"
+ "METADATA_HASH=aEKYyzJt2E8Gz8fzB+gmekN5mriotZCSq6R+kDfdeV4=\n"
+ "METADATA_SIZE=165\n";
string key_value;
EXPECT_TRUE(PayloadProperties{payload_file_.path()}.GetPropertiesAsKeyValue(
&key_value));