Merge "Dynamically load device-specific recovery UI lib." am: 9cf9b689d9
am: 75acf24207
Change-Id: I9a836dc442058856ab4dc71ccccc96029d3194cf
This commit is contained in:
+79
-6
@@ -28,6 +28,64 @@ recovery_common_cflags := \
|
|||||||
-Werror \
|
-Werror \
|
||||||
-DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)
|
-DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)
|
||||||
|
|
||||||
|
# librecovery_ui_ext (shared library)
|
||||||
|
# ===================================
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_MODULE := librecovery_ui_ext
|
||||||
|
|
||||||
|
# LOCAL_MODULE_PATH for shared libraries is unsupported in multiarch builds.
|
||||||
|
LOCAL_MULTILIB := first
|
||||||
|
|
||||||
|
ifeq ($(TARGET_IS_64_BIT),true)
|
||||||
|
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/lib64
|
||||||
|
else
|
||||||
|
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/lib
|
||||||
|
endif
|
||||||
|
|
||||||
|
LOCAL_WHOLE_STATIC_LIBRARIES := \
|
||||||
|
$(TARGET_RECOVERY_UI_LIB)
|
||||||
|
|
||||||
|
LOCAL_SHARED_LIBRARIES := \
|
||||||
|
libbase \
|
||||||
|
liblog \
|
||||||
|
librecovery_ui
|
||||||
|
|
||||||
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
|
||||||
|
# librecovery_ui (shared library)
|
||||||
|
# ===============================
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
LOCAL_SRC_FILES := \
|
||||||
|
device.cpp \
|
||||||
|
screen_ui.cpp \
|
||||||
|
ui.cpp \
|
||||||
|
vr_ui.cpp \
|
||||||
|
wear_ui.cpp
|
||||||
|
|
||||||
|
LOCAL_MODULE := librecovery_ui
|
||||||
|
|
||||||
|
LOCAL_CFLAGS := $(recovery_common_cflags)
|
||||||
|
|
||||||
|
LOCAL_MULTILIB := first
|
||||||
|
|
||||||
|
ifeq ($(TARGET_IS_64_BIT),true)
|
||||||
|
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/lib64
|
||||||
|
else
|
||||||
|
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/lib
|
||||||
|
endif
|
||||||
|
|
||||||
|
LOCAL_STATIC_LIBRARIES := \
|
||||||
|
libminui \
|
||||||
|
libotautil \
|
||||||
|
|
||||||
|
LOCAL_SHARED_LIBRARIES := \
|
||||||
|
libbase \
|
||||||
|
libpng \
|
||||||
|
libz \
|
||||||
|
|
||||||
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
|
||||||
# librecovery_ui (static library)
|
# librecovery_ui (static library)
|
||||||
# ===============================
|
# ===============================
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
@@ -40,12 +98,16 @@ LOCAL_SRC_FILES := \
|
|||||||
|
|
||||||
LOCAL_MODULE := librecovery_ui
|
LOCAL_MODULE := librecovery_ui
|
||||||
|
|
||||||
|
LOCAL_CFLAGS := $(recovery_common_cflags)
|
||||||
|
|
||||||
LOCAL_STATIC_LIBRARIES := \
|
LOCAL_STATIC_LIBRARIES := \
|
||||||
libminui \
|
libminui \
|
||||||
libotautil \
|
libotautil \
|
||||||
libbase
|
|
||||||
|
|
||||||
LOCAL_CFLAGS := $(recovery_common_cflags)
|
LOCAL_SHARED_LIBRARIES := \
|
||||||
|
libbase \
|
||||||
|
libpng \
|
||||||
|
libz \
|
||||||
|
|
||||||
include $(BUILD_STATIC_LIBRARY)
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
|
||||||
@@ -63,11 +125,9 @@ health_hal_static_libraries := \
|
|||||||
libbatterymonitor
|
libbatterymonitor
|
||||||
|
|
||||||
librecovery_static_libraries := \
|
librecovery_static_libraries := \
|
||||||
$(TARGET_RECOVERY_UI_LIB) \
|
|
||||||
libbootloader_message \
|
libbootloader_message \
|
||||||
libfusesideload \
|
libfusesideload \
|
||||||
libminadbd \
|
libminadbd \
|
||||||
librecovery_ui \
|
|
||||||
libminui \
|
libminui \
|
||||||
libverifier \
|
libverifier \
|
||||||
libotautil \
|
libotautil \
|
||||||
@@ -125,8 +185,6 @@ LOCAL_SRC_FILES := \
|
|||||||
|
|
||||||
LOCAL_MODULE := recovery
|
LOCAL_MODULE := recovery
|
||||||
|
|
||||||
LOCAL_FORCE_STATIC_EXECUTABLE := true
|
|
||||||
|
|
||||||
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin
|
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/bin
|
||||||
|
|
||||||
# Cannot link with LLD: undefined symbol: UsbNoPermissionsLongHelpText
|
# Cannot link with LLD: undefined symbol: UsbNoPermissionsLongHelpText
|
||||||
@@ -137,8 +195,12 @@ LOCAL_CFLAGS := $(recovery_common_cflags)
|
|||||||
|
|
||||||
LOCAL_STATIC_LIBRARIES := \
|
LOCAL_STATIC_LIBRARIES := \
|
||||||
librecovery \
|
librecovery \
|
||||||
|
librecovery_ui_default \
|
||||||
$(librecovery_static_libraries)
|
$(librecovery_static_libraries)
|
||||||
|
|
||||||
|
LOCAL_SHARED_LIBRARIES := \
|
||||||
|
librecovery_ui \
|
||||||
|
|
||||||
LOCAL_HAL_STATIC_LIBRARIES := libhealthd
|
LOCAL_HAL_STATIC_LIBRARIES := libhealthd
|
||||||
|
|
||||||
LOCAL_REQUIRED_MODULES := \
|
LOCAL_REQUIRED_MODULES := \
|
||||||
@@ -167,6 +229,17 @@ LOCAL_REQUIRED_MODULES += \
|
|||||||
recovery-refresh
|
recovery-refresh
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
LOCAL_REQUIRED_MODULES += \
|
||||||
|
librecovery_ui_ext
|
||||||
|
|
||||||
|
# TODO(b/110380063): Explicitly install the following shared libraries to recovery, until `recovery`
|
||||||
|
# module is built with Soong (with `recovery: true` flag).
|
||||||
|
LOCAL_REQUIRED_MODULES += \
|
||||||
|
libbase.recovery \
|
||||||
|
liblog.recovery \
|
||||||
|
libpng.recovery \
|
||||||
|
libz.recovery \
|
||||||
|
|
||||||
include $(BUILD_EXECUTABLE)
|
include $(BUILD_EXECUTABLE)
|
||||||
|
|
||||||
include \
|
include \
|
||||||
|
|||||||
@@ -119,8 +119,12 @@ class Device {
|
|||||||
std::unique_ptr<RecoveryUI> ui_;
|
std::unique_ptr<RecoveryUI> ui_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Disable name mangling, as this function will be loaded via dlsym(3).
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
// The device-specific library must define this function (or the default one will be used, if there
|
// The device-specific library must define this function (or the default one will be used, if there
|
||||||
// is no device-specific library). It returns the Device object that recovery should use.
|
// is no device-specific library). It returns the Device object that recovery should use.
|
||||||
Device* make_device();
|
Device* make_device();
|
||||||
|
}
|
||||||
|
|
||||||
#endif // _DEVICE_H
|
#endif // _DEVICE_H
|
||||||
|
|||||||
+27
-1
@@ -14,6 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <dlfcn.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
@@ -329,7 +330,32 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
printf("locale is [%s]\n", locale.c_str());
|
printf("locale is [%s]\n", locale.c_str());
|
||||||
|
|
||||||
Device* device = make_device();
|
static constexpr const char* kDefaultLibRecoveryUIExt = "librecovery_ui_ext.so";
|
||||||
|
// Intentionally not calling dlclose(3) to avoid potential gotchas (e.g. `make_device` may have
|
||||||
|
// handed out pointers to code or static [or thread-local] data and doesn't collect them all back
|
||||||
|
// in on dlclose).
|
||||||
|
void* librecovery_ui_ext = dlopen(kDefaultLibRecoveryUIExt, RTLD_NOW);
|
||||||
|
|
||||||
|
using MakeDeviceType = decltype(&make_device);
|
||||||
|
MakeDeviceType make_device_func = nullptr;
|
||||||
|
if (librecovery_ui_ext == nullptr) {
|
||||||
|
printf("Failed to dlopen %s: %s\n", kDefaultLibRecoveryUIExt, dlerror());
|
||||||
|
} else {
|
||||||
|
reinterpret_cast<void*&>(make_device_func) = dlsym(librecovery_ui_ext, "make_device");
|
||||||
|
if (make_device_func == nullptr) {
|
||||||
|
printf("Failed to dlsym make_device: %s\n", dlerror());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Device* device;
|
||||||
|
if (make_device_func == nullptr) {
|
||||||
|
printf("Falling back to the default make_device() instead\n");
|
||||||
|
device = make_device();
|
||||||
|
} else {
|
||||||
|
printf("Loading make_device from %s\n", kDefaultLibRecoveryUIExt);
|
||||||
|
device = (*make_device_func)();
|
||||||
|
}
|
||||||
|
|
||||||
if (android::base::GetBoolProperty("ro.boot.quiescent", false)) {
|
if (android::base::GetBoolProperty("ro.boot.quiescent", false)) {
|
||||||
printf("Quiescent recovery mode.\n");
|
printf("Quiescent recovery mode.\n");
|
||||||
device->ResetUI(new StubRecoveryUI());
|
device->ResetUI(new StubRecoveryUI());
|
||||||
|
|||||||
+1
-1
@@ -167,10 +167,10 @@ health_hal_static_libraries := \
|
|||||||
|
|
||||||
librecovery_static_libraries := \
|
librecovery_static_libraries := \
|
||||||
librecovery \
|
librecovery \
|
||||||
$(TARGET_RECOVERY_UI_LIB) \
|
|
||||||
libbootloader_message \
|
libbootloader_message \
|
||||||
libfusesideload \
|
libfusesideload \
|
||||||
libminadbd \
|
libminadbd \
|
||||||
|
librecovery_ui_default \
|
||||||
librecovery_ui \
|
librecovery_ui \
|
||||||
libminui \
|
libminui \
|
||||||
libverifier \
|
libverifier \
|
||||||
|
|||||||
Reference in New Issue
Block a user