Implement Android UE daemon using brillo::Daemon.
The setup logic for Brillo and Android devices is very similar despite
the differences in the daemon logic and exposed service interface.
This patch reuses the brillo::Daemon derived class and the main()
function from Brillo to implement the daemon and service setup in
Android as well.
In addition, the Chromium OS build now defines the __CHROMEOS__ macro
to make the code behave the same way as in the Brillo case.
Bug: 25631949
TEST=`mmma system/update_engine` on edison-eng and aosp_arm-eng
Change-Id: I0f9690264e0822ef7e71318c73c2f16eda99e07c
diff --git a/daemon.h b/daemon.h
index 6233064..32437cb 100644
--- a/daemon.h
+++ b/daemon.h
@@ -24,14 +24,24 @@
#include <brillo/binder_watcher.h>
#endif // USE_WEAVE || USE_BINDER
#include <brillo/daemons/daemon.h>
+#if USE_DBUS
#include <brillo/dbus/dbus_connection.h>
+#endif // USE_DBUS
#if USE_BINDER
+#if defined(__BRILLO__) || defined(__CHROMEOS__)
#include "update_engine/binder_service.h"
+#else // !(defined(__BRILLO__) || defined(__CHROMEOS__))
+#include "update_engine/binder_service_android.h"
+#endif // defined(__BRILLO__) || defined(__CHROMEOS__)
#endif // USE_BINDER
#include "update_engine/common/subprocess.h"
+#if USE_DBUS
#include "update_engine/dbus_service.h"
+#endif // USE_DBUS
+#if defined(__BRILLO__) || defined(__CHROMEOS__)
#include "update_engine/real_system_state.h"
+#endif // defined(__BRILLO__) || defined(__CHROMEOS__)
namespace chromeos_update_engine {
@@ -43,6 +53,7 @@
int OnInit() override;
private:
+#if USE_DBUS
// Run from the main loop when the |dbus_adaptor_| object is registered. At
// this point we can request ownership of the DBus service name and continue
// initialization.
@@ -51,6 +62,7 @@
// Main D-Bus connection and service adaptor.
brillo::DBusConnection dbus_connection_;
std::unique_ptr<UpdateEngineAdaptor> dbus_adaptor_;
+#endif // USE_DBUS
// The Subprocess singleton class requires a brillo::MessageLoop in the
// current thread, so we need to initialize it from this class instead of
@@ -62,11 +74,19 @@
#endif // USE_WEAVE || USE_BINDER
#if USE_BINDER
+#if defined(__BRILLO__) || defined(__CHROMEOS__)
android::sp<BinderUpdateEngineService> service_;
+#else // !(defined(__BRILLO__) || defined(__CHROMEOS__))
+ android::sp<BinderUpdateEngineAndroidService> service_;
+#endif // defined(__BRILLO__) || defined(__CHROMEOS__)
#endif // USE_BINDER
+#if defined(__BRILLO__) || defined(__CHROMEOS__)
// The RealSystemState uses the previous classes so it should be defined last.
std::unique_ptr<RealSystemState> real_system_state_;
+#else // !(defined(__BRILLO__) || defined(__CHROMEOS__))
+ //TODO(deymo): Define non-Brillo state.
+#endif // defined(__BRILLO__) || defined(__CHROMEOS__)
DISALLOW_COPY_AND_ASSIGN(UpdateEngineDaemon);
};