update_engine: Call dlcservice's Install/Update Completion DBus APIs

When an Install/Update completes, update_engine will now let dlcservice
know all the DLCs that were installed/updated + verified.

Update_engine will also track during install/update for DLCs which did
not install/update so dlcservice receives the correct list of DLC IDs.

BUG=chromium:1059126
TEST=FEATURES=test emerge-$B update_engine update_engine-client

Cq-Depend: chromium:2141191
Change-Id: Id57f66c7c6957d34870d27119d9a6482fe902503
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2146104
Tested-by: Jae Hoon Kim <kimjae@chromium.org>
Commit-Queue: Jae Hoon Kim <kimjae@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Andrew Lassalle <andrewlassalle@chromium.org>
Auto-Submit: Jae Hoon Kim <kimjae@chromium.org>
diff --git a/dlcservice_chromeos.cc b/dlcservice_chromeos.cc
index ad5806a..3c76b2a 100644
--- a/dlcservice_chromeos.cc
+++ b/dlcservice_chromeos.cc
@@ -16,6 +16,7 @@
 
 #include "update_engine/dlcservice_chromeos.h"
 
+#include <brillo/errors/error.h>
 #include <dlcservice/proto_bindings/dlcservice.pb.h>
 // NOLINTNEXTLINE(build/include_alpha) "dbus-proxies.h" needs "dlcservice.pb.h"
 #include <dlcservice/dbus-proxies.h>
@@ -28,6 +29,12 @@
 
 namespace chromeos_update_engine {
 
+namespace {
+org::chromium::DlcServiceInterfaceProxy GetDlcServiceProxy() {
+  return {DBusConnection::Get()->GetDBus()};
+}
+}  // namespace
+
 std::unique_ptr<DlcServiceInterface> CreateDlcService() {
   return std::make_unique<DlcServiceChromeOS>();
 }
@@ -37,11 +44,8 @@
     return false;
   dlc_module_ids->clear();
 
-  org::chromium::DlcServiceInterfaceProxy dlcservice_proxy(
-      DBusConnection::Get()->GetDBus());
-
   dlcservice::DlcModuleList dlc_module_list;
-  if (!dlcservice_proxy.GetInstalled(&dlc_module_list, nullptr)) {
+  if (!GetDlcServiceProxy().GetInstalled(&dlc_module_list, nullptr)) {
     LOG(ERROR) << "dlcservice does not return installed DLC module list.";
     return false;
   }
@@ -51,4 +55,24 @@
   return true;
 }
 
+bool DlcServiceChromeOS::InstallCompleted(const std::vector<std::string>& ids) {
+  brillo::ErrorPtr err;
+  if (!GetDlcServiceProxy().InstallCompleted(ids, &err)) {
+    LOG(ERROR) << "dlcservice failed to complete install. ErrCode="
+               << err->GetCode() << ", ErrMsg=" << err->GetMessage();
+    return false;
+  }
+  return true;
+}
+
+bool DlcServiceChromeOS::UpdateCompleted(const std::vector<std::string>& ids) {
+  brillo::ErrorPtr err;
+  if (!GetDlcServiceProxy().UpdateCompleted(ids, &err)) {
+    LOG(ERROR) << "dlcservice failed to complete updated. ErrCode="
+               << err->GetCode() << ", ErrMsg=" << err->GetMessage();
+    return false;
+  }
+  return true;
+}
+
 }  // namespace chromeos_update_engine