Do not map dynamic partitions on VABC devices
With VABC, we no longer need to map all partitions before
reading/writing, so don't try to map them.
1. modify GetPartitionDevice to return empty path for target partitions
on VABC
2. Add a separate GetMountableTargetDevice for obtaining a mountable
device path, specifically for postinstall
Test: treehugger
Change-Id: Ib1f608914fc49c677ce7389140ca79b028171191
diff --git a/common/fake_boot_control.h b/common/fake_boot_control.h
index 98b93e6..fc7839d 100644
--- a/common/fake_boot_control.h
+++ b/common/fake_boot_control.h
@@ -51,14 +51,16 @@
bool not_in_payload,
std::string* device,
bool* is_dynamic) const override {
- if (slot >= num_slots_)
+ auto dev =
+ GetPartitionDevice(partition_name, slot, current_slot_, not_in_payload);
+ if (!dev.has_value()) {
return false;
- auto part_it = devices_[slot].find(partition_name);
- if (part_it == devices_[slot].end())
- return false;
- *device = part_it->second;
- if (is_dynamic != nullptr) {
- *is_dynamic = false;
+ }
+ if (is_dynamic) {
+ *is_dynamic = dev->is_dynamic;
+ }
+ if (device) {
+ *device = dev->rw_device_path;
}
return true;
}
@@ -120,6 +122,25 @@
return dynamic_partition_control_.get();
}
+ std::optional<PartitionDevice> GetPartitionDevice(
+ const std::string& partition_name,
+ uint32_t slot,
+ uint32_t current_slot,
+ bool not_in_payload = false) const override {
+ if (slot >= devices_.size()) {
+ return {};
+ }
+ auto device_path = devices_[slot].find(partition_name);
+ if (device_path == devices_[slot].end()) {
+ return {};
+ }
+ PartitionDevice device;
+ device.is_dynamic = false;
+ device.rw_device_path = device_path->second;
+ device.mountable_device_path = device.rw_device_path;
+ return device;
+ }
+
private:
BootControlInterface::Slot num_slots_{2};
BootControlInterface::Slot current_slot_{0};