Refactor daemon state and service async notification.
There are three supported IPC mechanism in this code: DBus, binder and
weave (over binder); which are mostly supported by all three platforms
Chrome OS, Brillo and Android. The exceptions are that Brillo and
Chrome OS still *require* DBus and support the others, while the new
Android daemon requires and supports only Binder.
This CL introduces two new interfaces: the ServiceObserverInterface and
the DaemonStateInterface.
The first one abstracts a service (or IPC service) into an interfcae
from the point of view of the daemon initialization and async
notifications of status changes. The second interface encapsulates the
state and main functionality of the update_engine daemon while leaving
the shared initialization in the main.cc and daemon.cc classes.
Bug: 25631949
TEST=`mmma system/update_engine` on edison-eng and aosp_arm-eng
TEST=FEATURES=test emerge-link update_engine
Change-Id: Ic15621031a153e14bdc4df8fcedbca1032e82c21
diff --git a/real_system_state.h b/real_system_state.h
index f65f706..071e3e0 100644
--- a/real_system_state.h
+++ b/real_system_state.h
@@ -33,6 +33,7 @@
#include "update_engine/common/hardware_interface.h"
#include "update_engine/common/prefs.h"
#include "update_engine/connection_manager.h"
+#include "update_engine/daemon_state_interface.h"
#include "update_engine/p2p_manager.h"
#include "update_engine/payload_state.h"
#include "update_engine/shill_proxy.h"
@@ -44,7 +45,7 @@
// A real implementation of the SystemStateInterface which is
// used by the actual product code.
-class RealSystemState : public SystemState {
+class RealSystemState : public SystemState, public DaemonStateInterface {
public:
// Constructs all system objects that do not require separate initialization;
// see Initialize() below for the remaining ones.
@@ -55,10 +56,15 @@
// separately from construction. Returns |true| on success.
bool Initialize();
+ // DaemonStateInterface overrides.
// Start the periodic update attempts. Must be called at the beginning of the
// program to start the periodic update check process.
- void StartUpdater();
+ bool StartUpdater() override;
+ void AddObserver(ServiceObserverInterface* observer) override;
+ void RemoveObserver(ServiceObserverInterface* observer) override;
+
+ // SystemState overrides.
inline void set_device_policy(
const policy::DevicePolicy* device_policy) override {
device_policy_ = device_policy;