Simplify logic for PerformSourceCopyOperation
PartitionWriter::PerformSourceCopyOperation has the following logic:
1. If source hash matches data on device, use regular fd
2. If source hash mismatches but we can recover using FEC, use FEC fd
3. Otherwise, fail the OTA
All of the above logic is already handled in ChooseSourceFD, no need to
duplicate them in PerformSourceCopyOperation.
This CL introduces a slight change in behavior:
old behavior:
When we detect a source hash mismatch, still finish writing current op,
then fail.
new behavior:
when we detect a source hash mismatch, fail the OTA immediately and
don't write anything.
Test: th
Change-Id: Ib9526a5383219fabdae163a6384679f67b50d8c2
diff --git a/payload_consumer/partition_writer_unittest.cc b/payload_consumer/partition_writer_unittest.cc
index 263f338..564d8d4 100644
--- a/payload_consumer/partition_writer_unittest.cc
+++ b/payload_consumer/partition_writer_unittest.cc
@@ -167,7 +167,7 @@
ASSERT_EQ(output_data, expected_data);
// Verify that the fake_fec was actually used.
- EXPECT_EQ(1U, fake_fec->GetReadOps().size());
+ EXPECT_GE(fake_fec->GetReadOps().size(), 1U);
EXPECT_EQ(1U, GetSourceEccRecoveredFailures());
}