diff --git a/boot/1.0/default/Android.mk b/boot/1.0/default/Android.mk index 563f1883ee..50fd1e4ac3 100644 --- a/boot/1.0/default/Android.mk +++ b/boot/1.0/default/Android.mk @@ -15,3 +15,20 @@ LOCAL_SHARED_LIBRARIES := \ android.hardware.boot@1.0 \ include $(BUILD_SHARED_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_MODULE := android.hardware.boot@1.0-service +LOCAL_INIT_RC := android.hardware.boot@1.0-service.rc +LOCAL_SRC_FILES := \ + service.cpp + +LOCAL_SHARED_LIBRARIES := \ + liblog \ + libhwbinder \ + libhardware \ + libhidl \ + libutils \ + android.hardware.boot@1.0 \ + +include $(BUILD_EXECUTABLE) diff --git a/boot/1.0/default/android.hardware.boot@1.0-service.rc b/boot/1.0/default/android.hardware.boot@1.0-service.rc new file mode 100644 index 0000000000..57c1aff31c --- /dev/null +++ b/boot/1.0/default/android.hardware.boot@1.0-service.rc @@ -0,0 +1,4 @@ +service boot-hal-1-0 /system/bin/hw/android.hardware.boot@1.0-service + class hal + user system + group system readproc 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 + +#include +#include + +#include + +#include +#include +#include +#include +#include + +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 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(); +}