Merge "Refactor translateSystemPathToApexPath"
This commit is contained in:
commit
ba198d5084
|
@ -31,13 +31,14 @@
|
||||||
#include "linker_utils.h"
|
#include "linker_utils.h"
|
||||||
|
|
||||||
#if defined(__LP64__)
|
#if defined(__LP64__)
|
||||||
static const char* const kSystemLibDir = "/system/lib64";
|
#define APEX_LIB(apex, name) \
|
||||||
static const char* const kI18nApexLibDir = "/apex/com.android.i18n/lib64";
|
{ "/system/lib64/" name, "/apex/" apex "/lib64/" name }
|
||||||
#else
|
#else
|
||||||
static const char* const kSystemLibDir = "/system/lib";
|
#define APEX_LIB(apex, name) \
|
||||||
static const char* const kI18nApexLibDir = "/apex/com.android.i18n/lib";
|
{ "/system/lib/" name, "/apex/" apex "/lib/" name }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Workaround for dlopen(/system/lib(64)/<soname>) when .so is in /apex. http://b/121248172
|
// Workaround for dlopen(/system/lib(64)/<soname>) when .so is in /apex. http://b/121248172
|
||||||
/**
|
/**
|
||||||
* Translate /system path to /apex path if needed
|
* Translate /system path to /apex path if needed
|
||||||
|
@ -47,27 +48,22 @@ static const char* const kI18nApexLibDir = "/apex/com.android.i18n/lib";
|
||||||
* return true if translation is needed
|
* return true if translation is needed
|
||||||
*/
|
*/
|
||||||
bool translateSystemPathToApexPath(const char* name, std::string* out_name_to_apex) {
|
bool translateSystemPathToApexPath(const char* name, std::string* out_name_to_apex) {
|
||||||
static const char* const kSystemToArtApexLibs[] = {
|
static constexpr const char* kPathTranslationQ[][2] = {
|
||||||
"libicuuc.so",
|
APEX_LIB("com.android.i18n", "libicui18n.so"),
|
||||||
"libicui18n.so",
|
APEX_LIB("com.android.i18n", "libicuuc.so")
|
||||||
};
|
};
|
||||||
// New mapping for new apex should be added below
|
|
||||||
|
|
||||||
// Nothing to do if target sdk version is Q or above
|
if (name == nullptr) {
|
||||||
if (get_application_target_sdk_version() >= 29) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the path isn't /system/lib, there's nothing to do.
|
auto comparator = [name](auto p) { return strcmp(name, p[0]) == 0; };
|
||||||
if (name == nullptr || dirname(name) != kSystemLibDir) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* base_name = basename(name);
|
if (get_application_target_sdk_version() < __ANDROID_API_Q__) {
|
||||||
|
if (auto it =
|
||||||
for (const char* soname : kSystemToArtApexLibs) {
|
std::find_if(std::begin(kPathTranslationQ), std::end(kPathTranslationQ), comparator);
|
||||||
if (strcmp(base_name, soname) == 0) {
|
it != std::end(kPathTranslationQ)) {
|
||||||
*out_name_to_apex = std::string(kI18nApexLibDir) + "/" + base_name;
|
*out_name_to_apex = (*it)[1];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue