summaryrefslogtreecommitdiff
path: root/base/HidlInternal.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'base/HidlInternal.cpp')
-rw-r--r--base/HidlInternal.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/base/HidlInternal.cpp b/base/HidlInternal.cpp
index 6cdc24e..10e250b 100644
--- a/base/HidlInternal.cpp
+++ b/base/HidlInternal.cpp
@@ -19,6 +19,8 @@
#include <hidl/HidlInternal.h>
#include <android-base/logging.h>
+#include <android-base/properties.h>
+#include <android-base/stringprintf.h>
#include <cutils/properties.h>
#ifdef LIBHIDL_TARGET_DEBUGGABLE
@@ -43,6 +45,21 @@ void logAlwaysFatal(const char* message) {
LOG(FATAL) << message;
}
+std::string getVndkVersionStr() {
+ static std::string vndkVersion("0");
+ // "0" means the vndkVersion must be initialized with the property value.
+ // Otherwise, return the value.
+ if (vndkVersion == "0") {
+ vndkVersion = android::base::GetProperty("ro.vndk.version", "");
+ if (vndkVersion != "" && vndkVersion != "current") {
+ vndkVersion = "-" + vndkVersion;
+ } else {
+ vndkVersion = "";
+ }
+ }
+ return vndkVersion;
+}
+
// ----------------------------------------------------------------------
// HidlInstrumentor implementation.
HidlInstrumentor::HidlInstrumentor(const std::string& package, const std::string& interface)
@@ -127,8 +144,10 @@ void HidlInstrumentor::registerInstrumentationCallbacks(
"") > 0) {
instrumentationLibPaths.push_back(instrumentationLibPath);
} else {
+ static std::string halLibPathVndkSp = android::base::StringPrintf(
+ HAL_LIBRARY_PATH_VNDK_SP_FOR_VERSION, getVndkVersionStr().c_str());
instrumentationLibPaths.push_back(HAL_LIBRARY_PATH_SYSTEM);
- instrumentationLibPaths.push_back(HAL_LIBRARY_PATH_VNDK_SP);
+ instrumentationLibPaths.push_back(halLibPathVndkSp);
instrumentationLibPaths.push_back(HAL_LIBRARY_PATH_VENDOR);
instrumentationLibPaths.push_back(HAL_LIBRARY_PATH_ODM);
}