#define LOG_TAG "android.hardware.light@2.0-service" #include #include #include #include #include #include #include #include #include using android::sp; // libhwbinder: using android::hardware::IPCThreadState; using android::hardware::ProcessState; // Generated HIDL files using android::hardware::light::V2_0::ILight; int main() { ALOGI("Service is starting."); const char instance[] = "light"; ALOGI("Retrieving default implementation of instance %s.", instance); android::sp service = ILight::getService(instance, true /* getStub */); if (service.get() == nullptr) { ALOGE("ILight::getService returned NULL, exiting"); return EXIT_FAILURE; } LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!"); ALOGI("Registering instance %s.", instance); service->registerAsService(instance); ALOGI("Ready."); ProcessState::self()->setThreadPoolMaxThreadCount(0); ProcessState::self()->startThreadPool(); IPCThreadState::self()->joinThreadPool(); }