Add stubs for new API triggerPostinstall

Test: th
Bug: 377557752
Change-Id: I73beaae7feebb12d944d59496db2cf8c89115e93
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_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,