Allow to skip mounting metadata in recovery.
After factory data reset, metadata has no valid ext4 fs, and it is not
formatted when recovery is started. Hence, it is possible that recovery
can't mount metadata. Use fallback path for sideloading full OTAs on
Virtual A/B devices in this case.
Test: the following:
fastboot reboot fastboot -w
fastboot reboot recovery
adb root
adb shell mount -t ext4 /dev/block/by-name/metadata /metadata # fails
adb reboot sideload
adb sideload ota.zip # successful
Bug: 152352037
Change-Id: I51ae3e5918b0c00054f309832c45823d80e46c69
diff --git a/dynamic_partition_control_android.h b/dynamic_partition_control_android.h
index 9dcdcf1..8ad7593 100644
--- a/dynamic_partition_control_android.h
+++ b/dynamic_partition_control_android.h
@@ -233,6 +233,28 @@
uint32_t source_slot,
const DeltaArchiveManifest& manifest);
+ // Returns true if metadata is expected to be mounted, false otherwise.
+ // Note that it returns false on non-Virtual A/B devices.
+ //
+ // Almost all functions of SnapshotManager depends on metadata being mounted.
+ // - In Android mode for Virtual A/B devices, assume it is mounted. If not,
+ // let caller fails when calling into SnapshotManager.
+ // - In recovery for Virtual A/B devices, it is possible that metadata is not
+ // formatted, hence it cannot be mounted. Caller should not call into
+ // SnapshotManager.
+ // - On non-Virtual A/B devices, updates do not depend on metadata partition.
+ // Caller should not call into SnapshotManager.
+ //
+ // This function does NOT mount metadata partition. Use EnsureMetadataMounted
+ // to mount metadata partition.
+ bool ExpectMetadataMounted();
+
+ // Ensure /metadata is mounted. Returns true if successful, false otherwise.
+ //
+ // Note that this function returns true on non-Virtual A/B devices without
+ // doing anything.
+ bool EnsureMetadataMounted();
+
std::set<std::string> mapped_devices_;
const FeatureFlag dynamic_partitions_;
const FeatureFlag virtual_ab_;