BootControlAndroid: load / store metadata to correct 'super'
The 'super' device is different for different slots
on retrofit devices. Call fs_mgr_get_super_partition_name
with the correct slot.
Test: manual OTA
Bug: 118506262
Change-Id: I587556b5670a6578ee38c8549b8c2869c04a8850
diff --git a/boot_control_android.cc b/boot_control_android.cc
index 1d13139..f1d7b9c 100644
--- a/boot_control_android.cc
+++ b/boot_control_android.cc
@@ -188,7 +188,7 @@
base::FilePath device_dir(device_dir_str);
string super_device =
- device_dir.Append(fs_mgr_get_super_partition_name()).value();
+ device_dir.Append(fs_mgr_get_super_partition_name(slot)).value();
switch (GetDynamicPartitionDevice(dynamic_control_.get(),
super_device,
partition_name_suffix,
@@ -280,13 +280,14 @@
bool InitPartitionMetadataInternal(
DynamicPartitionControlInterface* dynamic_control,
- const string& super_device,
+ const string& source_device,
+ const string& target_device,
Slot source_slot,
Slot target_slot,
const string& target_suffix,
const PartitionMetadata& partition_metadata) {
auto builder = dynamic_control->LoadMetadataBuilder(
- super_device, source_slot, target_slot);
+ source_device, source_slot, target_slot);
if (builder == nullptr) {
// TODO(elsk): allow reconstructing metadata from partition_metadata
// in recovery sideload.
@@ -348,12 +349,12 @@
}
return dynamic_control->StoreMetadata(
- super_device, builder.get(), target_slot);
+ target_device, builder.get(), target_slot);
}
// Unmap all partitions, and remap partitions as writable.
bool Remap(DynamicPartitionControlInterface* dynamic_control,
- const string& super_device,
+ const string& target_device,
Slot target_slot,
const string& target_suffix,
const PartitionMetadata& partition_metadata) {
@@ -368,7 +369,7 @@
}
string map_path;
if (!dynamic_control->MapPartitionOnDeviceMapper(
- super_device,
+ target_device,
partition.name + target_suffix,
target_slot,
true /* force writable */,
@@ -393,14 +394,16 @@
return false;
}
base::FilePath device_dir(device_dir_str);
- string super_device =
- device_dir.Append(fs_mgr_get_super_partition_name()).value();
+ string target_device =
+ device_dir.Append(fs_mgr_get_super_partition_name(target_slot)).value();
Slot current_slot = GetCurrentSlot();
if (target_slot == current_slot) {
LOG(ERROR) << "Cannot call InitPartitionMetadata on current slot.";
return false;
}
+ string source_device =
+ device_dir.Append(fs_mgr_get_super_partition_name(current_slot)).value();
string target_suffix;
if (!GetSuffix(target_slot, &target_suffix)) {
@@ -408,7 +411,8 @@
}
if (!InitPartitionMetadataInternal(dynamic_control_.get(),
- super_device,
+ source_device,
+ target_device,
current_slot,
target_slot,
target_suffix,
@@ -417,7 +421,7 @@
}
if (!Remap(dynamic_control_.get(),
- super_device,
+ target_device,
target_slot,
target_suffix,
partition_metadata)) {