Make source partitions writable during update am: 8b07db549d
Original change: https://android-review.googlesource.com/c/platform/system/update_engine/+/3191277
Change-Id: I5908d22a299cbd3d41dd54a4d0f8800d892e0c5d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/aosp/dynamic_partition_control_android.cc b/aosp/dynamic_partition_control_android.cc
index e950a2e..af46b35 100644
--- a/aosp/dynamic_partition_control_android.cc
+++ b/aosp/dynamic_partition_control_android.cc
@@ -199,7 +199,7 @@
};
bool success = false;
if (GetVirtualAbFeatureFlag().IsEnabled() && target_supports_snapshot_ &&
- force_writable && ExpectMetadataMounted()) {
+ slot != source_slot_ && force_writable && ExpectMetadataMounted()) {
// Only target partitions are mapped with force_writable. On Virtual
// A/B devices, target partitions may overlap with source partitions, so
// they must be mapped with snapshot.
@@ -1247,7 +1247,7 @@
}
}
- bool force_writable = (slot != current_slot) && !not_in_payload;
+ const bool force_writable = !not_in_payload;
if (MapPartitionOnDeviceMapper(
super_device, partition_name_suffix, slot, force_writable, device)) {
return DynamicPartitionDeviceStatus::SUCCESS;
diff --git a/payload_consumer/verified_source_fd.cc b/payload_consumer/verified_source_fd.cc
index 3f17ad7..d760d1f 100644
--- a/payload_consumer/verified_source_fd.cc
+++ b/payload_consumer/verified_source_fd.cc
@@ -109,9 +109,16 @@
brillo::Blob source_hash;
brillo::Blob expected_source_hash(operation.src_sha256_hash().begin(),
operation.src_sha256_hash().end());
- if (fd_utils::ReadAndHashExtents(
- source_fd_, operation.src_extents(), block_size_, &source_hash) &&
- source_hash == expected_source_hash) {
+ if (!fd_utils::ReadAndHashExtents(
+ source_fd_, operation.src_extents(), block_size_, &source_hash)) {
+ LOG(ERROR) << "Failed to compute hash for operation " << operation.type()
+ << " data offset: " << operation.data_offset();
+ if (error) {
+ *error = ErrorCode::kDownloadOperationHashVerificationError;
+ }
+ return nullptr;
+ }
+ if (source_hash == expected_source_hash) {
return source_fd_;
}
if (error) {