IUpdateEngine.cleanupSuccessfulUpdate is async
UpdateAttempterAndroid::CleanupSuccessfulUpdate uses
CleanupPreviousUpdateAction, which is asynchronous. Hence,
the binder function needs to be asynchronous too.
Test: update_attempter_android --merge after update
Bug: 147696014
Change-Id: I0ce43db6d75a5a13a105c25645824612bd4d6be3
diff --git a/update_engine_client_android.cc b/update_engine_client_android.cc
index 7d9bc3d..1a68cf4 100644
--- a/update_engine_client_android.cc
+++ b/update_engine_client_android.cc
@@ -80,6 +80,7 @@
android::sp<android::os::IUpdateEngine> service_;
android::sp<android::os::BnUpdateEngineCallback> callback_;
+ android::sp<android::os::BnUpdateEngineCallback> cleanup_callback_;
brillo::BinderWatcher binder_watcher_;
};
@@ -226,13 +227,14 @@
}
if (FLAGS_merge) {
- int32_t ret = 0;
- Status status = service_->cleanupSuccessfulUpdate(&ret);
- if (status.isOk()) {
- LOG(INFO) << "CleanupSuccessfulUpdate exits with "
- << utils::ErrorCodeToString(static_cast<ErrorCode>(ret));
+ // Register a callback object with the service.
+ cleanup_callback_ = new UECallback(this);
+ Status status = service_->cleanupSuccessfulUpdate(cleanup_callback_);
+ if (!status.isOk()) {
+ LOG(ERROR) << "Failed to call cleanupSuccessfulUpdate.";
+ return ExitWhenIdle(status);
}
- return ExitWhenIdle(status);
+ keep_running = true;
}
if (FLAGS_follow) {