Allow the vendor partition to be in /system/vendor.
With the changed logic in https://r.android.com/2211602 it would
otherwise be treated as a system APK and given full access to system
libraries, which would be unfortunate.
/vendor must be a separate partition starting in U, but this is
necessary for the module on S and T.
A note on tests: It's difficult to set up fixtures to test
/system/{product,vendor} paths if the device has them as symlinks to
/{product,vendor}, because it would require moving the mount points and
symlink in the other direction.
Cherry-picked from https://r.android.com/2216741.
Test: atest libnativeloader_e2e_tests
Bug: 237577392
Change-Id: I9267c008db644ebe38f6215d3b692b98dd88ee34
Merged-In: I9267c008db644ebe38f6215d3b692b98dd88ee34
diff --git a/libnativeloader/library_namespaces.cpp b/libnativeloader/library_namespaces.cpp
index 4fbf798..f3c93a0 100644
--- a/libnativeloader/library_namespaces.cpp
+++ b/libnativeloader/library_namespaces.cpp
@@ -81,19 +81,22 @@
constexpr const char* kAlwaysPermittedDirectories = "/data:/mnt/expand";
constexpr const char* kVendorLibPath = "/vendor/" LIB;
+// TODO(mast): It's unlikely that both paths are necessary for kProductLibPath
+// below, because they can't be two separate directories - either one has to be
+// a symlink to the other.
constexpr const char* kProductLibPath = "/product/" LIB ":/system/product/" LIB;
constexpr const char* kSystemLibPath = "/system/" LIB ":/system_ext/" LIB;
-const std::regex kVendorDexPathRegex("(^|:)/vendor/");
+const std::regex kVendorDexPathRegex("(^|:)(/system)?/vendor/");
const std::regex kProductDexPathRegex("(^|:)(/system)?/product/");
const std::regex kSystemDexPathRegex("(^|:)/system(_ext)?/"); // MUST be tested last.
// Define origin partition of APK
using ApkOrigin = enum {
APK_ORIGIN_DEFAULT = 0,
- APK_ORIGIN_VENDOR = 1,
+ APK_ORIGIN_VENDOR = 1, // Includes both /vendor and /system/vendor
APK_ORIGIN_PRODUCT = 2, // Includes both /product and /system/product
- APK_ORIGIN_SYSTEM = 3, // Includes both /system and /system_ext but not /system/product
+ APK_ORIGIN_SYSTEM = 3, // Includes both /system and /system_ext but not /system/{vendor,product}
};
jobject GetParentClassLoader(JNIEnv* env, jobject class_loader) {