Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cd0d29d4 authored by Connor O'Brien's avatar Connor O'Brien
Browse files

Add android.hardware.boot_control@1.0 service.



Bug: 31864052
Change-Id: I982077d71a81c0bc8d081f0cc7e83180b97f2b87
Signed-off-by: default avatarConnor O'Brien <connoro@google.com>
parent fe25fd88
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -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)
+4 −0
Original line number Diff line number Diff line
service boot-hal-1-0 /system/bin/hw/android.hardware.boot@1.0-service
    class hal
    user system
    group system readproc
+44 −0
Original line number Diff line number Diff line
#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();
}