Snap for 12673321 from b12a6c036d1c2a88ee4333197eb2cdde901be149 to 25Q1-release
Change-Id: I45e2d7635da3e7444dd5410da4a78bbb090db358
diff --git a/Android.bp b/Android.bp
index 962a9a7..dd9b02e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -185,7 +185,7 @@
// The payload application component and common dependencies.
cc_defaults {
name: "libpayload_consumer_exports_defaults",
- defaults: ["update_metadata-protos_exports",],
+ defaults: ["update_metadata-protos_exports"],
static_libs: [
"libxz",
@@ -217,17 +217,17 @@
cc_defaults {
name: "libpayload_consumer_exports",
defaults: [
- "libpayload_consumer_exports_defaults"
+ "libpayload_consumer_exports_defaults",
],
- static_libs: ["update_metadata-protos",],
+ static_libs: ["update_metadata-protos"],
}
cc_defaults {
name: "libpayload_consumer_exports_proto-full",
defaults: [
- "libpayload_consumer_exports_defaults"
+ "libpayload_consumer_exports_defaults",
],
- static_libs: ["update_metadata-protos-full",],
+ static_libs: ["update_metadata-protos-full"],
}
cc_defaults {
@@ -312,7 +312,7 @@
export_generated_headers: ["statslog_ue.h"],
shared_libs: [
"libstatssocket",
- ]
+ ],
}
genrule {
@@ -338,7 +338,7 @@
// A BootControl class implementation using Android's HIDL boot_control HAL.
cc_defaults {
name: "libupdate_engine_boot_control_exports_defaults",
- defaults: ["update_metadata-protos_exports",],
+ defaults: ["update_metadata-protos_exports"],
static_libs: [
"libcutils",
@@ -371,7 +371,7 @@
exclude_static_libs: [
"libfs_mgr_binder",
"libsnapshot_static",
- "libstatslog_ue"
+ "libstatslog_ue",
],
},
},
@@ -385,7 +385,7 @@
static_libs: [
"libpayload_consumer",
"update_metadata-protos",
- ]
+ ],
}
cc_defaults {
@@ -396,7 +396,7 @@
static_libs: [
"libpayload_consumer_proto-full",
"update_metadata-protos-full",
- ]
+ ],
}
cc_defaults {
@@ -469,7 +469,7 @@
"libbrillo-binder",
"libcurl",
"libcutils",
- "libupdate_engine_stable-V2-cpp",
+ "libupdate_engine_stable-V3-cpp",
"liblog",
"libssl",
"libstatssocket",
@@ -565,7 +565,7 @@
defaults: [
"libupdate_engine_android_defaults",
"libupdate_engine_android_exports",
- ]
+ ],
}
cc_library_static {
@@ -573,7 +573,7 @@
defaults: [
"libupdate_engine_android_defaults",
"libupdate_engine_android_exports_proto-full",
- ]
+ ],
}
// update_engine (type: executable)
@@ -595,7 +595,10 @@
"otacerts",
],
- srcs: ["main.cc", "aosp/metrics_reporter_android.cc"],
+ srcs: [
+ "main.cc",
+ "aosp/metrics_reporter_android.cc",
+ ],
init_rc: ["update_engine.rc"],
}
@@ -621,7 +624,7 @@
exclude_static_libs: [
"libstatslog_ue",
- "libupdate_engine_boot_control"
+ "libupdate_engine_boot_control",
],
exclude_shared_libs: [
@@ -800,7 +803,7 @@
name: "libcow_size_estimator",
defaults: [
"ue_defaults",
- "update_metadata-protos_exports"
+ "update_metadata-protos_exports",
],
host_supported: true,
recovery_available: true,
@@ -832,7 +835,10 @@
cc_library_static {
name: "liblz4diff",
host_supported: true,
- defaults: ["ue_defaults", "liblz4diff_defaults"],
+ defaults: [
+ "ue_defaults",
+ "liblz4diff_defaults",
+ ],
srcs: [
"lz4diff/lz4diff.cc",
"lz4diff/lz4diff_compress.cc",
@@ -1021,8 +1027,8 @@
genrule {
name: "ue_unittest_erofs_imgs",
cmd: "$(in) $(location mkfs.erofs) $(location gen/erofs_empty.img) && " +
- "$(in) $(location mkfs.erofs) $(location gen/erofs.img) $(location delta_generator) && " +
- "$(in) $(location mkfs.erofs) $(location gen/erofs_new.img) $(location delta_generator) lz4hc,7",
+ "$(in) $(location mkfs.erofs) $(location gen/erofs.img) $(location delta_generator) && " +
+ "$(in) $(location mkfs.erofs) $(location gen/erofs_new.img) $(location delta_generator) lz4hc,7",
srcs: ["sample_images/generate_test_erofs_images.sh"],
out: [
"gen/erofs.img",
@@ -1324,7 +1330,7 @@
darwin: {
enabled: false,
},
- }
+ },
}
cc_binary_host {
@@ -1436,6 +1442,6 @@
cc: [
"elsk@google.com",
"zhangkelvin@google.com",
- ]
+ ],
},
}
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/binder_service_stable_android.cc b/aosp/binder_service_stable_android.cc
index 3bc7f6c..069f3ba 100644
--- a/aosp/binder_service_stable_android.cc
+++ b/aosp/binder_service_stable_android.cc
@@ -16,8 +16,6 @@
#include "update_engine/aosp/binder_service_stable_android.h"
-#include <memory>
-
#include <base/bind.h>
#include <base/logging.h>
#include <binderwrapper/binder_wrapper.h>
@@ -125,4 +123,15 @@
return true;
}
+android::binder::Status
+BinderUpdateEngineAndroidStableService::triggerPostinstall(
+ const ::android::String16& partition) {
+ Error error;
+ if (!service_delegate_->TriggerPostinstall(
+ android::String8{partition}.c_str(), &error)) {
+ return ErrorPtrToStatus(error);
+ }
+ return Status::ok();
+}
+
} // namespace chromeos_update_engine
diff --git a/aosp/binder_service_stable_android.h b/aosp/binder_service_stable_android.h
index 212afaa..2f3fa7e 100644
--- a/aosp/binder_service_stable_android.h
+++ b/aosp/binder_service_stable_android.h
@@ -19,7 +19,6 @@
#include <stdint.h>
-#include <string>
#include <vector>
#include <utils/Errors.h>
@@ -33,7 +32,7 @@
namespace chromeos_update_engine {
-class BinderUpdateEngineAndroidStableService
+class BinderUpdateEngineAndroidStableService final
: public android::os::BnUpdateEngineStable,
public ServiceObserverInterface {
public:
@@ -62,6 +61,8 @@
android::binder::Status unbind(
const android::sp<android::os::IUpdateEngineStableCallback>& callback,
bool* return_value) 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/service_delegate_android_interface.h b/aosp/service_delegate_android_interface.h
index 45c0274..c73c6de 100644
--- a/aosp/service_delegate_android_interface.h
+++ b/aosp/service_delegate_android_interface.h
@@ -68,6 +68,9 @@
const std::vector<std::string>& key_value_pair_headers,
Error* error) = 0;
+ virtual bool TriggerPostinstall(const std::string& partition,
+ Error* error) = 0;
+
// Suspend an ongoing update. Returns true if there was an update ongoing and
// it was suspended. In case of failure, it returns false and sets |error|
// accordingly.
diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc
index 9f7ec97..85f650c 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -1457,6 +1457,18 @@
processor_->StartProcessing();
}
+bool UpdateAttempterAndroid::TriggerPostinstall(const std::string& partition,
+ Error* error) {
+ if (error) {
+ return LogAndSetGenericError(
+ error,
+ __LINE__,
+ __FILE__,
+ __FUNCTION__ + std::string(" is not implemented"));
+ }
+ return false;
+}
+
void UpdateAttempterAndroid::OnCleanupProgressUpdate(double progress) {
for (auto&& callback : cleanup_previous_update_callbacks_) {
callback->OnCleanupProgressUpdate(progress);
diff --git a/aosp/update_attempter_android.h b/aosp/update_attempter_android.h
index b7851f1..eb3e29f 100644
--- a/aosp/update_attempter_android.h
+++ b/aosp/update_attempter_android.h
@@ -52,7 +52,7 @@
OTA_SUCCESSFUL,
};
-class UpdateAttempterAndroid
+class UpdateAttempterAndroid final
: public ServiceDelegateAndroidInterface,
public ActionProcessorDelegate,
public DownloadActionDelegate,
@@ -99,6 +99,7 @@
bool setShouldSwitchSlotOnReboot(const std::string& metadata_filename,
Error* error) override;
bool resetShouldSwitchSlotOnReboot(Error* error) override;
+ bool TriggerPostinstall(const std::string& partition, Error* error) override;
// ActionProcessorDelegate methods:
void ProcessingDone(const ActionProcessor* processor,
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 "
diff --git a/binder_bindings/android/os/IUpdateEngine.aidl b/binder_bindings/android/os/IUpdateEngine.aidl
index 4043b1a..7291391 100644
--- a/binder_bindings/android/os/IUpdateEngine.aidl
+++ b/binder_bindings/android/os/IUpdateEngine.aidl
@@ -76,4 +76,23 @@
* but needs reboot). DEVICE_CORRUPTED for permanent errors.
*/
void cleanupSuccessfulUpdate(IUpdateEngineCallback callback);
+ /**
+ * Run postinstall scripts for the given |partition|
+ * This allows developers to run postinstall for a partition at
+ * a time they see fit. For example, they may wish to run postinstall
+ * script when device is IDLE and charging. This method would return
+ * immediately if |partition| is empty or does not correspond to any
+ * partitions on device. |partition| is expected to be unsuffixed, for
+ * example system,product,system_ext, etc.
+ * It is allowed to call this function multiple times with the same
+ * partition. Postinstall script for that partition would get run more
+ * than once. Owners of postinstall scripts should be designed to work
+ * correctly in such cases(idempotent). Note this expectation holds even
+ * without this API, and it has been so for years.
+ * @param Name of thje partition to run postinstall scripts. Should not
+ * contain slot suffix.(e.g. system,product,system_ext)
+ *
+ * @hide
+ */
+ void triggerPostinstall(in String partition);
}