Delete COW group for downgrade Virtual A/B
When applying a downgrade OTA package on retrofit
Virtual A/B device (to a non-Virtual-A/B build), the
COW group / partitions needs to be explicitly deleted
to ensure there are enough space to create the regular
target partitions.
Bug: 138258570
Test: apply downgrade
Change-Id: I9e90a26500ec291ebd1e784e8e7fb8fbd508a925
diff --git a/dynamic_partition_control_android.cc b/dynamic_partition_control_android.cc
index 88a787a..2bd7d51 100644
--- a/dynamic_partition_control_android.cc
+++ b/dynamic_partition_control_android.cc
@@ -423,6 +423,11 @@
MetadataBuilder* builder,
uint32_t target_slot,
const DeltaArchiveManifest& manifest) {
+ // If applying downgrade from Virtual A/B to non-Virtual A/B, the left-over
+ // COW group needs to be deleted to ensure there are enough space to create
+ // target partitions.
+ builder->RemoveGroupAndPartitions(android::snapshot::kCowGroupName);
+
const std::string target_suffix = SlotSuffixForSlotNumber(target_slot);
DeleteGroupsWithSuffix(builder, target_suffix);