#include <pthread.h>
#include <errno.h>
#include <limits.h>
+#include <stdio.h>
+#include <unistd.h>
#define LOG_TAG "HAL"
-#include <utils/Log.h>
+#include <log/log.h>
+
+#include <vndksupport/linker.h>
/** Base path of the hal modules */
#if defined(__LP64__)
#define HAL_LIBRARY_PATH1 "/system/lib64/hw"
#define HAL_LIBRARY_PATH2 "/vendor/lib64/hw"
+#define HAL_LIBRARY_PATH3 "/odm/lib64/hw"
#else
#define HAL_LIBRARY_PATH1 "/system/lib/hw"
#define HAL_LIBRARY_PATH2 "/vendor/lib/hw"
+#define HAL_LIBRARY_PATH3 "/odm/lib/hw"
#endif
/**
const char *path,
const struct hw_module_t **pHmi)
{
- int status;
- void *handle;
- struct hw_module_t *hmi;
+ int status = -EINVAL;
+ void *handle = NULL;
+ struct hw_module_t *hmi = NULL;
/*
* 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
*/
- handle = dlopen(path, RTLD_NOW);
+ if (strncmp(path, "/system/", 8) == 0) {
+ /* If the library is in system partition, no need to check
+ * sphal namespace. Open it with dlopen.
+ */
+ handle = dlopen(path, RTLD_NOW);
+ } else {
+ handle = android_load_sphal_library(path, RTLD_NOW);
+ }
if (handle == NULL) {
char const *err_str = dlerror();
ALOGE("load: module=%s\n%s", path, err_str?err_str:"unknown");
const char *subname)
{
snprintf(path, path_len, "%s/%s.%s.so",
+ HAL_LIBRARY_PATH3, name, subname);
+ if (access(path, R_OK) == 0)
+ return 0;
+
+ snprintf(path, path_len, "%s/%s.%s.so",
HAL_LIBRARY_PATH2, name, subname);
if (access(path, R_OK) == 0)
return 0;
int hw_get_module_by_class(const char *class_id, const char *inst,
const struct hw_module_t **module)
{
- int i;
- char prop[PATH_MAX];
- char path[PATH_MAX];
- char name[PATH_MAX];
- char prop_name[PATH_MAX];
+ int i = 0;
+ char prop[PATH_MAX] = {0};
+ char path[PATH_MAX] = {0};
+ char name[PATH_MAX] = {0};
+ char prop_name[PATH_MAX] = {0};
+
if (inst)
snprintf(name, PATH_MAX, "%s.%s", class_id, inst);