Only wait for merge delay if there's merge pending am: a4650bd30e

Original change: https://android-review.googlesource.com/c/platform/system/update_engine/+/2886530

Change-Id: I8f2383d16e1ee3c79fd54fa1d8b9374ebd1bd8c4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/aosp/cleanup_previous_update_action.cc b/aosp/cleanup_previous_update_action.cc
index b070ecd..3b54f80 100644
--- a/aosp/cleanup_previous_update_action.cc
+++ b/aosp/cleanup_previous_update_action.cc
@@ -16,7 +16,7 @@
 #include "update_engine/aosp/cleanup_previous_update_action.h"
 
 #include <algorithm>
-#include <chrono>  // NOLINT(build/c++11) -- for merge times
+#include <chrono>
 #include <functional>
 #include <string>
 #include <type_traits>
@@ -24,6 +24,7 @@
 #include <android-base/chrono_utils.h>
 #include <android-base/properties.h>
 #include <base/bind.h>
+#include <libsnapshot/snapshot.h>
 
 #ifndef __ANDROID_RECOVERY__
 #include <statslog_ue.h>
@@ -205,6 +206,10 @@
 }
 
 void CleanupPreviousUpdateAction::CheckForMergeDelay() {
+  if (!android::snapshot::SnapshotManager::IsSnapshotManagerNeeded()) {
+    StartMerge();
+    return;
+  }
   const auto merge_delay_seconds =
       std::clamp<int>(android::base::GetIntProperty(kMergeDelaySecondsProp, 0),
                       0,
diff --git a/aosp/cleanup_previous_update_action.h b/aosp/cleanup_previous_update_action.h
index 1d701b1..6708a5e 100644
--- a/aosp/cleanup_previous_update_action.h
+++ b/aosp/cleanup_previous_update_action.h
@@ -17,7 +17,6 @@
 #ifndef UPDATE_ENGINE_AOSP_CLEANUP_PREVIOUS_UPDATE_ACTION_H_
 #define UPDATE_ENGINE_AOSP_CLEANUP_PREVIOUS_UPDATE_ACTION_H_
 
-#include <chrono>  // NOLINT(build/c++11) -- for merge times
 #include <memory>
 #include <string>
 #include <string_view>