diff options
author | 2024-06-18 12:32:03 +0100 | |
---|---|---|
committer | 2024-06-19 16:21:05 +0000 | |
commit | 7d4ebce2d8e15260ecdbfc6b3c67df3b5a7a09b4 (patch) | |
tree | c673c29bd85499256223001213cc42f609cf8c94 /libnativeloader/library_namespaces.cpp | |
parent | b8d63dfa69260d79fa254c29ae432c16756fa73a (diff) |
Recognise system/system_ext as a system image partition path.
Also move the regex used for that next to the other partition regex'es
for visibility, and add some unit tests.
Test: atest libnativeloader_tests libnativeloader_e2e_tests
on mokey_go32
Bug: 346515837
Change-Id: I30a85678e0d3c45645d6f089f5f1d92e1360e8bf
Diffstat (limited to 'libnativeloader/library_namespaces.cpp')
-rw-r--r-- | libnativeloader/library_namespaces.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libnativeloader/library_namespaces.cpp b/libnativeloader/library_namespaces.cpp index e0f3d6af8c..7aa14080ce 100644 --- a/libnativeloader/library_namespaces.cpp +++ b/libnativeloader/library_namespaces.cpp @@ -86,6 +86,8 @@ 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. +const std::regex kPartitionNativeLibPathRegex( + "/(system|(system/)?(system_ext|vendor|product))/lib(64)?/.*"); jobject GetParentClassLoader(JNIEnv* env, jobject class_loader) { jclass class_loader_class = env->FindClass("java/lang/ClassLoader"); @@ -138,6 +140,12 @@ Result<ApiDomain> GetApiDomainFromPathList(const std::string& path_list) { return result; } +// Returns true if the given path is in a partition-wide native library location, +// i.e. <partition root>/lib(64). +bool IsPartitionNativeLibPath(const std::string& path) { + return std::regex_match(path, kPartitionNativeLibPathRegex); +} + void LibraryNamespaces::Initialize() { // Once public namespace is initialized there is no // point in running this code - it will have no effect |