Add /system/lib/vndk-sp/hw to search paths for HAL impls

android.hidl.memory@1.0-impl.so is vndk-sp and thus is located under
/system/lib/vndk-sp/hw instead of /system/lib/hw.

Bug: 62930720
Test: 2017 pixel builds and boots with BOARD_VNDK_VERSION on
Merged-Id: Idc4bd81eed76190097a9a60b5fd08a05800e183d
Change-Id: Idc4bd81eed76190097a9a60b5fd08a05800e183d
diff --git a/base/HidlInternal.cpp b/base/HidlInternal.cpp
index 0ff52ad..51f42f6 100644
--- a/base/HidlInternal.cpp
+++ b/base/HidlInternal.cpp
@@ -92,6 +92,7 @@
         instrumentationLibPaths.push_back(instrumentationLibPath);
     } else {
         instrumentationLibPaths.push_back(HAL_LIBRARY_PATH_SYSTEM);
+        instrumentationLibPaths.push_back(HAL_LIBRARY_PATH_VNDK_SP);
         instrumentationLibPaths.push_back(HAL_LIBRARY_PATH_VENDOR);
         instrumentationLibPaths.push_back(HAL_LIBRARY_PATH_ODM);
     }
diff --git a/base/include/hidl/HidlInternal.h b/base/include/hidl/HidlInternal.h
index 2a86c9e..e9c628b 100644
--- a/base/include/hidl/HidlInternal.h
+++ b/base/include/hidl/HidlInternal.h
@@ -107,18 +107,22 @@
 };
 
 #define HAL_LIBRARY_PATH_SYSTEM_64BIT "/system/lib64/hw/"
+#define HAL_LIBRARY_PATH_VNDK_SP_64BIT "/system/lib64/vndk-sp/hw/"
 #define HAL_LIBRARY_PATH_VENDOR_64BIT "/vendor/lib64/hw/"
 #define HAL_LIBRARY_PATH_ODM_64BIT    "/odm/lib64/hw/"
 #define HAL_LIBRARY_PATH_SYSTEM_32BIT "/system/lib/hw/"
+#define HAL_LIBRARY_PATH_VNDK_SP_32BIT "/system/lib/vndk-sp/hw/"
 #define HAL_LIBRARY_PATH_VENDOR_32BIT "/vendor/lib/hw/"
 #define HAL_LIBRARY_PATH_ODM_32BIT    "/odm/lib/hw/"
 
 #if defined(__LP64__)
 #define HAL_LIBRARY_PATH_SYSTEM HAL_LIBRARY_PATH_SYSTEM_64BIT
+#define HAL_LIBRARY_PATH_VNDK_SP HAL_LIBRARY_PATH_VNDK_SP_64BIT
 #define HAL_LIBRARY_PATH_VENDOR HAL_LIBRARY_PATH_VENDOR_64BIT
 #define HAL_LIBRARY_PATH_ODM    HAL_LIBRARY_PATH_ODM_64BIT
 #else
 #define HAL_LIBRARY_PATH_SYSTEM HAL_LIBRARY_PATH_SYSTEM_32BIT
+#define HAL_LIBRARY_PATH_VNDK_SP HAL_LIBRARY_PATH_VNDK_SP_32BIT
 #define HAL_LIBRARY_PATH_VENDOR HAL_LIBRARY_PATH_VENDOR_32BIT
 #define HAL_LIBRARY_PATH_ODM    HAL_LIBRARY_PATH_ODM_32BIT
 #endif
@@ -171,9 +175,10 @@
     // libraries and registers the instrumentation callback functions.
     //
     // The instrumentation libraries should be stored under any of the following
-    // directories: HAL_LIBRARY_PATH_SYSTEM, HAL_LIBRARY_PATH_VENDOR and
-    // HAL_LIBRARY_PATH_ODM. The name of instrumentation libraries should
-    // follow pattern: ^profilerPrefix(.*).profiler.so$
+    // directories: HAL_LIBRARY_PATH_SYSTEM, HAL_LIBRARY_PATH_VNDK_SP,
+    // HAL_LIBRARY_PATH_VENDOR and HAL_LIBRARY_PATH_ODM.
+    // The name of instrumentation libraries should follow pattern:
+    // ^profilerPrefix(.*).profiler.so$
     //
     // Each instrumentation library is expected to implement the instrumentation
     // function called HIDL_INSTRUMENTATION_FUNCTION.
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp
index feb1254..5ed3220 100644
--- a/transport/ServiceManagement.cpp
+++ b/transport/ServiceManagement.cpp
@@ -283,7 +283,7 @@
         dlerror(); // clear
 
         std::vector<std::string> paths = {HAL_LIBRARY_PATH_ODM, HAL_LIBRARY_PATH_VENDOR,
-                                          HAL_LIBRARY_PATH_SYSTEM};
+                                          HAL_LIBRARY_PATH_VNDK_SP, HAL_LIBRARY_PATH_SYSTEM};
 #ifdef LIBHIDL_TARGET_DEBUGGABLE
         const char* env = std::getenv("TREBLE_TESTING_OVERRIDE");
         const bool trebleTestingOverride = env && !strcmp(env, "true");
@@ -403,14 +403,13 @@
     Return<void> debugDump(debugDump_cb _hidl_cb) override {
         using Arch = ::android::hidl::base::V1_0::DebugInfo::Architecture;
         using std::literals::string_literals::operator""s;
-        static std::vector<std::pair<Arch, std::vector<const char *>>> sAllPaths{
-            {Arch::IS_64BIT, {HAL_LIBRARY_PATH_ODM_64BIT,
-                                      HAL_LIBRARY_PATH_VENDOR_64BIT,
-                                      HAL_LIBRARY_PATH_SYSTEM_64BIT}},
-            {Arch::IS_32BIT, {HAL_LIBRARY_PATH_ODM_32BIT,
-                                      HAL_LIBRARY_PATH_VENDOR_32BIT,
-                                      HAL_LIBRARY_PATH_SYSTEM_32BIT}}
-        };
+        static std::vector<std::pair<Arch, std::vector<const char*>>> sAllPaths{
+            {Arch::IS_64BIT,
+             {HAL_LIBRARY_PATH_ODM_64BIT, HAL_LIBRARY_PATH_VENDOR_64BIT,
+              HAL_LIBRARY_PATH_VNDK_SP_64BIT, HAL_LIBRARY_PATH_SYSTEM_64BIT}},
+            {Arch::IS_32BIT,
+             {HAL_LIBRARY_PATH_ODM_32BIT, HAL_LIBRARY_PATH_VENDOR_32BIT,
+              HAL_LIBRARY_PATH_VNDK_SP_32BIT, HAL_LIBRARY_PATH_SYSTEM_32BIT}}};
         std::map<std::string, InstanceDebugInfo> map;
         for (const auto &pair : sAllPaths) {
             Arch arch = pair.first;