ResetStatus deletes snapshots for VAB.
When ResetStatus() is called, delete snapshots to free up space on
VAB devices.
On regular A/B, there is no need to cancel the update completely so that
the update may be resumed next time. However, on VAB devices, a
cancelled update should not occupy previously allocated space.
Test: manually call update_engine_client --cancel when an update is in progress, then
call update_engine_client --reset_status, then
call snapshotctl dump to check that snapshots are deleted.
Then, re-apply the update.
Test: manually kill update_engine when an update is in progress, then
call update_engine_client --reset_status, then
call snapshotctl dump to check that snapshots are deleted.
Then, re-apply the update.
Test: manually apply an update until UPDATED_NEED_REBOOT, then
call update_engine_client --reset_status, then
call snapshotctl dump to check that snapshots are deleted.
Then, re-apply the update.
Test: manually apply an update until UPDATED_NEED_REBOOT, then
kill update_engine, then
call update_engine_client --reset_status, then
call snapshotctl dump to check that snapshots are deleted.
Then, re-apply the update.
Bug: 147696014
Change-Id: Ic7049772091a34e0e666fd7ae361ef474d5a28aa
Merged-In: Ic7049772091a34e0e666fd7ae361ef474d5a28aa
diff --git a/update_attempter_android.cc b/update_attempter_android.cc
index 4b198e2..b7d119f 100644
--- a/update_attempter_android.cc
+++ b/update_attempter_android.cc
@@ -350,15 +350,16 @@
<< UpdateStatusToString(status_) << " to UpdateStatus::IDLE";
switch (status_) {
- case UpdateStatus::IDLE:
+ case UpdateStatus::IDLE: {
+ if (!boot_control_->GetDynamicPartitionControl()->ResetUpdate(prefs_)) {
+ LOG(WARNING) << "Failed to reset snapshots. UpdateStatus is IDLE but"
+ << "space might not be freed.";
+ }
return true;
+ }
case UpdateStatus::UPDATED_NEED_REBOOT: {
- // Remove the reboot marker so that if the machine is rebooted
- // after resetting to idle state, it doesn't go back to
- // UpdateStatus::UPDATED_NEED_REBOOT state.
- bool ret_value = prefs_->Delete(kPrefsUpdateCompletedOnBootId);
- ClearMetricsPrefs();
+ bool ret_value = true;
// Update the boot flags so the current slot has higher priority.
if (!boot_control_->SetActiveBootSlot(GetCurrentSlot()))
@@ -373,6 +374,17 @@
// Resets the warm reset property since we won't switch the slot.
hardware_->SetWarmReset(false);
+ // Remove update progress for DeltaPerformer and remove snapshots.
+ if (!boot_control_->GetDynamicPartitionControl()->ResetUpdate(prefs_))
+ ret_value = false;
+
+ // Remove the reboot marker so that if the machine is rebooted
+ // after resetting to idle state, it doesn't go back to
+ // UpdateStatus::UPDATED_NEED_REBOOT state.
+ if (!prefs_->Delete(kPrefsUpdateCompletedOnBootId))
+ ret_value = false;
+ ClearMetricsPrefs();
+
if (!ret_value) {
return LogAndSetError(
error, FROM_HERE, "Failed to reset the status to ");