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

Commit 2399c305 authored by Connor O'Brien's avatar Connor O'Brien Committed by android-build-merger
Browse files

Merge "Add statically linked boot HAL impl in recovery" am: e14e593d am: ee011948

am: 74e4c82d

Change-Id: I8f86942e2d76bb8234ddf812af09cfb2d8a7aa04
parents 3880628d 74e4c82d
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
# TODO(connoro): Remove this file once we eliminate existing usage of
# PRODUCT_STATIC_BOOT_CONTROL_HAL

LOCAL_PATH := $(call my-dir)

ifneq ($(strip $(PRODUCT_STATIC_BOOT_CONTROL_HAL)),)
include $(CLEAR_VARS)

LOCAL_MODULE := android.hardware.boot@1.0-impl-wrapper.recovery
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MULTILIB := first
ifeq ($(TARGET_IS_64_BIT),true)
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/hw
else
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/lib/hw
endif
LOCAL_SRC_FILES := BootControl.cpp
LOCAL_CFLAGS := -DBOOT_CONTROL_RECOVERY
LOCAL_SHARED_LIBRARIES := \
    libbase.recovery \
    liblog.recovery \
    libhidlbase.recovery \
    libhidltransport.recovery \
    libhardware.recovery \
    libutils.recovery \
    android.hardware.boot@1.0.recovery
LOCAL_STATIC_LIBRARIES := $(PRODUCT_STATIC_BOOT_CONTROL_HAL)
include $(BUILD_SHARED_LIBRARY)

endif
+21 −1
Original line number Diff line number Diff line
@@ -21,6 +21,10 @@
#include <hardware/boot_control.h>
#include "BootControl.h"

#ifdef BOOT_CONTROL_RECOVERY
extern const hw_module_t HAL_MODULE_INFO_SYM;
#endif

namespace android {
namespace hardware {
namespace boot {
@@ -92,7 +96,23 @@ Return<void> BootControl::getSuffix(uint32_t slot, getSuffix_cb _hidl_cb) {
    return Void();
}

#ifdef BOOT_CONTROL_RECOVERY
IBootControl* HIDL_FETCH_IBootControl(const char * /* hal */) {
    boot_control_module_t* module;

    // For devices that don't build a standalone libhardware bootctrl impl for recovery,
    // we simulate the hw_get_module() by accessing it from the current process directly.
    const hw_module_t* hw_module = &HAL_MODULE_INFO_SYM;
    if (!hw_module ||
        strcmp(BOOT_CONTROL_HARDWARE_MODULE_ID, hw_module->id) != 0) {
        ALOGE("Error loading boot_control HAL implementation: %d.", -EINVAL);
        return nullptr;
    }
    module = reinterpret_cast<boot_control_module_t*>(const_cast<hw_module_t*>(hw_module));
    module->init(module);
    return new BootControl(module);
}
#else
IBootControl* HIDL_FETCH_IBootControl(const char* /* hal */) {
    int ret = 0;
    boot_control_module_t* module = NULL;
@@ -106,7 +126,7 @@ IBootControl* HIDL_FETCH_IBootControl(const char* /* hal */) {
    module->init(module);
    return new BootControl(module);
}

#endif
} // namespace implementation
}  // namespace V1_0
}  // namespace boot