summaryrefslogtreecommitdiffstats
path: root/boot
diff options
context:
space:
mode:
authorConnor O'Brien2018-09-28 14:53:02 -0500
committerConnor O'Brien2018-10-19 14:21:13 -0500
commit3847ffcc0eaefbd197eb13a930fca75862d5f722 (patch)
treeb369fb34a476239c654dd5973e841da2d3981697 /boot
parent591171a65982b3df98dba4d928f18e8837c238d0 (diff)
downloadplatform-hardware-interfaces-3847ffcc0eaefbd197eb13a930fca75862d5f722.tar.gz
platform-hardware-interfaces-3847ffcc0eaefbd197eb13a930fca75862d5f722.tar.xz
platform-hardware-interfaces-3847ffcc0eaefbd197eb13a930fca75862d5f722.zip
Add statically linked boot HAL impl in recovery
The default Treble boot HAL implementation currently can only work in recovery on devices that specifically build their libhardware implementation as a shared library for recovery. This CL adds the option to statically link the libhardware implementation in recovery instead of finding it using hw_get_module(). This new approach allows devices that define PRODUCT_STATIC_BOOT_CONTROL_HAL to begin using the Treble HAL in recovery without requiring device-specific changes. A previous version of this CL broke some device builds by omitting libbase.recovery from LOCAL_SHARED_LIBRARIES. This version fixes that issue. Test: adb sideload succeeds Bug: 78598708 Change-Id: I1c2ef7fa59575ac7975129f7544f741459b8540e Signed-off-by: Connor O'Brien <connoro@google.com>
Diffstat (limited to 'boot')
-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