Snap for 12948418 from a21364a4fcf248d8798564c1b7b2a9202d08f4e6 to 25Q2-release

Change-Id: Ie03900fe3ca30e179ce8b1762363aee9aec7a4bd
diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc
index 89c79f3..943c3e4 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -482,6 +482,18 @@
 }
 
 bool UpdateAttempterAndroid::CancelUpdate(Error* error) {
+  auto action = processor_->current_action();
+  if (action != nullptr &&
+      action->Type() == CleanupPreviousUpdateAction::StaticType()) {
+    return LogAndSetError(
+        error,
+        __LINE__,
+        __FILE__,
+        "CleanupPreviousUpdateAction is running, this action cannot be "
+        "canceled. As it often performs critical merge operations after "
+        "reboot.",
+        ErrorCode::kRollbackNotPossible);
+  }
   if (!processor_->IsRunning())
     return LogAndSetGenericError(
         error, __LINE__, __FILE__, "No ongoing update to cancel.");