summaryrefslogtreecommitdiff
path: root/boot/1.0/default/service.cpp
diff options
context:
space:
mode:
authorConnor O'Brien <connoro@google.com>2016-10-10 14:41:35 -0700
committerConnor O'Brien <connoro@google.com>2016-10-19 14:43:36 -0700
commitcd0d29d4afd1910b584fb374265548adaf3f46ef (patch)
tree8d9a467d72212b62c971868321f2024533b38a5a /boot/1.0/default/service.cpp
parentfe25fd88c80f033470e1851dde779a49f76bae44 (diff)
Add android.hardware.boot_control@1.0 service.
Bug: 31864052 Change-Id: I982077d71a81c0bc8d081f0cc7e83180b97f2b87 Signed-off-by: Connor O'Brien <connoro@google.com>
Diffstat (limited to 'boot/1.0/default/service.cpp')
-rw-r--r--boot/1.0/default/service.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/boot/1.0/default/service.cpp b/boot/1.0/default/service.cpp
new file mode 100644
index 0000000000..b059f9a24b
--- /dev/null
+++ b/boot/1.0/default/service.cpp
@@ -0,0 +1,44 @@
+#define LOG_TAG "android.hardware.boot@1.0-service"
+#include <utils/Log.h>
+
+#include <iostream>
+#include <unistd.h>
+
+#include <android/hardware/boot/1.0/IBootControl.h>
+
+#include <hidl/IServiceManager.h>
+#include <hwbinder/IPCThreadState.h>
+#include <hwbinder/ProcessState.h>
+#include <utils/Errors.h>
+#include <utils/StrongPointer.h>
+
+using android::sp;
+
+using android::hardware::IPCThreadState;
+using android::hardware::ProcessState;
+
+using ::android::hardware::boot::V1_0::IBootControl;
+
+int main (int /* argc */, char * /* argv */ []) {
+ ALOGI("Service is starting.");
+ const char instance[] = "bootctrl";
+ ALOGI("Retrieving default implementation of instance %s.",
+ instance);
+
+ sp<IBootControl> service = IBootControl::getService(instance, true /* getStub */);
+
+ if (service.get() == nullptr) {
+ ALOGE("IBootControl::getService returned NULL, exiting");
+ return -1;
+ }
+
+ 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();
+}