Hidlize IBase; use IBase instead of IBinder.

* IBase is hidlized over hwbinder. GenericBinder
  is removed and Interface with name
  android.hidl.base@1.0::IBase is used instead.

* Removed AST::mImportedNamesForJava, because in Java,
  we always refer to a type with the full name. We don't
  import anything in the java file.

* IFoo.h now includes HidlSupport.h instead of
  HidlTransportSupport.h

Test: hidl_test
Test: hidl_test_java

Fix: 32756130
Fix: 33273293

Change-Id: I435ad7c68dea028a16252148b6f5778e3610b7cd
diff --git a/AST.cpp b/AST.cpp
index eaa3141..2d2898c 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -407,11 +407,6 @@
                     resolvedName.package(), resolvedName.version(), "types");
 
             mImportedNames.insert(typesName);
-
-            if (resolvedType->isNamedType() && !resolvedType->isTypeDef()) {
-                mImportedNamesForJava.insert(
-                        static_cast<NamedType *>(resolvedType)->fqName());
-            }
         } else {
             // Do _not_ use fqName, i.e. the name we used to look up the type,
             // but instead use the name of the interface we found.
@@ -421,9 +416,6 @@
 
             mImportedNames.insert(
                     static_cast<Interface *>(resolvedType)->fqName());
-
-            mImportedNamesForJava.insert(
-                    static_cast<Interface *>(resolvedType)->fqName());
         }
     }
 
@@ -489,4 +481,9 @@
     mRootScope->appendToExportedTypesVector(exportedTypes);
 }
 
+bool AST::isIBase() const {
+    Interface *iface = mRootScope->getInterface();
+    return iface != nullptr && iface->isIBase();
+}
+
 }  // namespace android;
diff --git a/AST.h b/AST.h
index dc5a7e2..05e1270 100644
--- a/AST.h
+++ b/AST.h
@@ -112,6 +112,8 @@
     void addSyntaxError();
     size_t syntaxErrors() const;
 
+    bool isIBase() const;
+
 private:
     Coordinator *mCoordinator;
     std::string mPath;
@@ -126,10 +128,6 @@
     // in this AST, this is a subset of those specified in import statements.
     std::set<FQName> mImportedNames;
 
-    // Similar to mImportedNames, but all types references from "types.hal"
-    // are individually listed.
-    std::set<FQName> mImportedNamesForJava;
-
     // A set of all ASTs we explicitly or implicitly (types.hal) import.
     std::set<AST *> mImportedASTs;
 
diff --git a/Android.bp b/Android.bp
index 856393c..8eae5b5 100644
--- a/Android.bp
+++ b/Android.bp
@@ -35,7 +35,6 @@
         "ConstantExpression.cpp",
         "EnumType.cpp",
         "FQName.cpp",
-        "GenericBinder.cpp",
         "HandleType.cpp",
         "Interface.cpp",
         "MemoryType.cpp",
diff --git a/Coordinator.cpp b/Coordinator.cpp
index 57da8bb..284bbce 100644
--- a/Coordinator.cpp
+++ b/Coordinator.cpp
@@ -189,6 +189,10 @@
     return root;
 }
 
+std::string Coordinator::getPackageRootOption(const FQName &fqName) const {
+    return getPackageRoot(fqName) + ":" + getPackageRootPath(fqName);
+}
+
 std::string Coordinator::getPackagePath(
         const FQName &fqName, bool relative) const {
 
diff --git a/Coordinator.h b/Coordinator.h
index 524cbb8..a87ad38 100644
--- a/Coordinator.h
+++ b/Coordinator.h
@@ -70,6 +70,9 @@
 
     std::string getPackageRootPath(const FQName &fqName) const;
 
+    // return getPackageRoot + ":" + getPackageRootPath
+    std::string getPackageRootOption(const FQName &fqName) const;
+
     // Given an FQName of "android.hardware.nfc@1.0::INfc", return
     // "android/hardware/".
     std::string convertPackageRootToPath(const FQName &fqName) const;
diff --git a/FQName.cpp b/FQName.cpp
index 908d39b..02e31e2 100644
--- a/FQName.cpp
+++ b/FQName.cpp
@@ -269,6 +269,10 @@
     return string() == other.string();
 }
 
