diff options
Diffstat (limited to 'libnativeloader/library_namespaces.cpp')
-rw-r--r-- | libnativeloader/library_namespaces.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libnativeloader/library_namespaces.cpp b/libnativeloader/library_namespaces.cpp index 8b87338fba..585e98a587 100644 --- a/libnativeloader/library_namespaces.cpp +++ b/libnativeloader/library_namespaces.cpp @@ -47,7 +47,12 @@ constexpr const char* kApexPath = "/apex/"; // to use to load vendor libraries to separate namespace with controlled interface between // vendor and system namespaces. constexpr const char* kVendorNamespaceName = "sphal"; +// Similar to sphal namespace, product namespace provides some product libraries. +constexpr const char* kProductNamespaceName = "product"; + +// vndk namespace for unbundled vendor apps constexpr const char* kVndkNamespaceName = "vndk"; +// vndk_product namespace for unbundled product apps constexpr const char* kVndkProductNamespaceName = "vndk_product"; // classloader-namespace is a linker namespace that is created for the loaded @@ -374,6 +379,27 @@ Result<NativeLoaderNamespace*> LibraryNamespaces::Create(JNIEnv* env, uint32_t t } } + auto product_libs = filter_public_libraries(target_sdk_version, uses_libraries, + product_public_libraries()); + if (!product_libs.empty()) { + auto target_ns = system_ns; + if (is_product_vndk_version_defined()) { + // If ro.product.vndk.version is defined, product namespace provides the product libraries. + target_ns = NativeLoaderNamespace::GetExportedNamespace(kProductNamespaceName, is_bridged); + } + if (target_ns.ok()) { + linked = app_ns->Link(&target_ns.value(), product_libs); + if (!linked.ok()) { + return linked.error(); + } + } else { + // The linkerconfig must have a problem on defining the product namespace in the system + // section. Skip linking product namespace. This will not affect most of the apps. Only the + // apps that requires the product public libraries will fail. + ALOGW("Namespace for product libs not found: %s", target_ns.error().message().c_str()); + } + } + auto& emplaced = namespaces_.emplace_back( std::make_pair(env->NewWeakGlobalRef(class_loader), *app_ns)); if (is_main_classloader) { |