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/binder_service_android.h b/binder_service_android.h
index 224ab07..2fb9ca1 100644
--- a/binder_service_android.h
+++ b/binder_service_android.h
@@ -25,14 +25,32 @@
#include "android/os/BnUpdateEngine.h"
#include "android/os/IUpdateEngineCallback.h"
+#include "update_engine/daemon_state_android.h"
+#include "update_engine/service_observer_interface.h"
namespace chromeos_update_engine {
-class BinderUpdateEngineAndroidService : public android::os::BnUpdateEngine {
+class BinderUpdateEngineAndroidService : public android::os::BnUpdateEngine,
+ public ServiceObserverInterface {
public:
- BinderUpdateEngineAndroidService() = default;
+ BinderUpdateEngineAndroidService(DaemonStateAndroid* daemon_state);
~BinderUpdateEngineAndroidService() override = default;
+ const char* ServiceName() const {
+ return "android.os.UpdateEngineService";
+ }
+
+ // ServiceObserverInterface overrides.
+ void SendStatusUpdate(int64_t last_checked_time,
+ double progress,
+ update_engine::UpdateStatus status,
+ const std::string& new_version,
+ int64_t new_size) override;
+
+ // Channel tracking changes are ignored.
+ void SendChannelChangeUpdate(const std::string& tracking_channel) override {}
+
+ // android::os::BnUpdateEngine overrides.
android::binder::Status applyPayload(
const android::String16& url,
const std::vector<android::String16>& header_kv_pairs) override;