libhardware do not open system hal for vendor modules

For vendor modules, do not search system directory.
Also, vendor modules do not need to dlopen system hals.

Those are allowed only for system modules.

Bug: 62209000
Test: On the device, use camera, audio and bluetooth a2dp.
Change-Id: If7af82a694ef8de901adae7e9aeb187a30e50b02
diff --git a/hardware.c b/hardware.c
index 8faac07..77cfd8d 100644
--- a/hardware.c
+++ b/hardware.c
@@ -76,13 +76,19 @@
     int status = -EINVAL;
     void *handle = NULL;
     struct hw_module_t *hmi = NULL;
+#ifdef __ANDROID_VNDK__
+    const bool try_system = false;
+#else
+    const bool try_system = true;
+#endif
 
     /*
      * load the symbols resolving undefined symbols before
      * dlopen returns. Since RTLD_GLOBAL is not or'd in with
      * RTLD_NOW the external symbols will not be global
      */
-    if (strncmp(path, "/system/", 8) == 0) {
+    if (try_system &&
+        strncmp(path, HAL_LIBRARY_PATH1, strlen(HAL_LIBRARY_PATH1)) == 0) {
         /* If the library is in system partition, no need to check
          * sphal namespace. Open it with dlopen.
          */
@@ -152,10 +158,12 @@
     if (access(path, R_OK) == 0)
         return 0;
 
+#ifndef __ANDROID_VNDK__
     snprintf(path, path_len, "%s/%s.%s.so",
              HAL_LIBRARY_PATH1, name, subname);
     if (access(path, R_OK) == 0)
         return 0;
+#endif
 
     return -ENOENT;
 }