blob: 8952052c316d9a54d36b5a33e42d77763b032a20 [file] [log] [blame]
Iliyan Malchev3db0f602016-09-26 09:57:20 -07001#define LOG_TAG "android.hardware.nfc@1.0-service"
2#include <utils/Log.h>
3
4#include <iostream>
5#include <unistd.h>
6
7#include <android/hardware/nfc/1.0/INfc.h>
8
9#include <hidl/IServiceManager.h>
10#include <hwbinder/IPCThreadState.h>
11#include <hwbinder/ProcessState.h>
12#include <utils/Errors.h>
13#include <utils/StrongPointer.h>
14
15using android::sp;
16
17// libhwbinder:
18using android::hardware::IPCThreadState;
19using android::hardware::ProcessState;
20
21// Generated HIDL files
22using android::hardware::nfc::V1_0::INfc;
23
24int main() {
25 ALOGI("Service is starting.");
26 const char instance[] = "nfc_nci";
27 ALOGI("Retrieving default implementation of instance %s.",
28 instance);
29 android::sp<INfc> service = INfc::getService(instance, true);
30 if (service.get() == nullptr) {
31 ALOGE("INfc::getService returned NULL, exiting");
32 return -1;
33 }
34 ALOGI("Default implementation using %s is %s",
35 instance, (service->isRemote() ? "REMOTE" : "LOCAL"));
36 LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
37 ALOGI("Registering instance %s.", instance);
38 service->registerAsService("nfc_nci");
39 ALOGI("Ready.");
40
41 ProcessState::self()->setThreadPoolMaxThreadCount(0);
42 ProcessState::self()->startThreadPool();
43 IPCThreadState::self()->joinThreadPool();
44}