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/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()