update_engine: change notication order

in the case that update_engine has the state of
ErrorCode::kUpdatedButNotActive, update_engine currently first reports
an IDLE state, before reporting reporting the error. This leads to a
period in between the two reports ambiguous as to what the state of the
OTA is. Moving the report of errorcode ahead to clarify this.

Test: th
Bug: 348514779
Change-Id: I957332cfa576f2eca2fe899e3e5828b389868820
diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc
index b19d424..b5ec1e0 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -850,6 +850,9 @@
 
   boot_control_->GetDynamicPartitionControl()->Cleanup();
 
+  for (auto observer : daemon_state_->service_observers())
+    observer->SendPayloadApplicationComplete(error_code);
+
   download_progress_ = 0;
   UpdateStatus new_status =
       (error_code == ErrorCode::kSuccess ? UpdateStatus::UPDATED_NEED_REBOOT
@@ -863,9 +866,6 @@
     LOG(WARNING) << "Unable to unbind network.";
   }
 
-  for (auto observer : daemon_state_->service_observers())
-    observer->SendPayloadApplicationComplete(error_code);
-
   CollectAndReportUpdateMetricsOnUpdateFinished(error_code);
   ClearMetricsPrefs();
   if (error_code == ErrorCode::kSuccess) {