blob: b059f9a24b4585790c12c26fe6cff1d1e7ef40c1 [file] [log] [blame]
Connor O'Briencd0d29d2016-10-10 14:41:35 -07001#define LOG_TAG "android.hardware.boot@1.0-service"
2#include <utils/Log.h>
3
4#include <iostream>
5#include <unistd.h>
6
7#include <android/hardware/boot/1.0/IBootControl.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
17using android::hardware::IPCThreadState;
18using android::hardware::ProcessState;
19
20using ::android::hardware::boot::V1_0::IBootControl;
21
22int main (int /* argc */, char * /* argv */ []) {
23 ALOGI("Service is starting.");
24 const char instance[] = "bootctrl";
25 ALOGI("Retrieving default implementation of instance %s.",
26 instance);
27
28 sp<IBootControl> service = IBootControl::getService(instance, true /* getStub */);
29
30 if (service.get() == nullptr) {
31 ALOGE("IBootControl::getService returned NULL, exiting");
32 return -1;
33 }
34
35 LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
36
37 ALOGI("Registering instance %s.", instance);
38 service->registerAsService(instance);
39 ALOGI("Ready.");
40
41 ProcessState::self()->setThreadPoolMaxThreadCount(0);
42 ProcessState::self()->startThreadPool();
43 IPCThreadState::self()->joinThreadPool();
44}