Retain merge failure codes if merge succeeds. am: 28e46893d0 am: 51428b62b9
Original change: https://android-review.googlesource.com/c/platform/system/update_engine/+/1716269
Change-Id: Ib4bf2bd1d5937bf0ce1c17dd113ec02574c21069
diff --git a/aosp/cleanup_previous_update_action.cc b/aosp/cleanup_previous_update_action.cc
index dde6b89..51bb083 100644
--- a/aosp/cleanup_previous_update_action.cc
+++ b/aosp/cleanup_previous_update_action.cc
@@ -276,7 +276,17 @@
void CleanupPreviousUpdateAction::WaitForMergeOrSchedule() {
AcknowledgeTaskExecuted();
TEST_AND_RETURN(running_);
+
auto update_uses_compression = snapshot_->UpdateUsesCompression();
+
+ // Propagate the merge failure code to the merge stats. If we wait until
+ // after ProcessUpdateState, then a successful merge could overwrite the
+ // state of the previous failure.
+ auto failure_code = snapshot_->ReadMergeFailureCode();
+ if (failure_code != android::snapshot::MergeFailureCode::Ok) {
+ merge_stats_->set_merge_failure_code(failure_code);
+ }
+
auto state = snapshot_->ProcessUpdateState(
std::bind(&CleanupPreviousUpdateAction::OnMergePercentageUpdate, this),
std::bind(&CleanupPreviousUpdateAction::BeforeCancel, this));