summaryrefslogtreecommitdiff
path: root/libnativeloader/native_loader.cpp
diff options
context:
space:
mode:
authorJiyong Park <jiyong@google.com>2020-07-02 23:17:58 +0900
committerTreehugger Robot <treehugger-gerrit@google.com>2020-07-24 10:28:24 +0000
commit14626a7c40471090745b7069310a6c6265671fc9 (patch)
treec3b0b32abe59ecd16b65168034a6675fb02a7a78 /libnativeloader/native_loader.cpp
parenta0130e8d2842a9a82e4fd4e811ee699272eb2e0b (diff)
libnativeloader understands uses-native-library tag
Previously, libnativeloader provided all the partner-provided public shared libraries to apps unconditionally. Starting from Android S, apps targeting S (or higher) get only the libs that are explicited listed as dependencies using the <uses-native-library> tag in the app manifest. The libs not listed there are not available to the app even if they are registered as public libraries. The changed behavior affects new (S+) apps. Existing apps are not affected; they still get all the libraries. The implementation is rather straightforward. The library accepts a new parameter soname_list from the framework, which is actually from the <uses-native-library> tags of the app manifest. The list is used to filter the partner-provided libraries when the target sdk is > 30. Bug: 142191088 Test: atest CtsUsesNativeLibraryTest Merged-In: I52e23dda58fc69f51451c5dbeffd0a77125c9bff (cherry picked from commit e741dfd18dcd15f002bc1db9bd6634322e4eeef8) Change-Id: I52e23dda58fc69f51451c5dbeffd0a77125c9bff
Diffstat (limited to 'libnativeloader/native_loader.cpp')
-rw-r--r--libnativeloader/native_loader.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp
index b187474c5b..64d60ea6cc 100644
--- a/libnativeloader/native_loader.cpp
+++ b/libnativeloader/native_loader.cpp
@@ -77,16 +77,17 @@ void ResetNativeLoader() {
jstring CreateClassLoaderNamespace(JNIEnv* env, int32_t target_sdk_version, jobject class_loader,
bool is_shared, jstring dex_path, jstring library_path,
- jstring permitted_path) {
+ jstring permitted_path, jstring uses_library_list) {
#if defined(ART_TARGET_ANDROID)
std::lock_guard<std::mutex> guard(g_namespaces_mutex);
auto ns = g_namespaces->Create(env, target_sdk_version, class_loader, is_shared, dex_path,
- library_path, permitted_path);
+ library_path, permitted_path, uses_library_list);
if (!ns.ok()) {
return env->NewStringUTF(ns.error().message().c_str());
}
#else
- UNUSED(env, target_sdk_version, class_loader, is_shared, dex_path, library_path, permitted_path);
+ UNUSED(env, target_sdk_version, class_loader, is_shared, dex_path, library_path, permitted_path,
+ uses_library_list);
#endif
return nullptr;
}
@@ -127,7 +128,7 @@ void* OpenNativeLibrary(JNIEnv* env, int32_t target_sdk_version, const char* pat
// In this case we create an isolated not-shared namespace for it.
Result<NativeLoaderNamespace*> isolated_ns =
g_namespaces->Create(env, target_sdk_version, class_loader, false /* is_shared */, nullptr,
- library_path, nullptr);
+ library_path, nullptr, nullptr);
if (!isolated_ns.ok()) {
*error_msg = strdup(isolated_ns.error().message().c_str());
return nullptr;