Introduce brillo binder interface

This is more or less an exact analogue of the DBus interface, but
available over binder. We also add support to the client library and let
update_engine_client build with binder. We don't yet support an
equivalent of the status signal/the HandleStatusUpdate method. That will
come in a future CL.

Bug: 25908638
TEST=Verified update_engine_client functionality

Change-Id: Ic793619c8019b0d50aa184e0f592b6a9ab71e0b0
diff --git a/daemon.cc b/daemon.cc
index f7f2170..cc528a4 100644
--- a/daemon.cc
+++ b/daemon.cc
@@ -21,9 +21,9 @@
 #include <base/bind.h>
 #include <base/location.h>
 #include <base/time/time.h>
-#if USE_WEAVE
+#if USE_WEAVE || USE_BINDER
 #include <binderwrapper/binder_wrapper.h>
-#endif  // USE_WEAVE
+#endif  // USE_WEAVE || USE_BINDER
 #include <brillo/message_loops/message_loop.h>
 
 #include "update_engine/update_attempter.h"
@@ -45,10 +45,10 @@
   if (exit_code != EX_OK)
     return exit_code;
 
-#if USE_WEAVE
+#if USE_WEAVE || USE_BINDER
   android::BinderWrapper::Create();
   binder_watcher_.Init();
-#endif  // USE_WEAVE
+#endif  // USE_WEAVE || USE_BINDER
 
   // We wait for the D-Bus connection for up two minutes to avoid re-spawning
   // the daemon too fast causing thrashing if dbus-daemon is not running.
@@ -71,6 +71,18 @@
   UpdateAttempter* update_attempter = real_system_state_->update_attempter();
   CHECK(update_attempter);
 
+#if USE_BINDER
+  // Create the Binder Service
+  service_ = new BinderUpdateEngineService{real_system_state_.get()};
+  auto binder_wrapper = android::BinderWrapper::Get();
+  sleep(10);
+  if (!binder_wrapper->RegisterService("android.brillo.UpdateEngineService",
+                                       service_)) {
+    LOG(ERROR) << "Failed to register binder service.";
+  }
+
+#endif  // USE_BINDER
+
   // Create the DBus service.
   dbus_adaptor_.reset(new UpdateEngineAdaptor(real_system_state_.get(), bus));
   update_attempter->set_dbus_adaptor(dbus_adaptor_.get());