+bool FQName::operator!=(const FQName &other) const {
+    return !(*this == other);
+}
+
 std::string FQName::getInterfaceBaseName() const {
     CHECK(names().size() == 1) << "Must be a top level type";
     CHECK(!mName.empty() && mName[0] == 'I') << mName;
diff --git a/FQName.h b/FQName.h
index a781157..5e5ef08 100644
--- a/FQName.h
+++ b/FQName.h
@@ -96,6 +96,7 @@
 
     bool operator<(const FQName &other) const;
     bool operator==(const FQName &other) const;
+    bool operator!=(const FQName &other) const;
 
     // Must be called on an interface
     // ::android::hardware::Foo::V1_0::IBar
@@ -162,6 +163,9 @@
     void setVersion(const std::string &v);
 };
 
+static const FQName gIBaseFqName{"android.hidl.base@1.0::IBase"};
+static const FQName gIBasePackageFqName{gIBaseFqName.package(), gIBaseFqName.version(), ""};
+
 }  // namespace android
 
 #endif  // FQNAME_H_
diff --git a/GenericBinder.cpp b/GenericBinder.cpp
deleted file mode 100644
index 935da31..0000000
--- a/GenericBinder.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "GenericBinder.h"
-
-#include <hidl-util/Formatter.h>
-
-namespace android {
-
-GenericBinder::GenericBinder() {}
-
-bool GenericBinder::isBinder() const {
-    return true;
-}
-
-void GenericBinder::addNamedTypesToSet(std::set<const FQName> &) const {
-    // do nothing
-}
-
-std::string GenericBinder::getCppType(
-        StorageMode mode,
-        bool specifyNamespaces) const {
-    const std::string base =
-          std::string(specifyNamespaces ? "::android::" : "")
-        + "sp<"
-        + std::string(specifyNamespaces ? "::android::hardware::" : "")
-        + "IBinder>";
-
-    switch (mode) {
-        case StorageMode_Stack:
-        case StorageMode_Result:
-            return base;
-
-        case StorageMode_Argument:
-            return "const " + base + "&";
-    }
-}
-
-std::string GenericBinder::getJavaType(bool /* forInitializer */) const {
-    return "android.os.IHwBinder";
-}
-
-void GenericBinder::emitReaderWriter(
-        Formatter &out,
-        const std::string &name,
-        const std::string &parcelObj,
-        bool parcelObjIsPointer,
-        bool isReader,
-        ErrorMode mode) const {
-    const std::string parcelObjDeref =
-        parcelObj + (parcelObjIsPointer ? "->" : ".");
-
-    if (isReader) {
-        out << "_hidl_err = ";
-        out << parcelObjDeref
-            << "readNullableStrongBinder(&"
-            << name
-            << ");\n";
-
-        handleError(out, mode);
-    } else {
-        out << "_hidl_err = ";
-        out << parcelObjDeref
-            << "writeStrongBinder("
-            << name
-            << ");\n";
-
-        handleError(out, mode);
-    }
-}
-
-void GenericBinder::emitJavaReaderWriter(
-        Formatter &out,
-        const std::string &parcelObj,
-        const std::string &argName,
-        bool isReader) const {
-    if (isReader) {
-        out << parcelObj
-            << ".readStrongBinder();\n";
-    } else {
-        out << parcelObj
-            << ".writeStrongBinder("
-            << argName
-            << " == null ? null : "
-            << argName
-            << ");\n";
-    }
-}
-
-status_t GenericBinder::emitVtsAttributeType(Formatter &) const {
-    return UNKNOWN_ERROR;
-}
-
-}  // namespace android
diff --git a/GenericBinder.h b/GenericBinder.h
deleted file mode 100644
index 55e7587..0000000
--- a/GenericBinder.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef GENERIC_BINDER_H_
-
-#define GENERIC_BINDER_H_
-
-#include "Type.h"
-
-namespace android {
-
-struct GenericBinder : public Type {
-    GenericBinder();
-
-    bool isBinder() const override;
-
-    void addNamedTypesToSet(std::set<const FQName> &set) const override;
-
-    std::string getCppType(
-            StorageMode mode,
-            bool specifyNamespaces) const override;
-
-    std::string getJavaType(bool forInitializer) const override;
-
-    void emitReaderWriter(
-            Formatter &out,
-            const std::string &name,
-            const std::string &parcelObj,
-            bool parcelObjIsPointer,
-            bool isReader,
-            ErrorMode mode) const override;
-
-    void emitJavaReaderWriter(
-            Formatter &out,
-            const std::string &parcelObj,
-            const std::string &argName,
-            bool isReader) const override;
-
-    status_t emitVtsAttributeType(Formatter &out) const override;
-};
-
-}  // namespace android
-
-#endif  // GENERIC_BINDER_H_
diff --git a/Interface.cpp b/Interface.cpp
index e0c4461..52e9a98 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -114,6 +114,11 @@
 
 
 bool Interface::addMethod(Method *method) {
+    if (isIBase()) {
+        // ignore addMethod requests for IBase; they are all HIDL reserved methods.
+        return true;
+    }
+
     CHECK(!method->isHidlReserved());
     if (lookupMethod(method->name()) != nullptr) {
         LOG(ERROR) << "Redefinition of method " << method->name();
@@ -188,7 +193,9 @@
         }
     }
     for (Method *reservedMethod : hidlReservedMethods()) {
-        v.push_back(InterfaceAndMethod(this, reservedMethod));
+        v.push_back(InterfaceAndMethod(
+                *chain.rbegin(), // IBase
+                reservedMethod));
     }
     return v;
 }
