Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 02822377 authored by Martijn Coenen's avatar Martijn Coenen
Browse files

Remove obsolete references to IPCThreadState/ProcessState.

Threadpool can now be configured/joined if needed with
configureRpcThreadpool() / joinRpcThreadpool().

Bug: 31226656
Test: mma
Change-Id: I0d7d9924cc8c8851cc2b61ebdae906204909890e
parent 7993944e
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -16,14 +16,17 @@

#define LOG_TAG "audiohalservice"

#include <hidl/HidlTransportSupport.h>
#include <hidl/LegacySupport.h>
#include <android/hardware/audio/2.0/IDevicesFactory.h>
#include <android/hardware/audio/effect/2.0/IEffectsFactory.h>
#include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
#include <android/hardware/broadcastradio/1.0/IBroadcastRadioFactory.h>

using android::hardware::IPCThreadState;
using android::hardware::ProcessState;
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using android::hardware::registerPassthroughServiceImplementation;

using android::hardware::audio::effect::V2_0::IEffectsFactory;
using android::hardware::audio::V2_0::IDevicesFactory;
using android::hardware::soundtrigger::V2_0::ISoundTriggerHw;
@@ -31,9 +34,10 @@ using android::hardware::registerPassthroughServiceImplementation;
using android::hardware::broadcastradio::V1_0::IBroadcastRadioFactory;

int main(int /* argc */, char* /* argv */ []) {
    configureRpcThreadpool(16, true /*callerWillJoin*/);
    registerPassthroughServiceImplementation<IDevicesFactory>("audio_devices_factory");
    registerPassthroughServiceImplementation<IEffectsFactory>("audio_effects_factory");
    registerPassthroughServiceImplementation<ISoundTriggerHw>("sound_trigger.primary");
    registerPassthroughServiceImplementation<IBroadcastRadioFactory>("broadcastradio");
    return android::hardware::launchRpcServer(16);
    joinRpcThreadpool();
}
+1 −5
Original line number Diff line number Diff line
@@ -19,9 +19,8 @@
#include <android-base/logging.h>
#include <cutils/native_handle.h>
#include <cutils/properties.h>
#include <hidl/HidlTransportSupport.h>
#include <utils/threads.h>
#include <hwbinder/IPCThreadState.h>
#include <hwbinder/ProcessState.h>

#include <android/hardware/broadcastradio/1.0/IBroadcastRadioFactory.h>
#include <android/hardware/broadcastradio/1.0/IBroadcastRadio.h>
@@ -33,7 +32,6 @@
using ::android::sp;
using ::android::Mutex;
using ::android::Condition;
using ::android::hardware::ProcessState;
using ::android::hardware::Return;
using ::android::hardware::Status;
using ::android::hardware::Void;
@@ -461,8 +459,6 @@ TEST_F(BroadcastRadioHidlTest, TuneAndGetProgramInformationAndCancel) {


int main(int argc, char** argv) {
  sp<ProcessState> proc(ProcessState::self());
  ProcessState::self()->startThreadPool();
  ::testing::AddGlobalTestEnvironment(new BroadcastRadioHidlEnvironment);
  ::testing::InitGoogleTest(&argc, argv);
  int status = RUN_ALL_TESTS();
+7 −19
Original line number Diff line number Diff line
@@ -18,8 +18,7 @@

#include <unistd.h>

#include <hwbinder/IPCThreadState.h>
#include <hwbinder/ProcessState.h>
#include <hidl/HidlTransportSupport.h>
#include <utils/Errors.h>
#include <utils/StrongPointer.h>
#include <utils/Log.h>
@@ -29,9 +28,9 @@
#include "EvsDisplay.h"


// libhwbinder:
using android::hardware::IPCThreadState;
using android::hardware::ProcessState;
// libhidl:
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;

// Generated HIDL files
using android::hardware::evs::V1_0::IEvsEnumerator;
@@ -46,25 +45,14 @@ int main() {
    ALOGI("EVS Hardware Enumerator service is starting");
    android::sp<IEvsEnumerator> service = new EvsEnumerator();

    configureRpcThreadpool(1, true /* callerWillJoin */);

    // Register our service -- if somebody is already registered by our name,
    // they will be killed (their thread pool will throw an exception).
    status_t status = service->registerAsService(kEnumeratorServiceName);
    if (status == OK) {
        ALOGD("%s is ready.", kEnumeratorServiceName);

        // Set thread pool size to ensure the API is not called in parallel.
        // By setting the size to zero, the main thread will be the only one
        // serving requests once we "joinThreadPool".
        ProcessState::self()->setThreadPoolMaxThreadCount(0);

        // Note:  We don't start the thread pool because it'll add at least one (default)
        //        thread to it, which we don't want.  See b/31226656
        // ProcessState::self()->startThreadPool();

        // Send this main thread to become a permanent part of the thread pool.
        // This bumps up the thread count by 1 (from zero in this case).
        // This is not expected to return.
        IPCThreadState::self()->joinThreadPool();
        joinRpcThreadpool();
    } else {
        ALOGE("Could not register service %s (%d).", kEnumeratorServiceName, status);
    }
+5 −9
Original line number Diff line number Diff line
@@ -16,15 +16,14 @@
#define LOG_TAG "android.hardware.light@2.0-service"

#include <android/log.h>
#include <hidl/HidlTransportSupport.h>

#include "Light.h"

using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using android::sp;

// libhwbinder:
using android::hardware::IPCThreadState;
using android::hardware::ProcessState;

// Generated HIDL files
using android::hardware::light::V2_0::ILight;

@@ -32,10 +31,7 @@ int main() {
    const char instance[] = "light";

    android::sp<ILight> service = new Light();

    configureRpcThreadpool(1, true /*callerWillJoin*/);
    service->registerAsService(instance);

    ProcessState::self()->setThreadPoolMaxThreadCount(0);
    ProcessState::self()->startThreadPool();
    IPCThreadState::self()->joinThreadPool();
    joinRpcThreadpool();
}
+5 −7
Original line number Diff line number Diff line
@@ -17,14 +17,13 @@
#define LOG_TAG "HWComposerService"

#include <binder/ProcessState.h>
#include <hwbinder/IPCThreadState.h>
#include <hwbinder/ProcessState.h>
#include <hidl/HidlTransportSupport.h>
#include <utils/StrongPointer.h>
#include "Hwc.h"

using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using android::sp;
using android::hardware::IPCThreadState;
using android::hardware::ProcessState;
using android::hardware::graphics::composer::V2_1::IComposer;
using android::hardware::graphics::composer::V2_1::implementation::HIDL_FETCH_IComposer;

@@ -34,6 +33,7 @@ int main()

    ALOGI("Service is starting.");

    configureRpcThreadpool(1, true /* callerWillJoin */);
    sp<IComposer> service = HIDL_FETCH_IComposer(instance);
    if (service == nullptr) {
        ALOGI("getService returned NULL");
@@ -48,9 +48,7 @@ int main()
    android::ProcessState::self()->setThreadPoolMaxThreadCount(4);
    android::ProcessState::self()->startThreadPool();

    ProcessState::self()->setThreadPoolMaxThreadCount(0);
    ProcessState::self()->startThreadPool();
    IPCThreadState::self()->joinThreadPool();
    joinRpcThreadpool();

    return 0;
}
Loading