summaryrefslogtreecommitdiffstats
path: root/sensors
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-05-02 02:48:41 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-05-02 02:48:41 +0000
commitda0ae1cfe43bdac2b3fda1139331c6940ab92cf2 (patch)
tree62f17ffeaeffbbcd96dd22f87510ca1994131795 /sensors
parent3bfea3e57f21ddcf2e16a092142994cb3ed8b56f (diff)
parent358db3b1061c3b3c18c597218b44456a3d4baed5 (diff)
downloadplatform_hardware_interfaces-da0ae1cfe43bdac2b3fda1139331c6940ab92cf2.tar.gz
platform_hardware_interfaces-da0ae1cfe43bdac2b3fda1139331c6940ab92cf2.tar.bz2
platform_hardware_interfaces-da0ae1cfe43bdac2b3fda1139331c6940ab92cf2.zip
Merge "Search for subhal .so files in additional directories" into rvc-dev am: 358db3b106
Change-Id: Id04399150e05bcc198ed8f9ccee9448e4a4a1581
Diffstat (limited to 'sensors')
-rw-r--r--sensors/common/default/2.X/multihal/HalProxy.cpp21
-rw-r--r--sensors/common/default/2.X/multihal/include/HalProxy.h10
2 files changed, 30 insertions, 1 deletions
diff --git a/sensors/common/default/2.X/multihal/HalProxy.cpp b/sensors/common/default/2.X/multihal/HalProxy.cpp
index a09e9e938e..75ffc17a67 100644
--- a/sensors/common/default/2.X/multihal/HalProxy.cpp
+++ b/sensors/common/default/2.X/multihal/HalProxy.cpp
@@ -426,7 +426,7 @@ void HalProxy::initializeSubHalListFromConfigFile(const char* configFileName) {
} else {
std::string subHalLibraryFile;
while (subHalConfigStream >> subHalLibraryFile) {
- void* handle = dlopen(subHalLibraryFile.c_str(), RTLD_NOW);
+ void* handle = getHandleForSubHalSharedObject(subHalLibraryFile);
if (handle == nullptr) {
ALOGE("dlopen failed for library: %s", subHalLibraryFile.c_str());
} else {
@@ -491,6 +491,25 @@ void HalProxy::initializeSensorList() {
}
}
+void* HalProxy::getHandleForSubHalSharedObject(const std::string& filename) {
+ static const std::string kSubHalShareObjectLocations[] = {
+ "", // Default locations will be searched
+#ifdef __LP64__
+ "/vendor/lib64/hw/", "/odm/lib64/hw/"
+#else
+ "/vendor/lib/hw/", "/odm/lib/hw/"
+#endif
+ };
+
+ for (const std::string& dir : kSubHalShareObjectLocations) {
+ void* handle = dlopen((dir + filename).c_str(), RTLD_NOW);
+ if (handle != nullptr) {
+ return handle;
+ }
+ }
+ return nullptr;
+}
+
void HalProxy::init() {
initializeSensorList();
}
diff --git a/sensors/common/default/2.X/multihal/include/HalProxy.h b/sensors/common/default/2.X/multihal/include/HalProxy.h
index fb0b806bab..35d7c8bae1 100644
--- a/sensors/common/default/2.X/multihal/include/HalProxy.h
+++ b/sensors/common/default/2.X/multihal/include/HalProxy.h
@@ -267,6 +267,16 @@ class HalProxy : public V2_0::implementation::IScopedWakelockRefCounter,
void initializeSensorList();
/**
+ * Try using the default include directories as well as the directories defined in
+ * kSubHalShareObjectLocations to get a handle for dlsym for a subhal.
+ *
+ * @param filename The file name to search for.
+ *
+ * @return The handle or nullptr if search failed.
+ */
+ void* getHandleForSubHalSharedObject(const std::string& filename);
+
+ /**
* Calls the helper methods that all ctors use.
*/
void init();