diff --git a/Interface.h b/Interface.h
index 5da326c..02b04dc 100644
--- a/Interface.h
+++ b/Interface.h
@@ -34,6 +34,7 @@
     bool isInterface() const override;
     bool isBinder() const override;
     bool isRootType() const { return mSuperType == nullptr; }
+    bool isIBase() const { return fqName() == gIBaseFqName; }
 
     const Interface *superType() const;
 
diff --git a/VectorType.cpp b/VectorType.cpp
index e2e7c56..1443697 100644
--- a/VectorType.cpp
+++ b/VectorType.cpp
@@ -191,18 +191,18 @@
         out.indent();
 
         out << mElementType->getCppStackType(true /* specifyNamespaces */)
-            << " _hidl_binder;\n";
+            << " _hidl_base;\n";
 
         mElementType->emitReaderWriter(
                 out,
-                "_hidl_binder",
+                "_hidl_base",
                 parcelObj,
                 parcelObjIsPointer,
                 isReader,
                 mode);
 
         out << name
-            << "[_hidl_index] = _hidl_binder;\n";
+            << "[_hidl_index] = _hidl_base;\n";
 
         out.unindent();
         out << "}\n";
diff --git a/c2hal/test/Android.bp b/c2hal/test/Android.bp
index 8fd73cb..6e2c3c5 100644
--- a/c2hal/test/Android.bp
+++ b/c2hal/test/Android.bp
@@ -23,6 +23,7 @@
          "-p android.hardware.c2hal_test@1.0 $(in) && " +
          "$(location hidl-gen) -o $(genDir) -Lc++ " +
          "-r android.hardware:$(genDir) " +
