diff options
author | 2021-08-10 14:05:49 +0900 | |
---|---|---|
committer | 2021-08-17 00:49:38 +0000 | |
commit | a21b58476a530d47532af28c0f909fb9a3aedcbf (patch) | |
tree | 6ec0af4828245affb1556ce8e5249e56d3f5ded9 /libnativeloader/library_namespaces.cpp | |
parent | fb3ad7201bf2d9154862e347e960df376ac04c3c (diff) |
Define product public libraries
When /product is unbundled from the /system, /product/etc/ may not
have 'public.libraries-<companyname>.txt' to extend public libraries.
Instead, /product/etc/public.library.txt can provide public libraries
from /product.
Bug: 186055799
Test: atest libnativeloader_test
Change-Id: I8994649826657f59ac1dac655205b9704a2c67c9
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) { |