Add getTransportFromManifest
which consult the vendor interface object to see
what transport method is expected for each HAL.
Test: hidl_test
Bug: 32718841
Change-Id: I4529b7dcb5a892d968b50f2a2301035b9f0aa466
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..a89e88b 100644
--- a/base/HidlSupport.cpp
+++ b/base/HidlSupport.cpp
@@ -18,6 +18,7 @@
#include <hidl/HidlSupport.h>
#include <android-base/logging.h>
+#include <vintf/VendorManifest.h>
#ifdef LIBHIDL_TARGET_DEBUGGABLE
#include <cutils/properties.h>
@@ -29,6 +30,20 @@
namespace android {
namespace hardware {
+vintf::Transport getTransportFromManifest(const std::string &iface) {
+ const vintf::VendorManifest *vm = vintf::VendorManifest::Get();
+ if (vm == nullptr) {
+ LOG(ERROR) << "Cannot find vendor interface manifest.";
+ return vintf::Transport::EMPTY;
+ }
+ auto it = vm->hals.find(iface);
+ if (it == vm->hals.end()) {
+ LOG(ERROR) << "Vendor interface manifest does not contain entry for " << iface;
+ return vintf::Transport::EMPTY;
+ }
+ return it->second.transport;
+}
+
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..acc6347 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,8 @@
namespace hardware {
+vintf::Transport getTransportFromManifest(const std::string &iface);
+
// hidl_death_recipient is a callback interfaced that can be used with
// linkToDeath() / unlinkToDeath()
struct hidl_death_recipient : public virtual RefBase {