From 8f30cfc41b95138651d44e11ee25db250a053cf6 Mon Sep 17 00:00:00 2001 From: Justin Yun Date: Thu, 30 Nov 2017 16:45:16 +0900 Subject: [PATCH] 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 --- hardware.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hardware.c b/hardware.c index 8faac074f..77cfd8d5c 100644 --- a/hardware.c +++ b/hardware.c @@ -76,13 +76,19 @@ static int load(const char *id, 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 @@ static int hw_module_exists(char *path, size_t path_len, const char *name, 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; }