Snap for 12680993 from dbff804d2f7aeb9fd2dc1e0cac57284b5e5de784 to 25Q1-release
Change-Id: I442b568a45a9cce79c55812f3ae05f970f5aeff1
diff --git a/payload_consumer/partition_writer_unittest.cc b/payload_consumer/partition_writer_unittest.cc
index 32324b6..ef2690f 100644
--- a/payload_consumer/partition_writer_unittest.cc
+++ b/payload_consumer/partition_writer_unittest.cc
@@ -128,7 +128,7 @@
PartitionWriter writer_{
partition_update_, install_part_, &dynamic_control_, kBlockSize, false};
};
-// Test that the error-corrected file descriptor is used to read a partition
+// Test that the plain file descriptor is used to read a partition
// when no hash is available for SOURCE_COPY but it falls back to the normal
// file descriptor when the size of the error corrected one is too small.
TEST_F(PartitionWriterTest, ErrorCorrectionSourceCopyWhenNoHashFallbackTest) {
@@ -153,13 +153,8 @@
ASSERT_NO_FATAL_FAILURE();
ASSERT_EQ(output_data, expected_data);
- // Verify that the fake_fec was attempted to be used. Since the file
- // descriptor is shorter it can actually do more than one read to realize it
- // reached the EOF.
- ASSERT_LE(1U, fake_fec->GetReadOps().size());
- // This fallback doesn't count as an error-corrected operation since the
- // operation hash was not available.
- ASSERT_EQ(0U, GetSourceEccRecoveredFailures());
+ // Verify that the fake_fec was not used
+ ASSERT_LE(0U, fake_fec->GetReadOps().size());
}
// Test that the error-corrected file descriptor is used to read the partition
diff --git a/payload_consumer/verified_source_fd.cc b/payload_consumer/verified_source_fd.cc
index addf534..131f2fb 100644
--- a/payload_consumer/verified_source_fd.cc
+++ b/payload_consumer/verified_source_fd.cc
@@ -19,7 +19,6 @@
#include <sys/stat.h>
#include <memory>
-#include <utility>
#include <vector>
#include <base/strings/string_number_conversions.h>
@@ -90,6 +89,16 @@
*error = ErrorCode::kSuccess;
}
if (!operation.has_src_sha256_hash()) {
+ if (operation.type() == InstallOperation::SOURCE_COPY) {
+ // delta_generator always adds SHA256 hash for source data. If hash is
+ // missing, the only possibility is we are doing a partial update, and
+ // currently processing a partition that's not in the payload. Data on
+ // this partition would be copied to the new slot as is. So, if the
+ // current partition boots fine(either no corruption, or with FEC), the
+ // new partition would boot fine as well. Hence, just return |source_fd_|
+ // to save time.
+ return source_fd_;
+ }
// When the operation doesn't include a source hash, we attempt the error
// corrected device first since we can't verify the block in the raw device
// at this point, but we first need to make sure all extents are readable