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.

Exempt-From-Owner-Approval: cherry-pick rvc-dev

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

Merged-In: I44b5ec028850613cb45fc3e792f43cd8e87cfd00
(cherry picked from commit 5280b5c03e)
Change-Id: I44b5ec028850613cb45fc3e792f43cd8e87cfd00
This commit is contained in:
Jiyong Park 2020-03-03 16:12:36 +09:00
parent 73ae00bbde
commit 2c608b32db

View file

@ -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 <dlfcn.h>
#endif
namespace android {
namespace base {
#if defined(__ANDROID__) && !defined(NO_LIBLOG_DLSYM)
#ifdef USE_DLSYM
const std::optional<LibLogFunctions>& GetLibLogFunctions() {
static std::optional<LibLogFunctions> liblog_functions = []() -> std::optional<LibLogFunctions> {