HidlBinderSupport: addPostCommandTask

Queue of tasks to be run after the binder thread
is done running.

The motivating usecase is to allow a lazy HAL to
exit when it is done with a particular call, but
this could also be used for resource deallocation
or other tasks that need to be run on the binder
thread.

This is intentionally not added for passthrough
services because there are not two separate contexts
for these.

Bug: 78509314
Test: use this to create a lazy dumpstate HAL and
   make sure it works as intended.

Change-Id: I1852c222e9b658d82b214b789aa76a8f850f7e00
diff --git a/transport/HidlBinderSupport.cpp b/transport/HidlBinderSupport.cpp
index d14887f..d884544 100644
--- a/transport/HidlBinderSupport.cpp
+++ b/transport/HidlBinderSupport.cpp
@@ -219,5 +219,9 @@
     return IPCThreadState::self()->handlePolledCommands();
 }
 
+void addPostCommandTask(const std::function<void(void)> task) {
+    IPCThreadState::self()->addPostCommandTask(task);
+}
+
 }  // namespace hardware
 }  // namespace android
diff --git a/transport/include/hidl/HidlBinderSupport.h b/transport/include/hidl/HidlBinderSupport.h
index 9759af1..1545946 100644
--- a/transport/include/hidl/HidlBinderSupport.h
+++ b/transport/include/hidl/HidlBinderSupport.h
@@ -374,6 +374,8 @@
 int setupBinderPolling();
 status_t handleBinderPoll();
 
+void addPostCommandTask(const std::function<void(void)> task);
+
 }  // namespace hardware
 }  // namespace android