[REFACTOR] DynamicPartitionControl: Add GetSuperPartitionName
fs_mgr_get_super_partition_name() should be mocked because
it is an external dependency to libfs_mgr.
In tests, deliberately make GetSuperDevice() to return "fake_super"
instead of "super" to make sure it is mocked properly.
Test: run unittests
Test: manually apply OTA
Change-Id: I0f05d99bf168b6e658052b4bd67dc1e82ab36471
diff --git a/dynamic_partition_control_android.cc b/dynamic_partition_control_android.cc
index 329ddd3..1a1e021 100644
--- a/dynamic_partition_control_android.cc
+++ b/dynamic_partition_control_android.cc
@@ -309,7 +309,7 @@
}
base::FilePath device_dir(device_dir_str);
auto source_device =
- device_dir.Append(fs_mgr_get_super_partition_name(source_slot)).value();
+ device_dir.Append(GetSuperPartitionName(source_slot)).value();
auto builder = LoadMetadataBuilder(source_device, source_slot, target_slot);
if (builder == nullptr) {
@@ -324,10 +324,15 @@
}
auto target_device =
- device_dir.Append(fs_mgr_get_super_partition_name(target_slot)).value();
+ device_dir.Append(GetSuperPartitionName(target_slot)).value();
return StoreMetadata(target_device, builder.get(), target_slot);
}
+std::string DynamicPartitionControlAndroid::GetSuperPartitionName(
+ uint32_t slot) {
+ return fs_mgr_get_super_partition_name(slot);
+}
+
bool DynamicPartitionControlAndroid::UpdatePartitionMetadata(
MetadataBuilder* builder,
uint32_t target_slot,