diff options
author | 2024-01-29 19:57:04 +0000 | |
---|---|---|
committer | 2024-02-23 16:47:38 +0000 | |
commit | 6e52064e41e6a130f1713c2f422c5bf66a5ff3b7 (patch) | |
tree | 42e65b1bff99218ce71ea1e6d6a2adb140d88ec5 /libnativeloader/library_namespaces.cpp | |
parent | f250d0b4c066d6993266b237c81515ed934fae6f (diff) |
Give full access to native libs from java libs in the same partition
(reland).
For both packages and shared java libs in system image partitions
(system, product, vendor), load native libraries from the same
partition by using the linker namespace for that partition ("default"
or "system", "product", "sphal", respectively).
This is only done for native libraries in the <partition root>/lib(64)
directories when specified by an absolute path (i.e. use
java.lang.System.load rather than loadLibrary). Otherwise it's looked
up using the classloader namespace for the package, as before.
Since only loads with absolute paths are affected, compat issues are
unlikely. However to be on the safe side it's only enabled for SDK
level 35 (VIC) and later (regardless of targetSdkVersion of the
package, because the affected code is in system image partitions).
This is based on a reland of
commit 453b9fe909c22eb0f01b3072a5213dd46aed6f45, but with a different
solution. It also extends the approach to work for vendor and product
partitions.
Test: atest libnativeloader_e2e_tests \
libnativeloader_test libnativeloader_lazy_test
Test: libnativeloader_e2e_tests on S, Sv2, T, and U platforms in CI
Bug: 237577392
Change-Id: If8b74503edfa9229b9eada73968b7d7b5c75ca10
Diffstat (limited to 'libnativeloader/library_namespaces.cpp')
-rw-r--r-- | libnativeloader/library_namespaces.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libnativeloader/library_namespaces.cpp b/libnativeloader/library_namespaces.cpp index e2b27294f9..bd186c122a 100644 --- a/libnativeloader/library_namespaces.cpp +++ b/libnativeloader/library_namespaces.cpp @@ -85,6 +85,7 @@ constexpr const char* kProductLibPath = "/product/" LIB ":/system/product/" LIB; const std::regex kVendorPathRegex("(/system)?/vendor/.*"); const std::regex kProductPathRegex("(/system)?/product/.*"); +const std::regex kSystemPathRegex("/system(_ext)?/.*"); // MUST be tested last. jobject GetParentClassLoader(JNIEnv* env, jobject class_loader) { jclass class_loader_class = env->FindClass("java/lang/ClassLoader"); @@ -103,6 +104,9 @@ ApiDomain GetApiDomainFromPath(const std::string_view path) { if (is_product_treblelized() && std::regex_match(path.begin(), path.end(), kProductPathRegex)) { return API_DOMAIN_PRODUCT; } + if (std::regex_match(path.begin(), path.end(), kSystemPathRegex)) { + return API_DOMAIN_SYSTEM; + } return API_DOMAIN_DEFAULT; } |