getTransport checks interface and instance names.
If <interface> is missing from the manifest, it returns
<transport> only if instanceName == "default", and EMPTY
otherwise.
Bug: 35219444
Test: hidl_test
Test: camera, soundtrigger works on marlin
Test: video playback works on marlin
Change-Id: Iaae6ae9bbf5f8c97fae63f2ac41595d822f781ca
diff --git a/base/HidlSupport.cpp b/base/HidlSupport.cpp
index 37f40c4..91d56e7 100644
--- a/base/HidlSupport.cpp
+++ b/base/HidlSupport.cpp
@@ -29,7 +29,8 @@
namespace hardware {
vintf::Transport getTransportFromManifest(
- const FQName &fqName, const std::string &manifestName,
+ const FQName &fqName, const std::string &instanceName,
+ const std::string &manifestName,
const vintf::HalManifest *vm) {
if (vm == nullptr) {
LOG(WARNING) << "getTransportFromManifest: No " << manifestName << " manifest defined, "
@@ -37,7 +38,8 @@
return vintf::Transport::EMPTY;
}
vintf::Transport tr = vm->getTransport(fqName.package(),
- vintf::Version{fqName.getPackageMajorVersion(), fqName.getPackageMinorVersion()});
+ vintf::Version{fqName.getPackageMajorVersion(), fqName.getPackageMinorVersion()},
+ fqName.name(), instanceName);
if (tr == vintf::Transport::EMPTY) {
LOG(WARNING) << "getTransportFromManifest: Cannot find entry "
<< fqName.string()
@@ -50,10 +52,10 @@
return tr;
}
-vintf::Transport getTransport(const std::string &name) {
- FQName fqName(name);
+vintf::Transport getTransport(const std::string &interfaceName, const std::string &instanceName) {
+ FQName fqName(interfaceName);
if (!fqName.isValid()) {
- LOG(ERROR) << "getTransport: " << name << " is not a valid fully-qualified name.";
+ LOG(ERROR) << "getTransport: " << interfaceName << " is not a valid fully-qualified name.";
return vintf::Transport::EMPTY;
}
if (!fqName.hasVersion()) {
@@ -61,12 +63,17 @@
<< " does not specify a version. Using default transport.";
return vintf::Transport::EMPTY;
}
+ if (fqName.name().empty()) {
+ LOG(ERROR) << "getTransport: " << fqName.string()
+ << " does not specify an interface name. Using default transport.";
+ return vintf::Transport::EMPTY;
+ }
// TODO(b/34772739): modify the list if other packages are added to system/manifest.xml
if (fqName.inPackage("android.hidl")) {
- return getTransportFromManifest(fqName, "framework",
+ return getTransportFromManifest(fqName, instanceName, "framework",
vintf::VintfObject::GetFrameworkHalManifest());
}
- return getTransportFromManifest(fqName, "device",
+ return getTransportFromManifest(fqName, instanceName, "device",
vintf::VintfObject::GetDeviceHalManifest());
}
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index 92a0e96..a16701b 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -57,9 +57,11 @@
namespace hardware {
// Get transport method from vendor interface manifest.
-// name has the format "android.hardware.foo@1.0::IFoo"
+// interfaceName has the format "android.hardware.foo@1.0::IFoo"
+// instanceName is "default", "ashmem", etc.
// If it starts with "android.hidl.", a static map is looked up instead.
-vintf::Transport getTransport(const std::string &name);
+vintf::Transport getTransport(const std::string &interfaceName,
+ const std::string &instanceName);
// hidl_death_recipient is a callback interfaced that can be used with
// linkToDeath() / unlinkToDeath()
diff --git a/transport/LegacySupport.cpp b/transport/LegacySupport.cpp
index 0032fc3..95796bf 100644
--- a/transport/LegacySupport.cpp
+++ b/transport/LegacySupport.cpp
@@ -61,7 +61,7 @@
std::string package = interface.substr(0, loc);
// only block if this is supposed to be toggled
- if (getTransport(interface) != vintf::Transport::TOGGLED) {
+ if (getTransport(interface, instance) != vintf::Transport::TOGGLED) {
return;
}