Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
libhardware do not open system hal for vendor modules
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Justin Yun committed Dec 4, 2017
1 parent 49cf861 commit 8f30cfc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion hardware.c
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 8f30cfc

Please sign in to comment.