diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-10-11 00:00:00 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2023-10-11 00:00:00 +0000 |
commit | 9fb9c41385f5202d80047a6b0a48959f9f1758ed (patch) | |
tree | c2afa35bd2da06539e6af4629b6060cb424da10e | |
parent | 0e026c718495303037bfaa82b4ae79714d5283cd (diff) | |
parent | 6727dad8f39e12907f1448057a88d4e47ff7a882 (diff) | |
download | libhardware-9fb9c41385f5202d80047a6b0a48959f9f1758ed.tar.gz |
Merge "Snap for 10929834 from 6e5271930fc3dbb222217ef4342fe59d1fbf3629 to sdk-release" into sdk-release
-rw-r--r-- | Android.bp | 11 | ||||
-rw-r--r-- | hardware.c | 40 | ||||
-rw-r--r-- | modules/gralloc/gralloc.cpp | 4 | ||||
-rw-r--r-- | modules/sensors/dynamic_sensor/HidRawDevice.cpp | 14 |
4 files changed, 51 insertions, 18 deletions
@@ -92,6 +92,7 @@ cc_library_shared { srcs: ["hardware.c"], shared_libs: [ + "libapexsupport", "libcutils", "liblog", "libvndksupport", @@ -114,10 +115,16 @@ cc_library_shared { }, target: { host: { - exclude_shared_libs: ["libvndksupport"], + exclude_shared_libs: [ + "libapexsupport", + "libvndksupport", + ], }, recovery: { - exclude_shared_libs: ["libvndksupport"], + exclude_shared_libs: [ + "libapexsupport", + "libvndksupport", + ], }, }, min_sdk_version: "29", @@ -34,17 +34,21 @@ #include <vndksupport/linker.h> #endif +#ifdef __ANDROID_APEX__ +#include <android/apexsupport.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 HAL_LIBRARY_PATH3 "/odm/lib64/hw" +#define HAL_LIBRARY_SUBDIR "lib64/hw" #else -#define HAL_LIBRARY_PATH1 "/system/lib/hw" -#define HAL_LIBRARY_PATH2 "/vendor/lib/hw" -#define HAL_LIBRARY_PATH3 "/odm/lib/hw" +#define HAL_LIBRARY_SUBDIR "lib/hw" #endif +#define HAL_LIBRARY_PATH1 "/system/" HAL_LIBRARY_SUBDIR +#define HAL_LIBRARY_PATH2 "/vendor/" HAL_LIBRARY_SUBDIR +#define HAL_LIBRARY_PATH3 "/odm/" HAL_LIBRARY_SUBDIR + /** * There are a set of variant filename for modules. The form of the filename * is "<MODULE_ID>.variant.so" so for the led module the Dream variants @@ -79,7 +83,7 @@ static int load(const char *id, int status = -EINVAL; void *handle = NULL; struct hw_module_t *hmi = NULL; -#ifdef __ANDROID_VNDK__ +#if defined(__ANDROID_VNDK__) || defined(__ANDROID_APEX__) const bool try_system = false; #else const bool try_system = true; @@ -97,7 +101,7 @@ static int load(const char *id, */ handle = dlopen(path, RTLD_NOW); } else { -#if defined(__ANDROID_RECOVERY__) || !defined(__ANDROID__) +#if defined(__ANDROID_RECOVERY__) || !defined(__ANDROID__) || defined(__ANDROID_APEX__) handle = dlopen(path, RTLD_NOW); #else handle = android_load_sphal_library(path, RTLD_NOW); @@ -151,7 +155,7 @@ static int load(const char *id, /* * If path is in in_path. */ -static bool path_in_path(const char *path, const char *in_path) { +static bool __attribute__ ((unused)) path_in_path(const char *path, const char *in_path) { char real_path[PATH_MAX]; if (realpath(path, real_path) == NULL) return false; @@ -174,6 +178,22 @@ static bool path_in_path(const char *path, const char *in_path) { static int hw_module_exists(char *path, size_t path_len, const char *name, const char *subname) { +#ifdef __ANDROID_APEX__ + // When used in APEX, it should look only into the same APEX because + // libhardware modules don't provide ABI stability. + if (__builtin_available(android AAPEXSUPPORT_API, *)) { + AApexInfo *apex_info; + if (AApexInfo_create(&apex_info) == AAPEXINFO_OK) { + snprintf(path, path_len, "/apex/%s/%s/%s.%s.so", + AApexInfo_getName(apex_info), HAL_LIBRARY_SUBDIR, name, subname); + AApexInfo_destroy(apex_info); + if (access(path, R_OK) == 0) + return 0; + } + } else { + ALOGE("hw_module_exists: libapexsupport is not supported in %d.", __ANDROID_API__); + } +#else // __ANDROID_APEX__ snprintf(path, path_len, "%s/%s.%s.so", HAL_LIBRARY_PATH3, name, subname); if (path_in_path(path, HAL_LIBRARY_PATH3) && access(path, R_OK) == 0) @@ -191,6 +211,8 @@ static int hw_module_exists(char *path, size_t path_len, const char *name, return 0; #endif +#endif // __ANDROID_APEX__ + return -ENOENT; } diff --git a/modules/gralloc/gralloc.cpp b/modules/gralloc/gralloc.cpp index 87bda975..f7ea01cf 100644 --- a/modules/gralloc/gralloc.cpp +++ b/modules/gralloc/gralloc.cpp @@ -224,7 +224,11 @@ static int gralloc_alloc(alloc_device_t* dev, case HAL_PIXEL_FORMAT_RAW16: bytesPerPixel = 2; break; + case HAL_PIXEL_FORMAT_BLOB: + bytesPerPixel = 1; + break; default: + ALOGE("gralloc_alloc bad format %d", format); return -EINVAL; } diff --git a/modules/sensors/dynamic_sensor/HidRawDevice.cpp b/modules/sensors/dynamic_sensor/HidRawDevice.cpp index 2588483a..6032ed95 100644 --- a/modules/sensors/dynamic_sensor/HidRawDevice.cpp +++ b/modules/sensors/dynamic_sensor/HidRawDevice.cpp @@ -204,7 +204,7 @@ bool HidRawDevice::getFeature(uint8_t id, std::vector<uint8_t> *out) { int res = ::ioctl(mDevFd, HIDIOCGFEATURE(size), mIoBuffer.data()); if (res < 0) { LOG_E << "HidRawDevice::getFeature: feature " << static_cast<int>(id) - << " ioctl returns " << res << " (" << ::strerror(res) << ")" << LOG_ENDL; + << " ioctl returned " << res << ", errno: " << ::strerror(errno) << LOG_ENDL; return false; } @@ -249,8 +249,8 @@ bool HidRawDevice::setFeature(uint8_t id, const std::vector<uint8_t> &in) { std::copy(in.begin(), in.end(), &mIoBuffer[1]); int res = ::ioctl(mDevFd, HIDIOCSFEATURE(size), mIoBuffer.data()); if (res < 0) { - LOG_E << "HidRawDevice::setFeature: feature " << id << " ioctl returns " << res - << " (" << ::strerror(res) << ")" << LOG_ENDL; + LOG_E << "HidRawDevice::setFeature: feature " << id << " ioctl returned " << res + << ", errno: " << ::strerror(errno) << LOG_ENDL; return false; } return true; @@ -287,8 +287,8 @@ bool HidRawDevice::sendReport(uint8_t id, std::vector<uint8_t> &data) { res = ::write(mDevFd, data.data(), size); } if (res < 0) { - LOG_E << "HidRawDevice::sendReport: output " << id << " write returns " << res - << " (" << ::strerror(res) << ")" << LOG_ENDL; + LOG_E << "HidRawDevice::sendReport: output " << id << " write returned " + << res << ", errno: " << ::strerror(errno) << LOG_ENDL; return false; } return true; @@ -302,8 +302,8 @@ bool HidRawDevice::receiveReport(uint8_t *id, std::vector<uint8_t> *data) { uint8_t buffer[256]; int res = ::read(mDevFd, buffer, 256); if (res < 0) { - LOG_E << "HidRawDevice::receiveReport: read returns " << res - << " (" << ::strerror(res) << ")" << LOG_ENDL; + LOG_E << "HidRawDevice::receiveReport: read returned " << res + << ", errno: " << ::strerror(errno) << LOG_ENDL; return false; } |