summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConnor O'Brien2018-10-22 16:45:29 -0500
committerGerrit Code Review2018-10-22 16:45:29 -0500
commite14e593d8fbeb2dcc3719e86bfa28bc0e3f1f585 (patch)
tree9bb22b8e234f7e28313c5adaaec2bf56242bcd0f
parent1ea726b6d7da167a3ab860ab0d912b8f89073fbd (diff)
parent3847ffcc0eaefbd197eb13a930fca75862d5f722 (diff)
downloadplatform-hardware-interfaces-e14e593d8fbeb2dcc3719e86bfa28bc0e3f1f585.tar.gz
platform-hardware-interfaces-e14e593d8fbeb2dcc3719e86bfa28bc0e3f1f585.tar.xz
platform-hardware-interfaces-e14e593d8fbeb2dcc3719e86bfa28bc0e3f1f585.zip
Merge "Add statically linked boot HAL impl in recovery"
-rw-r--r--boot/1.0/default/Android.mk30
-rw-r--r--boot/1.0/default/BootControl.cpp22
2 files changed, 51 insertions, 1 deletions
diff --git a/boot/1.0/default/Android.mk b/boot/1.0/default/Android.mk
new file mode 100644
index 00000000..7ccc4c83
--- /dev/null
+++ b/boot/1.0/default/Android.mk
@@ -0,0 +1,30 @@
1# TODO(connoro): Remove this file once we eliminate existing usage of
2# PRODUCT_STATIC_BOOT_CONTROL_HAL
3
4LOCAL_PATH := $(call my-dir)
5
6ifneq ($(strip $(PRODUCT_STATIC_BOOT_CONTROL_HAL)),)
7include $(CLEAR_VARS)
8
9LOCAL_MODULE := android.hardware.boot@1.0-impl-wrapper.recovery
10LOCAL_MODULE_CLASS := SHARED_LIBRARIES
11LOCAL_MULTILIB := first
12ifeq ($(TARGET_IS_64_BIT),true)
13LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/lib64/hw
14else
15LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/lib/hw
16endif
17LOCAL_SRC_FILES := BootControl.cpp
18LOCAL_CFLAGS := -DBOOT_CONTROL_RECOVERY
19LOCAL_SHARED_LIBRARIES := \
20 libbase.recovery \
21 liblog.recovery \
22 libhidlbase.recovery \
23 libhidltransport.recovery \
24 libhardware.recovery \
25 libutils.recovery \
26 android.hardware.boot@1.0.recovery
27LOCAL_STATIC_LIBRARIES := $(PRODUCT_STATIC_BOOT_CONTROL_HAL)
28include $(BUILD_SHARED_LIBRARY)
29
30endif
diff --git a/boot/1.0/default/BootControl.cpp b/boot/1.0/default/BootControl.cpp
index 9a900767..e36407fe 100644
--- a/boot/1.0/default/BootControl.cpp
+++ b/boot/1.0/default/BootControl.cpp
@@ -21,6 +21,10 @@
21#include <hardware/boot_control.h> 21#include <hardware/boot_control.h>
22#include "BootControl.h" 22#include "BootControl.h"
23 23
24#ifdef BOOT_CONTROL_RECOVERY
25extern const hw_module_t HAL_MODULE_INFO_SYM;
26#endif
27
24namespace android { 28namespace android {
25namespace hardware { 29namespace hardware {
26namespace boot { 30namespace boot {
@@ -92,7 +96,23 @@ Return<void> BootControl::getSuffix(uint32_t slot, getSuffix_cb _hidl_cb) {
92 return Void(); 96 return Void();
93} 97}
94 98
99#ifdef BOOT_CONTROL_RECOVERY
100IBootControl* HIDL_FETCH_IBootControl(const char * /* hal */) {
101 boot_control_module_t* module;
95 102
103 // For devices that don't build a standalone libhardware bootctrl impl for recovery,
104 // we simulate the hw_get_module() by accessing it from the current process directly.
105 const hw_module_t* hw_module = &HAL_MODULE_INFO_SYM;
106 if (!hw_module ||
107 strcmp(BOOT_CONTROL_HARDWARE_MODULE_ID, hw_module->id) != 0) {
108 ALOGE("Error loading boot_control HAL implementation: %d.", -EINVAL);
109 return nullptr;
110 }
111 module = reinterpret_cast<boot_control_module_t*>(const_cast<hw_module_t*>(hw_module));
112 module->init(module);
113 return new BootControl(module);
114}
115#else
96IBootControl* HIDL_FETCH_IBootControl(const char* /* hal */) { 116IBootControl* HIDL_FETCH_IBootControl(const char* /* hal */) {
97 int ret = 0; 117 int ret = 0;
98 boot_control_module_t* module = NULL; 118 boot_control_module_t* module = NULL;
@@ -106,7 +126,7 @@ IBootControl* HIDL_FETCH_IBootControl(const char* /* hal */) {
106 module->init(module); 126 module->init(module);
107 return new BootControl(module); 127 return new BootControl(module);
108} 128}
109 129#endif
110} // namespace implementation 130} // namespace implementation
111} // namespace V1_0 131} // namespace V1_0
112} // namespace boot 132} // namespace boot