diff options
| author | Connor O'Brien <connoro@google.com> | 2018-09-28 12:53:02 -0700 |
|---|---|---|
| committer | Connor O'Brien <connoro@google.com> | 2018-10-19 12:21:13 -0700 |
| commit | 3847ffcc0eaefbd197eb13a930fca75862d5f722 (patch) | |
| tree | b369fb34a476239c654dd5973e841da2d3981697 /boot/1.0/default/BootControl.cpp | |
| parent | 591171a65982b3df98dba4d928f18e8837c238d0 (diff) | |
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/1.0/default/BootControl.cpp')
| -rw-r--r-- | boot/1.0/default/BootControl.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/boot/1.0/default/BootControl.cpp b/boot/1.0/default/BootControl.cpp index 9a900767d..e36407fe2 100644 --- a/boot/1.0/default/BootControl.cpp +++ b/boot/1.0/default/BootControl.cpp @@ -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 |
