Do not add system to HAL library path for vendor process.
Vendor process is not allowed to use system libs. Do not search
'system/lib[64]/hw' for vendor hal services.
Bug: 117166926
Test: Boot and check camera/wifi/bluetooth
Change-Id: I3894a6ecb359c5e2e17bd8171dad4731ac6071bd
diff --git a/base/HidlInternal.cpp b/base/HidlInternal.cpp
index 7d7e960..81b353d 100644
--- a/base/HidlInternal.cpp
+++ b/base/HidlInternal.cpp
@@ -145,7 +145,9 @@
} else {
static std::string halLibPathVndkSp = android::base::StringPrintf(
HAL_LIBRARY_PATH_VNDK_SP_FOR_VERSION, getVndkVersionStr().c_str());
+#ifndef __ANDROID_VNDK__
instrumentationLibPaths.push_back(HAL_LIBRARY_PATH_SYSTEM);
+#endif
instrumentationLibPaths.push_back(halLibPathVndkSp);
instrumentationLibPaths.push_back(HAL_LIBRARY_PATH_VENDOR);
instrumentationLibPaths.push_back(HAL_LIBRARY_PATH_ODM);
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp
index d863eca..40a7ff5 100644
--- a/transport/ServiceManagement.cpp
+++ b/transport/ServiceManagement.cpp
@@ -357,8 +357,12 @@
static std::string halLibPathVndkSp = android::base::StringPrintf(
HAL_LIBRARY_PATH_VNDK_SP_FOR_VERSION, details::getVndkVersionStr().c_str());
- std::vector<std::string> paths = {HAL_LIBRARY_PATH_ODM, HAL_LIBRARY_PATH_VENDOR,
- halLibPathVndkSp, HAL_LIBRARY_PATH_SYSTEM};
+ std::vector<std::string> paths = {
+ HAL_LIBRARY_PATH_ODM, HAL_LIBRARY_PATH_VENDOR, halLibPathVndkSp,
+#ifndef __ANDROID_VNDK__
+ HAL_LIBRARY_PATH_SYSTEM,
+#endif
+ };
#ifdef LIBHIDL_TARGET_DEBUGGABLE
const char* env = std::getenv("TREBLE_TESTING_OVERRIDE");
@@ -486,11 +490,21 @@
HAL_LIBRARY_PATH_VNDK_SP_32BIT_FOR_VERSION, details::getVndkVersionStr().c_str());
static std::vector<std::pair<Arch, std::vector<const char*>>> sAllPaths{
{Arch::IS_64BIT,
- {HAL_LIBRARY_PATH_ODM_64BIT, HAL_LIBRARY_PATH_VENDOR_64BIT,
- halLibPathVndkSp64.c_str(), HAL_LIBRARY_PATH_SYSTEM_64BIT}},
+ {
+ HAL_LIBRARY_PATH_ODM_64BIT, HAL_LIBRARY_PATH_VENDOR_64BIT,
+ halLibPathVndkSp64.c_str(),
+#ifndef __ANDROID_VNDK__
+ HAL_LIBRARY_PATH_SYSTEM_64BIT,
+#endif
+ }},
{Arch::IS_32BIT,
- {HAL_LIBRARY_PATH_ODM_32BIT, HAL_LIBRARY_PATH_VENDOR_32BIT,
- halLibPathVndkSp32.c_str(), HAL_LIBRARY_PATH_SYSTEM_32BIT}}};
+ {
+ HAL_LIBRARY_PATH_ODM_32BIT, HAL_LIBRARY_PATH_VENDOR_32BIT,
+ halLibPathVndkSp32.c_str(),
+#ifndef __ANDROID_VNDK__
+ HAL_LIBRARY_PATH_SYSTEM_32BIT,
+#endif
+ }}};
std::map<std::string, InstanceDebugInfo> map;
for (const auto &pair : sAllPaths) {
Arch arch = pair.first;