Only wait for merge delay if there's merge pending

If ro.virtual_ab.merge_delay_seconds is set update_engine would wait for
X seconds before allowing OTA updates, even if there's no merge pending
anyway. Fix by first check if there's a merge pending.

Test: th
Bug: 316796547
Change-Id: I3474ccad0e82c67f64911446f08967c72fa1b60c
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,