Call InitPartitionMetadata when resuming an update.
BootControlAndroid::InitPartitionMetadata() should always be called when
starting / resuming an update that uses dynamic partitions. This allows
updating the metadata for the target slot, as well as setting up the
internal state for accessing the dynamic partitions in the target slot.
Bug: 122097567
Test: Run update_engine_unittests on taimen and blueline.
Test: Apply a payload that uses dynamic partitions. Reboot before it
finishes, then resume the update.
Change-Id: I1353f7460a61c0183654b6349689beaa9bf12129
diff --git a/boot_control_android.cc b/boot_control_android.cc
index af1a5f9..421c091 100644
--- a/boot_control_android.cc
+++ b/boot_control_android.cc
@@ -396,7 +396,9 @@
} // namespace
bool BootControlAndroid::InitPartitionMetadata(
- Slot target_slot, const PartitionMetadata& partition_metadata) {
+ Slot target_slot,
+ const PartitionMetadata& partition_metadata,
+ bool update_metadata) {
if (fs_mgr_overlayfs_is_setup()) {
// Non DAP devices can use overlayfs as well.
LOG(WARNING)
@@ -414,11 +416,6 @@
return false;
}
- string target_suffix;
- if (!GetSuffix(target_slot, &target_suffix)) {
- return false;
- }
-
// Although the current build supports dynamic partitions, the given payload
// doesn't use it for target partitions. This could happen when applying a
// retrofit update. Skip updating the partition metadata for the target slot.
@@ -427,6 +424,15 @@
return true;
}
+ if (!update_metadata) {
+ return true;
+ }
+
+ string target_suffix;
+ if (!GetSuffix(target_slot, &target_suffix)) {
+ return false;
+ }
+
// Unmap all the target dynamic partitions because they would become
// inconsistent with the new metadata.
if (!UnmapTargetPartitions(
@@ -434,15 +440,11 @@
return false;
}
- if (!UpdatePartitionMetadata(dynamic_control_.get(),
- source_slot,
- target_slot,
- target_suffix,
- partition_metadata)) {
- return false;
- }
-
- return true;
+ return UpdatePartitionMetadata(dynamic_control_.get(),
+ source_slot,
+ target_slot,
+ target_suffix,
+ partition_metadata);
}
} // namespace chromeos_update_engine