Support sideload full update on VAB
On devices with Virtual A/B, certain regions are snapshotted
during the udpate. Snapshots may fail to be created in
recovery because fiemap of userdata cannot be retrieved (it may
succeed if empty space in super is enough to hold CoW, although
this is likely not the case for launch VAB).
In this case (on VAB devices when super is not big enough,
esp. for launch VAB devices):
- sideloading incremental OTAs are not allowed
- sideloading full OTAs is similar to flashing. Source partitions
are deleted from super.
Note that to reduce the difference between launch and retrofit
VAB devices, most code only checks
GetVirtualAbFeatureFlag().IsEnabled(). IsLaunch() is only used when
doing sanity checks and providing more detailed logging information.
Test: manually make PrepareSnapshotPartitionsForUpdate fail, then sideload
Test: update_engine_unittests
Bug: 140749209
Change-Id: I64927c85bfb10b34d8bd19bd88c18663f4a2a917
diff --git a/dynamic_partition_control_android.h b/dynamic_partition_control_android.h
index ba23e7c..e7ae26b 100644
--- a/dynamic_partition_control_android.h
+++ b/dynamic_partition_control_android.h
@@ -127,10 +127,13 @@
virtual void set_fake_mapped_devices(const std::set<std::string>& fake);
+ // Allow mock objects to override this to test recovery mode.
+ virtual bool IsRecovery();
+
private:
friend class DynamicPartitionControlAndroidTest;
- void CleanupInternal();
+ void UnmapAllPartitions();
bool MapPartitionInternal(const std::string& super_device,
const std::string& target_partition_name,
uint32_t slot,
@@ -143,11 +146,14 @@
uint32_t target_slot,
const DeltaArchiveManifest& manifest);
- // Helper for PreparePartitionsForUpdate. Used for dynamic partitions without
- // Virtual A/B update.
+ // Helper for PreparePartitionsForUpdate. Used for devices with dynamic
+ // partitions updating without snapshots.
+ // If |delete_source| is set, source partitions are deleted before resizing
+ // target partitions (using DeleteSourcePartitions).
bool PrepareDynamicPartitionsForUpdate(uint32_t source_slot,
uint32_t target_slot,
- const DeltaArchiveManifest& manifest);
+ const DeltaArchiveManifest& manifest,
+ bool delete_source);
// Helper for PreparePartitionsForUpdate. Used for snapshotted partitions for
// Virtual A/B update.
@@ -179,6 +185,11 @@
uint32_t current_slot,
const std::string& partition_name_suffix);
+ // If sideloading a full OTA, delete source partitions from |builder|.
+ bool DeleteSourcePartitions(android::fs_mgr::MetadataBuilder* builder,
+ uint32_t source_slot,
+ const DeltaArchiveManifest& manifest);
+
std::set<std::string> mapped_devices_;
const FeatureFlag dynamic_partitions_;
const FeatureFlag virtual_ab_;