Mark current slot successful after cancelling an update.
When cancelling an update that was completed and pending reboot, we
need to rollback the "SetActiveSlot(the_other_slot)" action performed
when the update was applied. We used to just mark the current slot as
active, which should switch the priorities to make the current slot the
priority one.
This patch also marks the current slot as successful after marking it as
active since the action of marking a slot as active in the HAL might
reset the successful bit. The current slot must have already been marked
as successful because an update was applied, so this wouldn't mark a bad
slot successful.
Bug: 33102712
Test: Manual test: deployed an update, cancelled it with --reset_status
and checked that the current slot is still marked as successful.
(cherry picked from commit 5259033d23938ce3ce20e4a9b599be0eec113610)
Change-Id: I14f00fc0fb7156f148d06d1ed9a547223d7926cc
diff --git a/update_attempter.cc b/update_attempter.cc
index c773063..79cbcbf 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -1166,6 +1166,12 @@
if (!boot_control->SetActiveBootSlot(boot_control->GetCurrentSlot()))
ret_value = false;
+ // Mark the current slot as successful again, since marking it as active
+ // may reset the successful bit. We ignore the result of whether marking
+ // the current slot as successful worked.
+ if (!boot_control_->MarkBootSuccessfulAsync(Bind([](bool successful){})))
+ ret_value = false;
+
// Notify the PayloadState that the successful payload was canceled.
system_state_->payload_state()->ResetUpdateStatus();