Merge "Add getTransportFromManifest"
diff --git a/base/Android.bp b/base/Android.bp
index f2f5ab0..2282ddf 100644
--- a/base/Android.bp
+++ b/base/Android.bp
@@ -16,13 +16,15 @@
name: "libhidlbase",
shared_libs: [
"libbase",
+ "libcutils",
"liblog",
"libutils",
- "libcutils",
+ "libvintf",
],
export_shared_lib_headers: [
"libbase",
"libutils",
+ "libvintf",
],
local_include_dirs: ["include"],
export_include_dirs: ["include"],
diff --git a/base/HidlSupport.cpp b/base/HidlSupport.cpp
index ef82775..593380b 100644
--- a/base/HidlSupport.cpp
+++ b/base/HidlSupport.cpp
@@ -18,6 +18,8 @@
#include <hidl/HidlSupport.h>
#include <android-base/logging.h>
+#include <vintf/VendorManifest.h>
+#include <vintf/parse_string.h>
#ifdef LIBHIDL_TARGET_DEBUGGABLE
#include <cutils/properties.h>
@@ -29,6 +31,23 @@
namespace android {
namespace hardware {
+vintf::Transport getTransportFromManifest(const std::string &package) {
+ const vintf::VendorManifest *vm = vintf::VendorManifest::Get();
+ if (vm == nullptr) {
+ LOG(ERROR) << "getTransportFromManifest: Cannot find vendor interface manifest.";
+ return vintf::Transport::EMPTY;
+ }
+ vintf::Transport tr = vm->getTransport(package);
+ if (tr == vintf::Transport::EMPTY) {
+ LOG(WARNING) << "getTransportFromManifest: Cannot find entry "
+ << package << " in vendor interface manifest.";
+ } else {
+ LOG(INFO) << "getTransportFromManifest: " << package
+ << " declares transport method " << to_string(tr);
+ }
+ return tr;
+}
+
static const char *const kEmptyString = "";
hidl_string::hidl_string()
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index b9e4ffa..4a17c3e 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -34,6 +34,7 @@
#include <utils/Errors.h>
#include <utils/RefBase.h>
#include <utils/StrongPointer.h>
+#include <vintf/Transport.h>
#include <vector>
namespace android {
@@ -58,6 +59,10 @@
namespace hardware {
+// Get transport method from vendor interface manifest.
+// name has the format "android.hardware.foo"
+vintf::Transport getTransportFromManifest(const std::string &name);
+
// hidl_death_recipient is a callback interfaced that can be used with
// linkToDeath() / unlinkToDeath()
struct hidl_death_recipient : public virtual RefBase {