Use interfaceDescriptor instead of interfaceChain

wherever suits. Sementically, interfaceDescriptor
returns the first element of interfaceChain; use
interfaceDescriptor when the rest of the elements
aren't used.

Bug: 34136228

Test: hidl_test
Change-Id: Id7650788a00a37a6d0fcb574547371965ddf4a04
diff --git a/transport/HidlPassthroughSupport.cpp b/transport/HidlPassthroughSupport.cpp
index 2e1671d..43724f9 100644
--- a/transport/HidlPassthroughSupport.cpp
+++ b/transport/HidlPassthroughSupport.cpp
@@ -28,9 +28,9 @@
         // doesn't know how to handle it.
         return iface;
     }
-    std::string myDescriptor = getDescriptor(iface.get());
+    std::string myDescriptor = details::getDescriptor(iface.get());
     if (myDescriptor.empty()) {
-        // interfaceChain fails
+        // interfaceDescriptor fails
         return nullptr;
     }
     auto func = gBsConstructorMap.get(myDescriptor, nullptr);
diff --git a/transport/include/hidl/HidlBinderSupport.h b/transport/include/hidl/HidlBinderSupport.h
index e948221..ba11937 100644
--- a/transport/include/hidl/HidlBinderSupport.h
+++ b/transport/include/hidl/HidlBinderSupport.h
@@ -323,9 +323,9 @@
     if (ifacePtr->isRemote()) {
         return ::android::hardware::IInterface::asBinder(static_cast<ProxyType *>(ifacePtr));
     } else {
-        std::string myDescriptor = getDescriptor(ifacePtr);
+        std::string myDescriptor = details::getDescriptor(ifacePtr);
         if (myDescriptor.empty()) {
-            // interfaceChain fails
+            // interfaceDescriptor fails
             return nullptr;
         }
         auto func = gBnConstructorMap.get(myDescriptor, nullptr);
@@ -348,7 +348,7 @@
         return new ProxyType(binderIface);
     }
     sp<IBase> base = static_cast<BnHwBase*>(binderIface.get())->getImpl();
-    if (canCastInterface(base.get(), IType::descriptor)) {
+    if (details::canCastInterface(base.get(), IType::descriptor)) {
         StubType* stub = static_cast<StubType*>(binderIface.get());
         return stub->getImpl();
     } else {
diff --git a/transport/include/hidl/HidlTransportSupport.h b/transport/include/hidl/HidlTransportSupport.h
index eabb75d..86379a9 100644
--- a/transport/include/hidl/HidlTransportSupport.h
+++ b/transport/include/hidl/HidlTransportSupport.h
@@ -61,7 +61,7 @@
         // casts always succeed with nullptrs.
         return nullptr;
     }
-    bool canCast = canCastInterface(parent.get(), childIndicator);
+    bool canCast = details::canCastInterface(parent.get(), childIndicator);
 
     if (!canCast) {
         return sp<IChild>(nullptr); // cast failed.
diff --git a/transport/include/hidl/HidlTransportUtils.h b/transport/include/hidl/HidlTransportUtils.h
index dc444dc..0fe70c4 100644
--- a/transport/include/hidl/HidlTransportUtils.h
+++ b/transport/include/hidl/HidlTransportUtils.h
@@ -21,6 +21,7 @@
 
 namespace android {
 namespace hardware {
+namespace details {
 
 /*
  * Verifies the interface chain of 'interface' contains 'castTo'
@@ -44,14 +45,14 @@
 
 inline std::string getDescriptor(::android::hidl::base::V1_0::IBase* interface) {
     std::string myDescriptor{};
-    auto ret = interface->interfaceChain([&](const hidl_vec<hidl_string> &types) {
-        if (types.size() > 0) {
-            myDescriptor = types[0].c_str();
-        }
+    auto ret = interface->interfaceDescriptor([&](const hidl_string &types) {
+        myDescriptor = types.c_str();
     });
-    return ret.isOk() ? myDescriptor : "";
+    ret.isOk(); // ignored, return empty string if not isOk()
+    return myDescriptor;
 }
 
+}   // namespace details
 }   // namespace hardware
 }   // namespace android