Chromium Code Reviews| Index: third_party/hwcplus/src/hardware.c |
| diff --git a/third_party/hwcplus/src/hardware.c b/third_party/hwcplus/src/hardware.c |
| index 6713ea0107efa7f0aa0b84dfd7881535cc0b4572..4ff293d243cefae991b156e93c9925d396d82f91 100644 |
| --- a/third_party/hwcplus/src/hardware.c |
| +++ b/third_party/hwcplus/src/hardware.c |
| @@ -23,17 +23,29 @@ |
| #include <pthread.h> |
| #include <errno.h> |
| #include <limits.h> |
| +#include <stdlib.h> |
| #define LOG_TAG "HAL" |
| +#ifdef ANDROID |
| #include <utils/Log.h> |
| +#else |
| +#include <stdio.h> |
| +#include <unistd.h> |
| +#include <log/log.h> |
| +#endif |
| -/** Base path of the hal modules */ |
| #if defined(__LP64__) |
| -#define HAL_LIBRARY_PATH1 "/system/lib64/hw" |
| -#define HAL_LIBRARY_PATH2 "/vendor/lib64/hw" |
| +#define _64 "64" |
| #else |
| -#define HAL_LIBRARY_PATH1 "/system/lib/hw" |
| -#define HAL_LIBRARY_PATH2 "/vendor/lib/hw" |
| +#define _64 "" |
| +#endif |
| + |
| +/** Base path of the hal modules */ |
| +#ifndef HAL_LIBRARY_PATH1 |
| +#define HAL_LIBRARY_PATH1 "/system/lib" _64 "/hw" |
| +#endif |
| +#ifndef HAL_LIBRARY_PATH2 |
| +#define HAL_LIBRARY_PATH2 "/vendor/lib" _64 "/hw" |
| #endif |
| /** |
| @@ -129,6 +141,14 @@ static int load(const char *id, |
| static int hw_module_exists(char *path, size_t path_len, const char *name, |
| const char *subname) |
| { |
| + char *hal_library_path = getenv("HAL_LIBRARY_PATH"); |
|
rjkroege
2014/05/02 20:38:26
upon reflection, reading from the environment seem
|
| + if (hal_library_path) { |
| + snprintf(path, path_len, "%s/%s.%s.so", |
| + hal_library_path, 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) |