main.cpp revision e4eec20f6263f4a42ae462456f60ea6c4518bb0a
1#include <binder/IPCThreadState.h>
2#include <binder/IServiceManager.h>
3#include <binder/ProcessState.h>
4#include <cutils/log.h>
5
6#include "VirtualTouchpadService.h"
7
8int 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}
37