From 7d4ebce2d8e15260ecdbfc6b3c67df3b5a7a09b4 Mon Sep 17 00:00:00 2001 From: Martin Stjernholm Date: Tue, 18 Jun 2024 12:32:03 +0100 Subject: 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 --- libnativeloader/library_namespaces.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libnativeloader/library_namespaces.cpp') 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 GetApiDomainFromPathList(const std::string& path_list) { return result; } +// Returns true if the given path is in a partition-wide native library location, +// i.e. /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 -- cgit v1.2.3-59-g8ed1b