Send an initial status update notification on bind().
When the client calls bind(), this patch now sends an initial status
update so the client can react to the status update that could have
been sent before it called bind().
Bug: 27108108
TEST=`update_engine_client --follow` shows the initial status.
(cherry picked from commit 0e061aebc651e041b6d1d8a3a91834feb87e0d62)
Change-Id: I4a8bd7a69054ead5e1ac144127452b64351d8082
diff --git a/binder_service_android.cc b/binder_service_android.cc
index 3c679da..e275319 100644
--- a/binder_service_android.cc
+++ b/binder_service_android.cc
@@ -45,8 +45,10 @@
update_engine::UpdateStatus status,
const std::string& /* new_version */,
int64_t /* new_size */) {
+ last_status_ = static_cast<int>(status);
+ last_progress_ = progress;
for (auto& callback : callbacks_) {
- callback->onStatusUpdate(static_cast<int>(status), progress);
+ callback->onStatusUpdate(last_status_, last_progress_);
}
}
@@ -68,6 +70,12 @@
base::Unretained(this),
base::Unretained(callback.get())));
+ // Send an status update on connection (except when no update sent so far),
+ // since the status update is oneway and we don't need to wait for the
+ // response.
+ if (last_status_ != -1)
+ callback->onStatusUpdate(last_status_, last_progress_);
+
*return_value = true;
return Status::ok();
}