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/real_system_state.cc b/real_system_state.cc
index 906ec97..f415b90 100644
--- a/real_system_state.cc
+++ b/real_system_state.cc
@@ -18,9 +18,12 @@
 
 #include <string>
 
+#include <base/bind.h>
 #include <base/files/file_util.h>
+#include <base/location.h>
 #include <base/time/time.h>
 #include <brillo/make_unique_ptr.h>
+#include <brillo/message_loops/message_loop.h>
 
 #include "update_engine/common/boot_control.h"
 #include "update_engine/common/boot_control_stub.h"
@@ -30,6 +33,8 @@
 #include "update_engine/update_manager/state_factory.h"
 #include "update_engine/weave_service_factory.h"
 
+using brillo::MessageLoop;
+
 namespace chromeos_update_engine {
 
 RealSystemState::RealSystemState(const scoped_refptr<dbus::Bus>& bus)
@@ -160,4 +165,27 @@
   return true;
 }
 
+void RealSystemState::StartUpdater() {
+  // Initiate update checks.
+  update_attempter_->ScheduleUpdates();
+
+  // Update boot flags after 45 seconds.
+  MessageLoop::current()->PostDelayedTask(
+      FROM_HERE,
+      base::Bind(&UpdateAttempter::UpdateBootFlags,
+                 base::Unretained(update_attempter_.get())),
+      base::TimeDelta::FromSeconds(45));
+
+  // Broadcast the update engine status on startup to ensure consistent system
+  // state on crashes.
+  MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
+      &UpdateAttempter::BroadcastStatus,
+      base::Unretained(update_attempter_.get())));
+
+  // Run the UpdateEngineStarted() method on |update_attempter|.
+  MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
+      &UpdateAttempter::UpdateEngineStarted,
+      base::Unretained(update_attempter_.get())));
+}
+
 }  // namespace chromeos_update_engine