Fix wifi/bluetooth threadpool usage. am: 4faa7f5b27 am: 7699b7d666
am: 5d85b41fee
Change-Id: I986b9624589e670a7dc48d4906d9b0e4c4b2f8d6
diff --git a/bluetooth/1.0/vts/functional/bluetooth_hidl_hal_test.cpp b/bluetooth/1.0/vts/functional/bluetooth_hidl_hal_test.cpp
index b05e22b..2a4bbdd 100644
--- a/bluetooth/1.0/vts/functional/bluetooth_hidl_hal_test.cpp
+++ b/bluetooth/1.0/vts/functional/bluetooth_hidl_hal_test.cpp
@@ -21,7 +21,6 @@
#include <android/hardware/bluetooth/1.0/IBluetoothHciCallbacks.h>
#include <android/hardware/bluetooth/1.0/types.h>
#include <hardware/bluetooth.h>
-#include <hwbinder/ProcessState.h>
#include <utils/Log.h>
#include <gtest/gtest.h>
@@ -128,14 +127,6 @@
bluetooth->isRemote() ? "remote" : "local");
ASSERT_NE(bluetooth, nullptr);
- // TODO(b/31748996) A client must be completely unaware of the
- // implementation details of its HAL: whether the HAL is passthrough, or
- // whether it uses HWbinder or some other transport.
- if (bluetooth->isRemote()) {
- ::android::hardware::ProcessState::self()->setThreadPoolMaxThreadCount(1);
- ::android::hardware::ProcessState::self()->startThreadPool();
- }
-
bluetooth_cb = new BluetoothHciCallbacks(*this);
ASSERT_NE(bluetooth_cb, nullptr);
diff --git a/wifi/1.0/default/service.cpp b/wifi/1.0/default/service.cpp
index 751e8f6..40e8b12 100644
--- a/wifi/1.0/default/service.cpp
+++ b/wifi/1.0/default/service.cpp
@@ -15,42 +15,21 @@
*/
#include <android-base/logging.h>
-#include <hwbinder/IPCThreadState.h>
-#include <hwbinder/ProcessState.h>
+#include <hidl/HidlTransportSupport.h>
#include <utils/Looper.h>
#include <utils/StrongPointer.h>
#include "wifi.h"
-using android::hardware::hidl_version;
-using android::hardware::IPCThreadState;
-using android::hardware::ProcessState;
-using android::Looper;
-
-namespace {
-int OnBinderReadReady(int /*fd*/, int /*events*/, void* /*data*/) {
- IPCThreadState::self()->handlePolledCommands();
- return 1; // continue receiving events
-}
-}
+using android::hardware::configureRpcThreadpool;
+using android::hardware::joinRpcThreadpool;
int main(int /*argc*/, char** argv) {
android::base::InitLogging(argv,
android::base::LogdLogger(android::base::SYSTEM));
LOG(INFO) << "wifi_hal_legacy is starting up...";
- // Setup binder
- int binder_fd = -1;
- ProcessState::self()->setThreadPoolMaxThreadCount(0);
- CHECK_EQ(IPCThreadState::self()->setupPolling(&binder_fd), android::NO_ERROR)
- << "Failed to initialize binder polling";
- CHECK_GE(binder_fd, 0) << "Invalid binder FD: " << binder_fd;
-
- // Setup looper
- android::sp<Looper> looper = Looper::prepare(0 /* no options */);
- CHECK(looper->addFd(
- binder_fd, 0, Looper::EVENT_INPUT, OnBinderReadReady, nullptr))
- << "Failed to watch binder FD";
+ configureRpcThreadpool(1, true /* callerWillJoin */);
// Setup hwbinder service
android::sp<android::hardware::wifi::V1_0::IWifi> service =
@@ -58,10 +37,7 @@
CHECK_EQ(service->registerAsService("wifi"), android::NO_ERROR)
<< "Failed to register wifi HAL";
- // Loop
- while (looper->pollAll(-1) != Looper::POLL_ERROR) {
- // Keep polling until failure.
- }
+ joinRpcThreadpool();
LOG(INFO) << "wifi_hal_legacy is terminating...";
return 0;