Refactor get partition path and IsVABC into separate function am: e012f65a1b
Original change: https://android-review.googlesource.com/c/platform/system/update_engine/+/1701825
Change-Id: I187be7eb0967e878e66fc7da231d443ea12b97fc
diff --git a/payload_consumer/filesystem_verifier_action.cc b/payload_consumer/filesystem_verifier_action.cc
index b14cbc8..8d496a6 100644
--- a/payload_consumer/filesystem_verifier_action.cc
+++ b/payload_consumer/filesystem_verifier_action.cc
@@ -201,25 +201,13 @@
}
const InstallPlan::Partition& partition =
install_plan_.partitions[partition_index_];
- string part_path;
- switch (verifier_step_) {
- case VerifierStep::kVerifySourceHash:
- part_path = partition.source_path;
- partition_size_ = partition.source_size;
- break;
- case VerifierStep::kVerifyTargetHash:
- part_path = partition.target_path;
- partition_size_ = partition.target_size;
- break;
- }
+ const auto& part_path = GetPartitionPath();
+ partition_size_ = GetPartitionSize();
LOG(INFO) << "Hashing partition " << partition_index_ << " ("
<< partition.name << ") on device " << part_path;
auto success = false;
- if (dynamic_control_->UpdateUsesSnapshotCompression() &&
- verifier_step_ == VerifierStep::kVerifyTargetHash &&
- dynamic_control_->IsDynamicPartition(partition.name,
- install_plan_.target_slot)) {
+ if (IsVABC(partition)) {
success = InitializeFdVABC();
} else {
if (part_path.empty()) {
@@ -268,6 +256,40 @@
ScheduleFileSystemRead();
}
+bool FilesystemVerifierAction::IsVABC(
+ const InstallPlan::Partition& partition) const {
+ return dynamic_control_->UpdateUsesSnapshotCompression() &&
+ verifier_step_ == VerifierStep::kVerifyTargetHash &&
+ dynamic_control_->IsDynamicPartition(partition.name,
+ install_plan_.target_slot);
+}
+
+const std::string& FilesystemVerifierAction::GetPartitionPath() const {
+ const InstallPlan::Partition& partition =
+ install_plan_.partitions[partition_index_];
+ switch (verifier_step_) {
+ case VerifierStep::kVerifySourceHash:
+ return partition.source_path;
+ case VerifierStep::kVerifyTargetHash:
+ if (IsVABC(partition)) {
+ return partition.readonly_target_path;
+ } else {
+ return partition.target_path;
+ }
+ }
+}
+
+size_t FilesystemVerifierAction::GetPartitionSize() const {
+ const InstallPlan::Partition& partition =
+ install_plan_.partitions[partition_index_];
+ switch (verifier_step_) {
+ case VerifierStep::kVerifySourceHash:
+ return partition.source_size;
+ case VerifierStep::kVerifyTargetHash:
+ return partition.target_size;
+ }
+}
+
bool FilesystemVerifierAction::ShouldWriteVerity() {
const InstallPlan::Partition& partition =
install_plan_.partitions[partition_index_];
diff --git a/payload_consumer/filesystem_verifier_action.h b/payload_consumer/filesystem_verifier_action.h
index 78634cb..68a9432 100644
--- a/payload_consumer/filesystem_verifier_action.h
+++ b/payload_consumer/filesystem_verifier_action.h
@@ -91,6 +91,12 @@
// remaining to be hashed, it finishes the action.
void StartPartitionHashing();
+ const std::string& GetPartitionPath() const;
+
+ bool IsVABC(const InstallPlan::Partition& partition) const;
+
+ size_t GetPartitionSize() const;
+
// Schedules the asynchronous read of the filesystem part of this
// partition(not including hashtree/verity).
void ScheduleFileSystemRead();