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.

Change-Id: I0e3296446e811b5efbee7791565710fc1fa3a8dd
diff --git a/update_attempter.cc b/update_attempter.cc
index 8afc395..4e300d7 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -1140,6 +1140,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();
 
diff --git a/update_attempter_android.cc b/update_attempter_android.cc
index 2de2667..a5c25c0 100644
--- a/update_attempter_android.cc
+++ b/update_attempter_android.cc
@@ -257,6 +257,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;
+
       if (!ret_value) {
         return LogAndSetError(
             error,