Add support for polling transport.
To remove remaining direct calls/linkage into libhwbinder.
Bug: 34388964
Test: wifi works
Change-Id: Idd3928e9a0879434cb71ab63eaca905f174e645e
diff --git a/transport/HidlBinderSupport.cpp b/transport/HidlBinderSupport.cpp
index fe1ccbc..d14887f 100644
--- a/transport/HidlBinderSupport.cpp
+++ b/transport/HidlBinderSupport.cpp
@@ -204,5 +204,20 @@
IPCThreadState::self()->joinThreadPool();
}
+int setupBinderPolling() {
+ int fd;
+ int err = IPCThreadState::self()->setupPolling(&fd);
+
+ if (err != OK) {
+ ALOGE("Failed to setup binder polling: %d (%s)", err, strerror(err));
+ }
+
+ return err == OK ? fd : -1;
+}
+
+status_t handleBinderPoll() {
+ return IPCThreadState::self()->handlePolledCommands();
+}
+
} // namespace hardware
} // namespace android
diff --git a/transport/HidlTransportSupport.cpp b/transport/HidlTransportSupport.cpp
index 1df6c38..d0871f6 100644
--- a/transport/HidlTransportSupport.cpp
+++ b/transport/HidlTransportSupport.cpp
@@ -30,6 +30,14 @@
joinBinderRpcThreadpool();
}
+int setupTransportPolling() {
+ return setupBinderPolling();
+}
+
+status_t handleTransportPoll(int /*fd*/) {
+ return handleBinderPoll();
+}
+
bool setMinSchedulerPolicy(const sp<::android::hidl::base::V1_0::IBase>& service,
int policy, int priority) {
if (service->isRemote()) {
diff --git a/transport/include/hidl/HidlBinderSupport.h b/transport/include/hidl/HidlBinderSupport.h
index 09111f4..9759af1 100644
--- a/transport/include/hidl/HidlBinderSupport.h
+++ b/transport/include/hidl/HidlBinderSupport.h
@@ -371,6 +371,8 @@
void configureBinderRpcThreadpool(size_t maxThreads, bool callerWillJoin);
void joinBinderRpcThreadpool();
+int setupBinderPolling();
+status_t handleBinderPoll();
} // namespace hardware
} // namespace android
diff --git a/transport/include/hidl/HidlTransportSupport.h b/transport/include/hidl/HidlTransportSupport.h
index 9123d6f..368c2c5 100644
--- a/transport/include/hidl/HidlTransportSupport.h
+++ b/transport/include/hidl/HidlTransportSupport.h
@@ -51,6 +51,26 @@
void joinRpcThreadpool();
/**
+ * Sets up the transport for use with (e)poll.
+ *
+ * Note that all currently supported transports can only be polled
+ * from a single thread. When poll() on the returned fd returns,
+ * the caller must call handleTransportPoll() to handle the result.
+ *
+ * @return the file descriptor to be used with (e)poll, or -1 in case of error.
+ */
+int setupTransportPolling();
+
+/**
+ * Handles transport work after poll() returns.
+ *
+ * @param fd returned from setupTransportPolling()
+ *
+ * @return OK when successful
+ */
+status_t handleTransportPoll(int fd);
+
+/**
* Sets a minimum scheduler policy for all transactions coming into this
* service.
*