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/cleanup_previous_update_action.cc b/cleanup_previous_update_action.cc
index ee68947..26cc6be 100644
--- a/cleanup_previous_update_action.cc
+++ b/cleanup_previous_update_action.cc
@@ -160,7 +160,10 @@
if (metadata_device_ == nullptr) {
LOG(ERROR) << "Failed to mount /metadata.";
- processor_->ActionComplete(this, ErrorCode::kError);
+ // If metadata is erased but not formatted, it is possible to not mount
+ // it in recovery. It is safe to skip CleanupPreviousUpdateAction.
+ processor_->ActionComplete(
+ this, kIsRecovery ? ErrorCode::kSuccess : ErrorCode::kError);
return;
}