Add triggerPostinstall API to IUpdateEngine.aidl
Test: th
Bug: 377557752
Change-Id: I8cad42ec0eb1d6e359229555fd8cfd3517a69137
diff --git a/aosp/binder_service_android.cc b/aosp/binder_service_android.cc
index 37df9a5..ec9ea6e 100644
--- a/aosp/binder_service_android.cc
+++ b/aosp/binder_service_android.cc
@@ -24,6 +24,7 @@
#include <utils/String8.h>
#include "update_engine/aosp/binder_service_android_common.h"
+#include "update_engine/common/error_code.h"
using android::binder::Status;
using android::os::IUpdateEngineCallback;
@@ -254,4 +255,14 @@
return Status::ok();
}
+Status BinderUpdateEngineAndroidService::triggerPostinstall(
+ const ::android::String16& partition) {
+ Error error;
+ service_delegate_->TriggerPostinstall(android::String8(partition).c_str(),
+ &error);
+ if (error.error_code != ErrorCode::kSuccess)
+ return ErrorPtrToStatus(error);
+ return Status::ok();
+}
+
} // namespace chromeos_update_engine
diff --git a/aosp/binder_service_android.h b/aosp/binder_service_android.h
index f1ce6b5..25d3c4b 100644
--- a/aosp/binder_service_android.h
+++ b/aosp/binder_service_android.h
@@ -33,8 +33,9 @@
namespace chromeos_update_engine {
-class BinderUpdateEngineAndroidService : public android::os::BnUpdateEngine,
- public ServiceObserverInterface {
+class BinderUpdateEngineAndroidService final
+ : public android::os::BnUpdateEngine,
+ public ServiceObserverInterface {
public:
explicit BinderUpdateEngineAndroidService(
ServiceDelegateAndroidInterface* service_delegate);
@@ -79,6 +80,8 @@
int64_t* return_value) override;
android::binder::Status cleanupSuccessfulUpdate(
const android::sp<android::os::IUpdateEngineCallback>& callback) override;
+ ::android::binder::Status triggerPostinstall(
+ const ::android::String16& partition) override;
private:
// Remove the passed |callback| from the list of registered callbacks. Called
diff --git a/aosp/update_engine_client_android.cc b/aosp/update_engine_client_android.cc
index 4f42a59..4d01ea6 100644
--- a/aosp/update_engine_client_android.cc
+++ b/aosp/update_engine_client_android.cc
@@ -157,6 +157,11 @@
"Perform just the slow switching part of OTA. "
"Used to revert a slot switch or re-do slot switch. Valid "
"values are 'true' and 'false'");
+ DEFINE_string(
+ trigger_postinstall,
+ UNSPECIFIED_FLAG,
+ "Only run postinstall sciprts. And only run postinstall script for the "
+ "specified partition. Example: \"system\", \"product\"");
DEFINE_bool(suspend, false, "Suspend an ongoing update and exit.");
DEFINE_bool(resume, false, "Resume a suspended update.");
DEFINE_bool(cancel, false, "Cancel the ongoing update and exit.");
@@ -231,6 +236,11 @@
return ExitWhenIdle(service_->resetStatus());
}
+ if (FLAGS_trigger_postinstall != UNSPECIFIED_FLAG) {
+ return ExitWhenIdle(service_->triggerPostinstall(
+ android::String16(FLAGS_trigger_postinstall.c_str())));
+ }
+
if (FLAGS_switch_slot != UNSPECIFIED_FLAG) {
if (FLAGS_switch_slot != "true" && FLAGS_switch_slot != "false") {
LOG(ERROR) << "--switch_slot should be either true or false, got "