Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 1 | #include <binder/IPCThreadState.h> |
| 2 | #include <binder/IServiceManager.h> |
| 3 | #include <binder/ProcessState.h> |
Alex Vakulenko | 4fe6058 | 2017-02-02 11:35:59 -0800 | [diff] [blame^] | 4 | #include <log/log.h> |
Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 5 | |
| 6 | #include "VirtualTouchpadService.h" |
| 7 | |
| 8 | int main() { |
| 9 | ALOGI("Starting"); |
| 10 | android::dvr::VirtualTouchpad touchpad; |
| 11 | android::dvr::VirtualTouchpadService touchpad_service(touchpad); |
| 12 | const int touchpad_status = touchpad_service.Initialize(); |
| 13 | if (touchpad_status) { |
| 14 | ALOGE("virtual touchpad initialization failed: %d", touchpad_status); |
| 15 | exit(1); |
| 16 | } |
| 17 | |
| 18 | signal(SIGPIPE, SIG_IGN); |
| 19 | android::sp<android::ProcessState> ps(android::ProcessState::self()); |
| 20 | ps->setThreadPoolMaxThreadCount(4); |
| 21 | ps->startThreadPool(); |
| 22 | ps->giveThreadPoolName(); |
| 23 | |
| 24 | android::sp<android::IServiceManager> sm(android::defaultServiceManager()); |
| 25 | const android::status_t service_status = |
| 26 | sm->addService(android::String16(touchpad_service.getServiceName()), |
| 27 | &touchpad_service, false /*allowIsolated*/); |
| 28 | if (service_status != android::OK) { |
| 29 | ALOGE("virtual touchpad service not added: %d", |
| 30 | static_cast<int>(service_status)); |
| 31 | exit(2); |
| 32 | } |
| 33 | |
| 34 | android::IPCThreadState::self()->joinThreadPool(); |
| 35 | return 0; |
| 36 | } |