+         "-r android.hidl:system/libhidl/transport " +
          "android.hardware.c2hal_test@1.0::ISimple",
     srcs: [
         "simple.h",
@@ -46,6 +47,7 @@
          "-p android.hardware.c2hal_test@1.0 $(in) && " +
          "$(location hidl-gen) -o $(genDir) -Lc++ " +
          "-r android.hardware:$(genDir) " +
+         "-r android.hidl:system/libhidl/transport " +
          "android.hardware.c2hal_test@1.0::ISimple",
     srcs: [
         "simple.h",
diff --git a/generateCpp.cpp b/generateCpp.cpp
index b7ed184..4d7a444 100644
--- a/generateCpp.cpp
+++ b/generateCpp.cpp
@@ -163,11 +163,14 @@
     }
 
     if (isInterface) {
-        out << "#include <android/hidl/manager/1.0/IServiceNotification.h>\n\n";
+        if (isIBase()) {
+            out << "// skipped #include IServiceNotification.h\n\n";
+        } else {
+            out << "#include <android/hidl/manager/1.0/IServiceNotification.h>\n\n";
+        }
     }
 
-    // TODO b/32756130 change back to HidlSupport.h
-    out << "#include <hidl/HidlTransportSupport.h>\n";
+    out << "#include <hidl/HidlSupport.h>\n";
     out << "#include <hidl/MQDescriptor.h>\n";
 
     if (isInterface) {
@@ -189,7 +192,7 @@
         const Interface *superType = iface->superType();
 
         if (superType == NULL) {
-            out << " : virtual public ::android::hardware::IBase";
+            out << " : virtual public ::android::RefBase";
         } else {
             out << " : public "
                 << superType->fullName();
@@ -220,7 +223,11 @@
         out << "return version;\n";
         out.unindent();
         out << "}\n\n";
-        out << "virtual bool isRemote() const override { return false; }\n\n";
+        out << "virtual bool isRemote() const ";
+        if (!isIBase()) {
+            out << "override ";
+        }
+        out << "{ return false; }\n\n";
 
         for (const auto &method : iface->methods()) {
             out << "\n";
@@ -261,7 +268,9 @@
 
             out << ")";
             if (method->isHidlReserved()) {
-                out << " override";
+                if (!isIBase()) {
+                    out << " override";
+                }
                 out << " {\n";
                 out.indent();
                 method->cppImpl(out);
@@ -288,7 +297,11 @@
 
         out << "\nstatic const char* descriptor;\n\n";
 
-        out << "DECLARE_SERVICE_MANAGER_INTERACTIONS(" << baseName << ")\n\n";
+        if (isIBase()) {
+            out << "// skipped DECLARE_SERVICE_MANAGER_INTERACTIONS\n\n";
+        } else {
+            out << "DECLARE_SERVICE_MANAGER_INTERACTIONS(" << baseName << ")\n\n";
+        }
 
         out << "private: static int hidlStaticBlock;\n";
     }
@@ -865,11 +878,15 @@
     if (err == OK && isInterface) {
         const Interface *iface = mRootScope->getInterface();
 
-        out << "IMPLEMENT_SERVICE_MANAGER_INTERACTIONS("
-            << baseName << ", "
-            << "\"" << iface->fqName().package()
-            << iface->fqName().atVersion()
-            << "\")\n";
+        if (isIBase()) {
+            out << "// skipped IMPLEMENT_SERVICE_MANAGER_INTERACTIONS\n";
+        } else {
+            out << "IMPLEMENT_SERVICE_MANAGER_INTERACTIONS("
+                << baseName << ", "
+                << "\"" << iface->fqName().package()
+                << iface->fqName().atVersion()
+                << "\")\n";
+        }
     }
 
     enterLeaveNamespace(out, false /* enter */);
@@ -993,13 +1010,9 @@
             out, method->results(), true /* forResults */);
 
     out << "_hidl_err = _hidl_data.writeInterfaceToken(";
-    if (method->isHidlReserved()) {
-        out << "::android::hardware::IBase";
-    } else {
-        out << superInterface->fqName().cppNamespace()
-            << "::I"
-            << superInterface->getBaseName();
-    }
+    out << superInterface->fqName().cppNamespace()
+        << "::I"
+        << superInterface->getBaseName();
     out << "::descriptor);\n";
     out << "if (_hidl_err != ::android::OK) { goto _hidl_error; }\n\n";
 
@@ -1282,13 +1295,9 @@
         Formatter &out, const Interface *iface, const Method *method) const {
     out << "if (!_hidl_data.enforceInterface(";
 
-    if (method->isHidlReserved()) {
-        out << "::android::hardware::IBase";
-    } else {
-        out << iface->fqName().cppNamespace()
-            << "::I"
-            << iface->getBaseName();
-    }
+    out << iface->fqName().cppNamespace()
+        << "::I"
+        << iface->getBaseName();
 
     out << "::descriptor)) {\n";
 
diff --git a/generateJava.cpp b/generateJava.cpp
index ee76e18..df2b1c0 100644
--- a/generateJava.cpp
+++ b/generateJava.cpp
@@ -77,9 +77,6 @@
 
         out << "package " << mPackage.javaPackage() << ";\n\n";
 
-        for (const auto &item : mImportedNamesForJava) {
-            out << "import " << item.javaName() << ";\n";
-        }
         out << "\n";
 
         status_t err =
@@ -136,14 +133,6 @@
 
     out << "package " << mPackage.javaPackage() << ";\n\n";
 
-    for (const auto &item : mImportedNamesForJava) {
-        out << "import " << item.javaName() << ";\n";
-    }
-
-    if (!mImportedNamesForJava.empty()) {
-        out << "\n";
-    }
-
     out.setNamespace(mPackage.javaPackage() + ".");
 
     const Interface *superType = iface->superType();
diff --git a/hidl-gen_y.yy b/hidl-gen_y.yy
index 186fb61..85c0b8e 100644
--- a/hidl-gen_y.yy
+++ b/hidl-gen_y.yy
@@ -23,7 +23,6 @@
 #include "ConstantExpression.h"
 #include "EnumType.h"
 #include "FQName.h"
-#include "GenericBinder.h"
 #include "Interface.h"
 #include "Location.h"
 #include "Method.h"
@@ -52,7 +51,7 @@
 bool isValidInterfaceField(const char *identifier, std::string *errorMsg) {
     static const std::vector<std::string> reserved({
         // Injected names to interfaces by auto-generated code
-        "isRemote", "interfaceChain", "descriptor", "hidlStaticBlock", "onTransact",
+        "isRemote", "descriptor", "hidlStaticBlock", "onTransact",
         "castFrom", "version", "getInterfaceVersion",
 
         // Inherited names by interfaces from IInterface / IBinder
@@ -585,7 +584,22 @@
 interface_declaration
     : INTERFACE valid_identifier opt_extends
       {
-          if ($3 != NULL && !$3->isInterface()) {
+          Type *parent = $3;
+
+          if (ast->package() != gIBasePackageFqName) {
+              if (!ast->addImport(gIBaseFqName.string().c_str())) {
+                  std::cerr << "ERROR: Unable to automatically import '"
+                            << gIBaseFqName.string()
+                            << "' at " << @$
+                            << "\n";
+                  YYERROR;
+              }
+              if (parent == nullptr) {
+                parent = ast->lookupType(gIBaseFqName);
+              }
+          }
+
+          if (parent != NULL && !parent->isInterface()) {
               std::cerr << "ERROR: You can only extend interfaces. at " << @3
                         << "\n";
 
@@ -599,7 +613,7 @@
               YYERROR;
           }
 
-          Interface *iface = new Interface($2, convertYYLoc(@2), static_cast<Interface *>($3));
+          Interface *iface = new Interface($2, convertYYLoc(@2), static_cast<Interface *>(parent));
 
           // Register interface immediately so it can be referenced inside
           // definition.
@@ -975,7 +989,18 @@
     : array_type_base { $$ = $1; }
     | array_type { $$ = $1; }
     | annotated_compound_declaration { $$ = $1; }
-    | INTERFACE { $$ = new GenericBinder; }
+    | INTERFACE
+      {
+          // "interface" is a synonym of android.hidl.base@1.0::IBase
+          $$ = ast->lookupType(gIBaseFqName);
+          if ($$ == nullptr) {
+              std::cerr << "FATAL: Cannot find "
+                        << gIBaseFqName.string()
+                        << " at " << @1 << "\n";
+
+              YYERROR;
+      }
+    }
     ;
 
 %%
diff --git a/main.cpp b/main.cpp
index c33ce5e..4701757 100644
--- a/main.cpp
+++ b/main.cpp
@@ -188,10 +188,11 @@
     out.indent();
     out.indent();
     out << "\n$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \\"
-        << "\n-Ljava"
-        << " -r"
-        << coordinator->getPackageRoot(packageFQName) << ":"
-        << coordinator->getPackageRootPath(packageFQName) << " \\\n";
+        << "\n-Ljava \\"
+        << "\n-r"
+        << coordinator->getPackageRootOption(packageFQName) << " \\"
+        << "\n-r"
+        << coordinator->getPackageRootOption(gIBasePackageFqName) << " \\\n";
 
     out << packageFQName.string()
         << "::"
@@ -364,10 +365,11 @@
     out.indent();
     out.indent();
     out << "\n$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \\"
-        << "\n-Ljava-constants"
-        << " -r"
-        << coordinator->getPackageRoot(packageFQName) << ":"
-        << coordinator->getPackageRootPath(packageFQName) << " \\\n";
+        << "\n-Ljava-constants \\"
+        << "\n-r"
+        << coordinator->getPackageRootOption(packageFQName) << " \\"
+        << "\n-r"
+        << coordinator->getPackageRootOption(gIBasePackageFqName) << " \\\n";
 
     out << packageFQName.string();
     out << "\n";
@@ -587,8 +589,9 @@
     out << "cmd: \"$(location " << hidl_gen << ") -o $(genDir)"
         << " -L" << language
         << " -r"
-        << coordinator->getPackageRoot(packageFQName) << ":"
-        << coordinator->getPackageRootPath(packageFQName)
+        << coordinator->getPackageRootOption(packageFQName)
+        << " -r"
+        << coordinator->getPackageRootOption(gIBasePackageFqName)
         << " " << packageFQName.string() << "\",\n";
 
     out << "srcs: [\n";
diff --git a/test/java_test/Android.mk b/test/java_test/Android.mk
index 89e0067..ea8eebb 100644
--- a/test/java_test/Android.mk
+++ b/test/java_test/Android.mk
@@ -6,6 +6,7 @@
 LOCAL_MODULE_STEM := hidl_test_java
 LOCAL_MODULE_CLASS := JAVA_LIBRARIES
 LOCAL_JAVA_LIBRARIES :=                         \
+    android.hidl.base@1.0-java                  \
     android.hardware.tests.baz@1.0-java         \
     android.hardware.tests.expression@1.0-java  \
     android.hardware.tests.inheritance@1.0-java
@@ -25,6 +26,7 @@
 
 LOCAL_REQUIRED_MODULES :=                       \
     hidl_test_java_lib                          \
+    android.hidl.base@1.0-java                  \
     android.hardware.tests.baz@1.0-java
 
 include $(BUILD_PREBUILT)
diff --git a/test/java_test/hidl_test_java b/test/java_test/hidl_test_java
index e1171cc..e8876a2 100644
--- a/test/java_test/hidl_test_java
+++ b/test/java_test/hidl_test_java
@@ -1,5 +1,5 @@
 base=/system
-export CLASSPATH=$base/framework/hidl_test_java.jar:$base/framework/android.hardware.tests.baz@1.0-java.jar
+export CLASSPATH=$base/framework/hidl_test_java.jar:$base/framework/android.hardware.tests.baz@1.0-java.jar:$base/framework/android.hidl.base@1.0-java.jar
 
 # Test native server with Java client
 hidl_test_java_native -s &
diff --git a/test/main.cpp b/test/main.cpp
index 636dca2..f778fe4 100644
--- a/test/main.cpp
+++ b/test/main.cpp
@@ -993,23 +993,29 @@
 }
 
 TEST_F(HidlTest, FooHaveAVectorOfGenericInterfacesTest) {
-    using ::android::hardware::tests::foo::V1_0::IHwSimple;
-    using ::android::hardware::tests::foo::V1_0::BnSimple;
 
-    hidl_vec<sp<android::hardware::IBinder> > in;
+    hidl_vec<sp<::android::hidl::base::V1_0::IBase> > in;
     in.resize(16);
     for (size_t i = 0; i < in.size(); ++i) {
-        sp<BnSimple> simpleStub = new BnSimple(new Simple(i));
-        in[i] = IHwSimple::asBinder(simpleStub);
+        sp<ISimple> s = new Simple(i);
+        in[i] = s;
     }
 
     EXPECT_OK(foo->haveAVectorOfGenericInterfaces(
                 in,
                 [&](const auto &out) {
                     EXPECT_EQ(in.size(), out.size());
+
+                    EXPECT_OK(out[0]->interfaceChain([](const auto &names) {
+                        ASSERT_GT(names.size(), 0u);
+                        ASSERT_STREQ(names[0].c_str(), ISimple::descriptor);
+                    }));
                     for (size_t i = 0; i < in.size(); ++i) {
-                        sp<ISimple> inSimple = IHwSimple::asInterface(in[i]);
-                        sp<ISimple> outSimple = IHwSimple::asInterface(out[i]);
+                        sp<ISimple> inSimple = ISimple::castFrom(in[i]);
+                        sp<ISimple> outSimple = ISimple::castFrom(out[i]);
+
+                        ASSERT_NE(inSimple.get(), nullptr);
+                        ASSERT_NE(outSimple.get(), nullptr);
 
                         int32_t inCookie = inSimple->getCookie();
                         int32_t outCookie = outSimple->getCookie();
diff --git a/test/vendor/1.0/Android.bp b/test/vendor/1.0/Android.bp
index c7c0947..7f3aa3e 100644
--- a/test/vendor/1.0/Android.bp
+++ b/test/vendor/1.0/Android.bp
@@ -3,7 +3,7 @@
 genrule {
     name: "tests.vendor@1.0_genc++",
     tools: ["hidl-gen"],
-    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -rtests:system/tools/hidl/test/ tests.vendor@1.0",
+    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -rtests:system/tools/hidl/test/ -randroid.hidl:system/libhidl/transport tests.vendor@1.0",
     srcs: [
         "IVendor.hal",
     ],
@@ -15,7 +15,7 @@
 genrule {
     name: "tests.vendor@1.0_genc++_headers",
     tools: ["hidl-gen"],
-    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -rtests:system/tools/hidl/test/ tests.vendor@1.0",
+    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -rtests:system/tools/hidl/test/ -randroid.hidl:system/libhidl/transport tests.vendor@1.0",
     srcs: [
         "IVendor.hal",
     ],
@@ -40,11 +40,13 @@
         "liblog",
         "libutils",
         "libcutils",
+        "android.hidl.base@1.0",
     ],
     export_shared_lib_headers: [
         "libhidlbase",
         "libhidltransport",
         "libhwbinder",
         "libutils",
+        "android.hidl.base@1.0",
     ],
 }
diff --git a/test/vendor/1.0/update-makefile.sh b/test/vendor/1.0/update-makefile.sh
index e286c22..0b61759 100755
--- a/test/vendor/1.0/update-makefile.sh
+++ b/test/vendor/1.0/update-makefile.sh
@@ -1,4 +1,4 @@
 #!/bin/bash
 
-hidl-gen -Lmakefile -r tests:system/tools/hidl/test/ tests.vendor@1.0;
-hidl-gen -Landroidbp -r tests:system/tools/hidl/test/ tests.vendor@1.0;
\ No newline at end of file
+hidl-gen -Lmakefile -r tests:system/tools/hidl/test/ -randroid.hidl:system/libhidl/transport tests.vendor@1.0;
+hidl-gen -Landroidbp -r tests:system/tools/hidl/test/ -randroid.hidl:system/libhidl/transport tests.vendor@1.0;