From 5280b5c03ee1dc4bc60a579626190dcbcbd9849a Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Tue, 3 Mar 2020 16:12:36 +0900 Subject: [PATCH] libbase uses liblog symbols via dlsym when it is built for APEX libbase is a popular library that is used by many APEXes either directly or transitively. It is being used by several Mainline modules that were launched with Q, in which case everything in the APEX - including libbase - shouldn't use new APIs that are added post Q, i.e. R. libbase however is using a few new R symbols from liblog, and this is preventing those Q-launching Mainline modules that are built in R source tree from being installed to Q devices. Fortunately, the dependencies to the new R symbols are guarded with a flag; when the existence of the symbols are not guaranteed, it uses dlsym. This change fixes the aforementioned problem by turning on the flag also when libbase is built for an APEX. Bug: 149569129 Test: TARGET_BUILD_APPS=com.android.media vendor/google/build/build_mainline_modules.sh adb install --staged out/dist/mainline_modules_arm64/com.android.media.apex adb reboot The APEX is installed and mediaextractor process doesn't crash Change-Id: I44b5ec028850613cb45fc3e792f43cd8e87cfd00 --- base/liblog_symbols.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/base/liblog_symbols.cpp b/base/liblog_symbols.cpp index d5dfcd28b..8d5917907 100644 --- a/base/liblog_symbols.cpp +++ b/base/liblog_symbols.cpp @@ -16,14 +16,20 @@ #include "liblog_symbols.h" -#if defined(__ANDROID__) && !defined(NO_LIBLOG_DLSYM) +#if defined(__ANDROID__) +#if !defined(NO_LIBLOG_DLSYM) || defined(__ANDROID_APEX__) +#define USE_DLSYM +#endif +#endif + +#ifdef USE_DLSYM #include #endif namespace android { namespace base { -#if defined(__ANDROID__) && !defined(NO_LIBLOG_DLSYM) +#ifdef USE_DLSYM const std::optional& GetLibLogFunctions() { static std::optional liblog_functions = []() -> std::optional {