From a4d0252ab5b6f6cc52a221538e1536c5b55c1fa7 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Fri, 3 Nov 2017 16:18:19 -0700 Subject: canCastInterface: always return true for IBase Don't do a binder call for passing interface around, especially since every HIDL thing is already IBase. Bug: 68217907 Test: hidl's run_all_device_tests, boot + camera/YT sanity Merged-In: Ic195e9c19f181828296c515a3004c75daccdd03f Change-Id: Ic195e9c19f181828296c515a3004c75daccdd03f (cherry picked from commit b2bf30d7009674938a96ff9ae87a30e9ab260dc6) --- transport/HidlTransportUtils.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/transport/HidlTransportUtils.cpp b/transport/HidlTransportUtils.cpp index eda9b8a..4e952eb 100644 --- a/transport/HidlTransportUtils.cpp +++ b/transport/HidlTransportUtils.cpp @@ -16,16 +16,25 @@ #include +#include + namespace android { namespace hardware { namespace details { -Return canCastInterface(::android::hidl::base::V1_0::IBase* interface, - const char* castTo, bool emitError) { +using ::android::hidl::base::V1_0::IBase; + +Return canCastInterface(IBase* interface, const char* castTo, bool emitError) { if (interface == nullptr) { return false; } + // b/68217907 + // Every HIDL interface is a base interface. + if (std::string(IBase::descriptor) == castTo) { + return true; + } + bool canCast = false; auto chainRet = interface->interfaceChain([&](const hidl_vec &types) { for (size_t i = 0; i < types.size(); i++) { @@ -46,7 +55,7 @@ Return canCastInterface(::android::hidl::base::V1_0::IBase* interface, return canCast; } -std::string getDescriptor(::android::hidl::base::V1_0::IBase* interface) { +std::string getDescriptor(IBase* interface) { std::string myDescriptor{}; auto ret = interface->interfaceDescriptor([&](const hidl_string &types) { myDescriptor = types.c_str(); -- cgit v1.2.3