diff options
Diffstat (limited to 'libnativeloader/native_loader.cpp')
| -rw-r--r-- | libnativeloader/native_loader.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp index 927cbec67..73423a3c6 100644 --- a/libnativeloader/native_loader.cpp +++ b/libnativeloader/native_loader.cpp @@ -21,6 +21,7 @@ #ifdef __ANDROID__ #include "dlext_namespaces.h" #include "cutils/properties.h" +#define LOG_TAG "libnativeloader" #include "log/log.h" #endif @@ -58,7 +59,8 @@ class LibraryNamespaces { jobject class_loader, bool is_shared, jstring java_library_path, - jstring java_permitted_path) { + jstring java_permitted_path, + int32_t target_sdk_version) { std::string library_path; // empty string by default. if (java_library_path != nullptr) { @@ -81,7 +83,7 @@ class LibraryNamespaces { } } - if (!initialized_ && !InitPublicNamespace(library_path.c_str())) { + if (!initialized_ && !InitPublicNamespace(library_path.c_str(), target_sdk_version)) { return nullptr; } @@ -99,7 +101,7 @@ class LibraryNamespaces { nullptr, library_path.c_str(), namespace_type, - java_permitted_path != nullptr ? + !permitted_path.empty() ? permitted_path.c_str() : nullptr); @@ -192,12 +194,15 @@ class LibraryNamespaces { return true; } - bool InitPublicNamespace(const char* library_path) { + bool InitPublicNamespace(const char* library_path, int32_t target_sdk_version) { + std::string publicNativeLibraries = public_libraries_; + + UNUSED(target_sdk_version); // (http://b/25844435) - Some apps call dlopen from generated code (mono jited // code is one example) unknown to linker in which case linker uses anonymous // namespace. The second argument specifies the search path for the anonymous // namespace which is the library_path of the classloader. - initialized_ = android_init_namespaces(public_libraries_.c_str(), library_path); + initialized_ = android_init_namespaces(publicNativeLibraries.c_str(), library_path); return initialized_; } @@ -241,7 +246,8 @@ jstring CreateClassLoaderNamespace(JNIEnv* env, class_loader, is_shared, library_path, - permitted_path); + permitted_path, + target_sdk_version); if (ns == nullptr) { return env->NewStringUTF(dlerror()); } @@ -269,7 +275,7 @@ void* OpenNativeLibrary(JNIEnv* env, if (ns == nullptr) { // This is the case where the classloader was not created by ApplicationLoaders // In this case we create an isolated not-shared namespace for it. - ns = g_namespaces->Create(env, class_loader, false, library_path, nullptr); + ns = g_namespaces->Create(env, class_loader, false, library_path, nullptr, target_sdk_version); if (ns == nullptr) { return nullptr; } |
