Fix merge in sideload

For UpdateAttempterAndroid:

- In sideload, ApplyPayload is immediately called after
UpdateAttempterAndroid::Init(), and errors out because
ScheduleCleanupPreviousUpdate starts the ActionProcessor. Do not
call it in sideload since ApplyPayload schedules a
CleanupPreviousUpdateAction too.
- Also fixes TerminateUpdateAndNotify in sideload if it errors at
CleanupPreviousUpdateAction.

For CleanupPreviousUpdateAction:

- Don't wait for boot_completed and slot verification in sideload.
- Ensure metadata is mounted.

Fixes: 151640692
Test: sideload

Change-Id: Ib91b208d3f8d79285b9a87a44410a575bd2da42e
Merged-In: Ib91b208d3f8d79285b9a87a44410a575bd2da42e
diff --git a/update_attempter_android.cc b/update_attempter_android.cc
index eecd2da..4b198e2 100644
--- a/update_attempter_android.cc
+++ b/update_attempter_android.cc
@@ -158,7 +158,12 @@
   } else {
     SetStatusAndNotify(UpdateStatus::IDLE);
     UpdatePrefsAndReportUpdateMetricsOnReboot();
+#ifdef _UE_SIDELOAD
+    LOG(INFO) << "Skip ScheduleCleanupPreviousUpdate in sideload because "
+              << "ApplyPayload will call it later.";
+#else
     ScheduleCleanupPreviousUpdate();
+#endif
   }
 }
 
@@ -644,6 +649,8 @@
   if (status_ == UpdateStatus::CLEANUP_PREVIOUS_UPDATE) {
     LOG(INFO) << "Terminating cleanup previous update.";
     SetStatusAndNotify(UpdateStatus::IDLE);
+    for (auto observer : daemon_state_->service_observers())
+      observer->SendPayloadApplicationComplete(error_code);
     return;
   }