UpdateAttempterAndroid::Init initiates merge
On update_engine starts, schedule CleanupPreviousUpdateAction that calls
CleanupSuccessfulUpdate to do necessary cleanup as soon as possible.
In the good case, update_engine initiates merge when
sys.boot_completed, and clean up snapshots.
If the update is
rolled back or partitions are flashed, the following happens (on
a Virtual A/B device):
- UpdateAttempterAndroid::CleanupSuccessfulUpdate is called
- DynamicPartitionControlAndroid::CleanupSuccessfulUpdate is called
- SnapshotManager::InitiateMergeAndWait is called
- SnapshotManager::RemoveAllUpdateState(before_cancel) is called
- before_cancel is called,
DeltaPerformer::ResetUpdateProgress is called
- All update states in update_engine is reset.
- SnapshotManager proceeds to delete snapshots
- All update states in SnapshotManager is reset.
Hence, on an VAB device, when an update is rolled back or partitions
are flashed, the whole update needs to be re-applied
(while in A/B, it skips writing and directly start verifying hashes of
the target partitions because the update markers are still there).
Bug: 147696014
Test: apply OTA then reboot, inspect logs and do `snapshotctl dump`
Change-Id: I0fc5e7768dfb53e4fd474f2d8d85d2a1b615a88b
diff --git a/dynamic_partition_control_android.cc b/dynamic_partition_control_android.cc
index 938a75b..84c2f78 100644
--- a/dynamic_partition_control_android.cc
+++ b/dynamic_partition_control_android.cc
@@ -35,6 +35,7 @@
#include <libdm/dm.h>
#include <libsnapshot/snapshot.h>
+#include "update_engine/cleanup_previous_update_action.h"
#include "update_engine/common/boot_control_interface.h"
#include "update_engine/common/utils.h"
#include "update_engine/dynamic_partition_utils.h"
@@ -786,4 +787,16 @@
return true;
}
+std::unique_ptr<AbstractAction>
+DynamicPartitionControlAndroid::GetCleanupPreviousUpdateAction(
+ BootControlInterface* boot_control,
+ PrefsInterface* prefs,
+ CleanupPreviousUpdateActionDelegateInterface* delegate) {
+ if (!GetVirtualAbFeatureFlag().IsEnabled()) {
+ return std::make_unique<NoOpAction>();
+ }
+ return std::make_unique<CleanupPreviousUpdateAction>(
+ prefs, boot_control, snapshot_.get(), delegate);
+}
+
} // namespace chromeos_update_engine