Skip to content

Commit 3c9703d

Browse files
Refactor get partition path and IsVABC into separate function am: e012f65 am: 5ac9a7d
Original change: https://android-review.googlesource.com/c/platform/system/update_engine/+/1701825 Change-Id: I84994a0b514153386b1e47e5da957b18bff9ee73
2 parents 022e20e + 5ac9a7d commit 3c9703d

File tree

2 files changed

+43
-15
lines changed

2 files changed

+43
-15
lines changed

payload_consumer/filesystem_verifier_action.cc

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -201,25 +201,13 @@ void FilesystemVerifierAction::StartPartitionHashing() {
201201
}
202202
const InstallPlan::Partition& partition =
203203
install_plan_.partitions[partition_index_];
204-
string part_path;
205-
switch (verifier_step_) {
206-
case VerifierStep::kVerifySourceHash:
207-
part_path = partition.source_path;
208-
partition_size_ = partition.source_size;
209-
break;
210-
case VerifierStep::kVerifyTargetHash:
211-
part_path = partition.target_path;
212-
partition_size_ = partition.target_size;
213-
break;
214-
}
204+
const auto& part_path = GetPartitionPath();
205+
partition_size_ = GetPartitionSize();
215206

216207
LOG(INFO) << "Hashing partition " << partition_index_ << " ("
217208
<< partition.name << ") on device " << part_path;
218209
auto success = false;
219-
if (dynamic_control_->UpdateUsesSnapshotCompression() &&
220-
verifier_step_ == VerifierStep::kVerifyTargetHash &&
221-
dynamic_control_->IsDynamicPartition(partition.name,
222-
install_plan_.target_slot)) {
210+
if (IsVABC(partition)) {
223211
success = InitializeFdVABC();
224212
} else {
225213
if (part_path.empty()) {
@@ -268,6 +256,40 @@ void FilesystemVerifierAction::StartPartitionHashing() {
268256
ScheduleFileSystemRead();
269257
}
270258

259+
bool FilesystemVerifierAction::IsVABC(
260+
const InstallPlan::Partition& partition) const {
261+
return dynamic_control_->UpdateUsesSnapshotCompression() &&
262+
verifier_step_ == VerifierStep::kVerifyTargetHash &&
263+
dynamic_control_->IsDynamicPartition(partition.name,
264+
install_plan_.target_slot);
265+
}
266+
267+
const std::string& FilesystemVerifierAction::GetPartitionPath() const {
268+
const InstallPlan::Partition& partition =
269+
install_plan_.partitions[partition_index_];
270+
switch (verifier_step_) {
271+
case VerifierStep::kVerifySourceHash:
272+
return partition.source_path;
273+
case VerifierStep::kVerifyTargetHash:
274+
if (IsVABC(partition)) {
275+
return partition.readonly_target_path;
276+
} else {
277+
return partition.target_path;
278+
}
279+
}
280+
}
281+
282+
size_t FilesystemVerifierAction::GetPartitionSize() const {
283+
const InstallPlan::Partition& partition =
284+
install_plan_.partitions[partition_index_];
285+
switch (verifier_step_) {
286+
case VerifierStep::kVerifySourceHash:
287+
return partition.source_size;
288+
case VerifierStep::kVerifyTargetHash:
289+
return partition.target_size;
290+
}
291+
}
292+
271293
bool FilesystemVerifierAction::ShouldWriteVerity() {
272294
const InstallPlan::Partition& partition =
273295
install_plan_.partitions[partition_index_];

payload_consumer/filesystem_verifier_action.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ class FilesystemVerifierAction : public InstallPlanAction {
9191
// remaining to be hashed, it finishes the action.
9292
void StartPartitionHashing();
9393

94+
const std::string& GetPartitionPath() const;
95+
96+
bool IsVABC(const InstallPlan::Partition& partition) const;
97+
98+
size_t GetPartitionSize() const;
99+
94100
// Schedules the asynchronous read of the filesystem part of this
95101
// partition(not including hashtree/verity).
96102
void ScheduleFileSystemRead();

0 commit comments

Comments
 (0)