summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2017-04-06 17:24:22 -0700
committerSteven Moreland <smoreland@google.com>2017-04-06 17:45:53 -0700
commit819c05d28de72983177620902990dff360e80e73 (patch)
tree2b1c6f2072e5832cb3083c06a514e048ea77123a
parentc601c5f21808844e614015eabc03e9c71f5aae42 (diff)
downloadlibhidl-819c05d28de72983177620902990dff360e80e73.tar.gz
Remove dependency on libhidl-gen-utils.
Test: hidl_test + (sanity) hidl_test_java Test: VtsHalVibratorV1_0TargetProfiling Test: internal marlin boots up w/o errors Test: (sanity) YouTube/Camera works Bug: 37107636 Change-Id: I9b3a47d17ff3d594282bc3a28cd81463c3b1ac0f
-rw-r--r--base/Android.bp1
-rw-r--r--base/HidlInternal.cpp20
-rw-r--r--transport/Android.bp1
-rw-r--r--transport/ServiceManagement.cpp35
4 files changed, 39 insertions, 18 deletions
diff --git a/base/Android.bp b/base/Android.bp
index 25b2a80..dd759d2 100644
--- a/base/Android.bp
+++ b/base/Android.bp
@@ -18,7 +18,6 @@ cc_library_shared {
shared_libs: [
"libbase",
"libcutils",
- "libhidl-gen-utils",
"liblog",
"libutils",
],
diff --git a/base/HidlInternal.cpp b/base/HidlInternal.cpp
index 36ffae8..3bb27f8 100644
--- a/base/HidlInternal.cpp
+++ b/base/HidlInternal.cpp
@@ -24,7 +24,6 @@
#ifdef LIBHIDL_TARGET_DEBUGGABLE
#include <dirent.h>
#include <dlfcn.h>
-#include <hidl-util/FQName.h>
#include <regex>
#endif
@@ -111,14 +110,25 @@ void HidlInstrumentor::registerInstrumentationCallbacks(
const char *,
const char *,
std::vector<void *> *);
- FQName package_name = FQName(mInstrumentationLibPackage);
+ std::string package = mInstrumentationLibPackage;
+ for (size_t i = 0; i < package.size(); i++) {
+ if (package[i] == '.') {
+ package[i] = '_';
+ continue;
+ }
+
+ if (package[i] == '@') {
+ package[i] = '_';
+ package.insert(i + 1, "V");
+ continue;
+ }
+ }
auto cb = (cb_fun)dlsym(handle, ("HIDL_INSTRUMENTATION_FUNCTION_"
- + package_name.tokenName() + "_"
- + mInterfaceName).c_str());
+ + package + "_" + mInterfaceName).c_str());
if ((error = dlerror()) != NULL) {
LOG(WARNING)
<< "couldn't find symbol: HIDL_INSTRUMENTATION_FUNCTION_"
- << mInterfaceName << ", error: " << error;
+ << package << "_" << mInterfaceName << ", error: " << error;
continue;
}
instrumentationCallbacks->push_back(cb);
diff --git a/transport/Android.bp b/transport/Android.bp
index 835c6e1..6f0b6a9 100644
--- a/transport/Android.bp
+++ b/transport/Android.bp
@@ -33,7 +33,6 @@ cc_library_shared {
"libhidlbase",
"libhwbinder",
"libcutils",
- "libhidl-gen-utils"
],
export_shared_lib_headers: [
"libbase",
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp
index 30013d3..ff9884e 100644
--- a/transport/ServiceManagement.cpp
+++ b/transport/ServiceManagement.cpp
@@ -30,8 +30,6 @@
#include <android-base/logging.h>
#include <android-base/properties.h>
-#include <hidl-util/FQName.h>
-#include <hidl-util/StringHelper.h>
#include <hwbinder/IPCThreadState.h>
#include <hwbinder/Parcel.h>
@@ -97,6 +95,16 @@ sp<IServiceManager> defaultServiceManager() {
return details::gDefaultServiceManager;
}
+bool endsWith(const std::string &in, const std::string &suffix) {
+ return in.size() >= suffix.size() &&
+ in.substr(in.size() - suffix.size()) == suffix;
+}
+
+bool startsWith(const std::string &in, const std::string &prefix) {
+ return in.size() >= prefix.size() &&
+ in.substr(0, prefix.size()) == prefix;
+}
+
std::vector<std::string> search(const std::string &path,
const std::string &prefix,
const std::string &suffix) {
@@ -109,8 +117,8 @@ std::vector<std::string> search(const std::string &path,
while ((dp = readdir(dir.get())) != nullptr) {
std::string name = dp->d_name;
- if (StringHelper::StartsWith(name, prefix) &&
- StringHelper::EndsWith(name, suffix)) {
+ if (startsWith(name, prefix) &&
+ endsWith(name, suffix)) {
results.push_back(name);
}
}
@@ -148,18 +156,23 @@ static void registerReference(const hidl_string &interfaceName, const hidl_strin
struct PassthroughServiceManager : IServiceManager {
Return<sp<IBase>> get(const hidl_string& fqName,
- const hidl_string& name) override {
- const FQName iface(fqName);
+ const hidl_string& name) override {
+ std::string stdFqName(fqName.c_str());
+
+ //fqName looks like android.hardware.foo@1.0::IFoo
+ size_t idx = stdFqName.find("::");
- if (!iface.isValid() ||
- !iface.isFullyQualified() ||
- iface.isIdentifier()) {
+ if (idx == std::string::npos ||
+ idx + strlen("::") + 1 >= stdFqName.size()) {
LOG(ERROR) << "Invalid interface name passthrough lookup: " << fqName;
return nullptr;
}
- const std::string prefix = iface.getPackageAndVersion().string() + "-impl";
- const std::string sym = "HIDL_FETCH_" + iface.name();
+ std::string packageAndVersion = stdFqName.substr(0, idx);
+ std::string ifaceName = stdFqName.substr(idx + strlen("::"));
+
+ const std::string prefix = packageAndVersion + "-impl";
+ const std::string sym = "HIDL_FETCH_" + ifaceName;
const int dlMode = RTLD_LAZY;
void *handle = nullptr;