diff options
author | Martin Stjernholm <mast@google.com> | 2019-10-24 16:57:34 +0100 |
---|---|---|
committer | Treehugger Robot <treehugger-gerrit@google.com> | 2019-11-13 17:50:14 +0000 |
commit | 94fd9eaee76e862932dded6583a9c052e5aa9efc (patch) | |
tree | 26638e055a87784bd4d05fac144f644a64a99320 /libnativeloader/library_namespaces.cpp | |
parent | 149cddaa22a1a78e8dde179d2c33b745cb500629 (diff) |
Use a different name for shared classloader namespace, to help debugging.
Test: atest libnativeloader_test
Bug: 130388701
Change-Id: I6dbb53cac7fb7ac8fb5178611a164c83c2ab59ba
Diffstat (limited to 'libnativeloader/library_namespaces.cpp')
-rw-r--r-- | libnativeloader/library_namespaces.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/libnativeloader/library_namespaces.cpp b/libnativeloader/library_namespaces.cpp index ef979591c0..03e0814211 100644 --- a/libnativeloader/library_namespaces.cpp +++ b/libnativeloader/library_namespaces.cpp @@ -56,6 +56,14 @@ constexpr const char* kNeuralNetworksNamespaceName = "neuralnetworks"; constexpr const char* kClassloaderNamespaceName = "classloader-namespace"; // Same thing for vendor APKs. constexpr const char* kVendorClassloaderNamespaceName = "vendor-classloader-namespace"; +// If the namespace is shared then add this suffix to form +// "classloader-namespace-shared" or "vendor-classloader-namespace-shared", +// respectively. A shared namespace (cf. ANDROID_NAMESPACE_TYPE_SHARED) has +// inherited all the libraries of the parent classloader namespace, or the +// platform namespace for the main app classloader. It is used to give full +// access to the platform libraries for apps bundled in the system image, +// including their later updates installed in /data. +constexpr const char* kSharedNamespaceSuffix = "-shared"; // (http://b/27588281) This is a workaround for apps using custom classloaders and calling // System.load() with an absolute path which is outside of the classloader library search path. @@ -161,7 +169,7 @@ Result<NativeLoaderNamespace*> LibraryNamespaces::Create(JNIEnv* env, uint32_t t "There is already a namespace associated with this classloader"); std::string system_exposed_libraries = default_public_libraries(); - const char* namespace_name = kClassloaderNamespaceName; + std::string namespace_name = kClassloaderNamespaceName; bool unbundled_vendor_or_product_app = false; if ((apk_origin == APK_ORIGIN_VENDOR || (apk_origin == APK_ORIGIN_PRODUCT && target_sdk_version > 29)) && @@ -204,6 +212,12 @@ Result<NativeLoaderNamespace*> LibraryNamespaces::Create(JNIEnv* env, uint32_t t } } + if (is_shared) { + // Show in the name that the namespace was created as shared, for debugging + // purposes. + namespace_name = namespace_name + kSharedNamespaceSuffix; + } + // Create the app namespace NativeLoaderNamespace* parent_ns = FindParentNamespaceByClassLoader(env, class_loader); // Heuristic: the first classloader with non-empty library_path is assumed to |