Clean up hard-coded Bp/Bn/Bs/IHw prefixes.

Also,
* use iface->localName() instead of "I" + iface->getBaseName()
* do not hardcode IBase related strings
* remove baseName in some places

Bug: 32559427
Test: hidl_test
Change-Id: Ib2049f570ca27d33a945dd6ccb5442e336a11262
diff --git a/AST.h b/AST.h
index ffd63b1..7310942 100644
--- a/AST.h
+++ b/AST.h
@@ -200,10 +200,10 @@
     void generateFetchSymbol(Formatter &out, const std::string &ifaceName) const;
 
     status_t generateProxySource(
-            Formatter &out, const std::string &baseName) const;
+            Formatter &out, const FQName &fqName) const;
 
     status_t generateStubSource(
-            Formatter &out, const Interface *iface, const std::string &baseName) const;
+            Formatter &out, const Interface *iface) const;
 
     status_t generateStubSourceForMethod(
             Formatter &out, const Interface *iface, const Method *method) const;
diff --git a/FQName.cpp b/FQName.cpp
index 700af9f..5e9e347 100644
--- a/FQName.cpp
+++ b/FQName.cpp
@@ -281,12 +281,44 @@
     return !(*this == other);
 }
 
-std::string FQName::getInterfaceBaseName() const {
+std::string FQName::getInterfaceName() const {
     CHECK(names().size() == 1) << "Must be a top level type";
     CHECK(!mName.empty() && mName[0] == 'I') << mName;
 
+    return mName;
+}
+
+std::string FQName::getInterfaceBaseName() const {
     // cut off the leading 'I'.
-    return mName.substr(1);
+    return getInterfaceName().substr(1);
+}
+
+std::string FQName::getInterfaceHwName() const {
+    return "IHw" + getInterfaceBaseName();
+}
+
+std::string FQName::getInterfaceProxyName() const {
+    return "Bp" + getInterfaceBaseName();
+}
+
+std::string FQName::getInterfaceStubName() const {
+    return "Bn" + getInterfaceBaseName();
+}
+
+std::string FQName::getInterfacePassthroughName() const {
+    return "Bs" + getInterfaceBaseName();
+}
+
+FQName FQName::getInterfaceProxyFqName() const {
+    return FQName(package(), version(), getInterfaceProxyName());
+}
+
+FQName FQName::getInterfaceStubFqName() const {
+    return FQName(package(), version(), getInterfaceStubName());
+}
+
+FQName FQName::getInterfacePassthroughFqName() const {
+    return FQName(package(), version(), getInterfacePassthroughName());
 }
 
 FQName FQName::getTypesForPackage() const {
diff --git a/FQName.h b/FQName.h
index d4601ab..de47bc3 100644
--- a/FQName.h
+++ b/FQName.h
@@ -101,10 +101,50 @@
     bool operator!=(const FQName &other) const;
 
     // Must be called on an interface
-    // ::android::hardware::Foo::V1_0::IBar
+    // android.hardware.foo@1.0::IBar
     // -> Bar
     std::string getInterfaceBaseName() const;
 
+    // Must be called on an interface
+    // android.hardware.foo@1.0::IBar
+    // -> IBar
+    std::string getInterfaceName() const;
+
+    // Must be called on an interface
+    // android.hardware.foo@1.0::IBar
+    // -> IHwBar
+    std::string getInterfaceHwName() const;
+
+    // Must be called on an interface
+    // android.hardware.foo@1.0::IBar
+    // -> BpBar
+    std::string getInterfaceProxyName() const;
+
+    // Must be called on an interface
+    // android.hardware.foo@1.0::IBar
+    // -> BnBar
+    std::string getInterfaceStubName() const;
+
+    // Must be called on an interface
+    // android.hardware.foo@1.0::IBar
+    // -> BsBar
+    std::string getInterfacePassthroughName() const;
+
+    // Must be called on an interface
+    // android.hardware.foo@1.0::IBar
+    // -> android.hardware.foo@1.0::BpBar
+    FQName getInterfaceProxyFqName() const;
+
+    // Must be called on an interface
+    // android.hardware.foo@1.0::IBar
+    // -> android.hardware.foo@1.0::BnBar
+    FQName getInterfaceStubFqName() const;
+
+    // Must be called on an interface
+    // android.hardware.foo@1.0::IBar
+    // -> android.hardware.foo@1.0::BsBar
+    FQName getInterfacePassthroughFqName() const;
+
     // Replace whatever after :: with "types"
     // android.hardware.foo@1.0::Abc.Type:VALUE
     // -> android.hardware.foo@1.0::types
diff --git a/Interface.cpp b/Interface.cpp
index 50125d3..4c9e9a5 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -330,16 +330,32 @@
     return fqName().getInterfaceBaseName();
 }
 
+std::string Interface::getProxyName() const {
+    return fqName().getInterfaceProxyName();
+}
+
+std::string Interface::getStubName() const {
+    return fqName().getInterfaceStubName();
+}
+
+std::string Interface::getHwName() const {
+    return fqName().getInterfaceHwName();
+}
+
+std::string Interface::getPassthroughName() const {
+    return fqName().getInterfacePassthroughName();
+}
+
 FQName Interface::getProxyFqName() const {
-    return FQName(fqName().package(), fqName().version(), "Bp" + getBaseName());
+    return fqName().getInterfaceProxyFqName();
 }
 
 FQName Interface::getStubFqName() const {
-    return FQName(fqName().package(), fqName().version(), "Bn" + getBaseName());
+    return fqName().getInterfaceStubFqName();
 }
 
 FQName Interface::getPassthroughFqName() const {
-    return FQName(fqName().package(), fqName().version(), "Bs" + getBaseName());
+    return fqName().getInterfacePassthroughFqName();
 }
 
 std::string Interface::getCppType(StorageMode mode,
diff --git a/Interface.h b/Interface.h
index 296a4ae..6cde462 100644
--- a/Interface.h
+++ b/Interface.h
@@ -64,8 +64,12 @@
     // this->hidlReservedMethods()
     std::vector<InterfaceAndMethod> allMethodsFromRoot() const;
 
+    // aliases for corresponding methods in this->fqName()
     std::string getBaseName() const;
-
+    std::string getProxyName() const;
+    std::string getStubName() const;
+    std::string getPassthroughName() const;
+    std::string getHwName() const;
     FQName getProxyFqName() const;
     FQName getStubFqName() const;
     FQName getPassthroughFqName() const;
diff --git a/generateCpp.cpp b/generateCpp.cpp
index b1661c7..69b5f8e 100644
--- a/generateCpp.cpp
+++ b/generateCpp.cpp
@@ -125,8 +125,8 @@
     }
 }
 
-static void declareServiceManagerInteractions(Formatter &out, const std::string &baseName) {
-    out << "static ::android::sp<I" << baseName << "> getService("
+static void declareServiceManagerInteractions(Formatter &out, const std::string &interfaceName) {
+    out << "static ::android::sp<" << interfaceName << "> getService("
         << "const std::string &serviceName, bool getStub=false);\n";
     out << "::android::status_t registerAsService(const std::string &serviceName);\n";
     out << "static bool registerForNotifications(\n";
@@ -139,24 +139,26 @@
 }
 
 static void implementServiceManagerInteractions(Formatter &out,
-        const std::string &baseName, const std::string &package) {
+        const FQName &fqName, const std::string &package) {
+
+    const std::string interfaceName = fqName.getInterfaceName();
 
     out << "// static\n"
-        << "::android::sp<I" << baseName << "> I" << baseName << "::getService("
+        << "::android::sp<" << interfaceName << "> " << interfaceName << "::getService("
         << "const std::string &serviceName, bool getStub) ";
     out.block([&] {
-        out << "::android::sp<I" << baseName << "> iface;\n"
+        out << "::android::sp<" << interfaceName << "> iface;\n"
             << "const ::android::sp<::android::hidl::manager::V1_0::IServiceManager> sm\n";
         out.indent(2, [&] {
             out << "= ::android::hardware::defaultServiceManager();\n";
         });
         out.sIf("sm != nullptr && !getStub", [&] {
-            out << "::android::hardware::Return<::android::sp<::android::hidl::base::V1_0::IBase>> ret = \n";
+            out << "::android::hardware::Return<::android::sp<" << gIBaseFqName.cppName() << ">> ret = \n";
             out.indent(2, [&] {
-                out << "sm->get(\"" << package << "::I" << baseName << "\", serviceName.c_str());\n";
+                out << "sm->get(\"" << package << "::" << interfaceName << "\", serviceName.c_str());\n";
             });
             out.sIf("ret.isOk()", [&] {
-                out << "iface = I" << baseName << "::castFrom(ret);\n";
+                out << "iface = " << interfaceName << "::castFrom(ret);\n";
                 out.sIf("iface != nullptr", [&] {
                     out << "return iface;\n";
                 }).endl();
@@ -175,18 +177,18 @@
         out.sIf("handle == nullptr", [&] {
             out << "return iface;\n";
         }).endl();
-        out << "I" << baseName << "* (*generator)(const char* name);\n"
-            << "*(void **)(&generator) = dlsym(handle, \"HIDL_FETCH_I" << baseName << "\");\n";
+        out << "" << interfaceName << "* (*generator)(const char* name);\n"
+            << "*(void **)(&generator) = dlsym(handle, \"HIDL_FETCH_" << interfaceName << "\");\n";
         out.sIf("generator", [&] {
             out << "iface = (*generator)(serviceName.c_str());\n";
             out.sIf("iface != nullptr", [&] {
-                out << "iface = new Bs" << baseName << "(iface);\n";
+                out << "iface = new " << fqName.getInterfacePassthroughName() << "(iface);\n";
             }).endl();
         }).endl();
         out << "return iface;\n";
     }).endl().endl();
 
-    out << "::android::status_t I" << baseName << "::registerAsService("
+    out << "::android::status_t " << interfaceName << "::registerAsService("
         << "const std::string &serviceName) ";
     out.block([&] {
         out << "const ::android::sp<::android::hidl::manager::V1_0::IServiceManager> sm\n";
@@ -212,7 +214,7 @@
         out << "return success ? ::android::OK : ::android::UNKNOWN_ERROR;\n";
     }).endl().endl();
 
-    out << "bool I" << baseName << "::registerForNotifications(\n";
+    out << "bool " << interfaceName << "::registerForNotifications(\n";
     out.indent(2, [&] {
         out << "const std::string &serviceName,\n"
             << "const ::android::sp<::android::hidl::manager::V1_0::IServiceNotification> "
@@ -228,7 +230,7 @@
         }).endl();
         out << "::android::hardware::Return<bool> success =\n";
         out.indent(2, [&] {
-            out << "sm->registerForNotifications(\"" << package << "::I" << baseName << "\",\n";
+            out << "sm->registerForNotifications(\"" << package << "::" << interfaceName << "\",\n";
             out.indent(2, [&] {
                 out << "serviceName, notification);\n";
             });
@@ -324,7 +326,7 @@
     if (isInterface) {
         const Interface *iface = mRootScope->getInterface();
         const Interface *superType = iface->superType();
-        const std::string baseName = iface->getBaseName();
+
         out << "virtual bool isRemote() const ";
         if (!isIBase()) {
             out << "override ";
@@ -400,7 +402,7 @@
         if (isIBase()) {
             out << "// skipped getService, registerAsService, registerForNotifications\n\n";
         } else {
-            declareServiceManagerInteractions(out, baseName);
+            declareServiceManagerInteractions(out, iface->localName());
         }
 
         out << "private: static int hidlStaticBlock;\n";
@@ -430,13 +432,11 @@
     std::string ifaceName;
     bool isInterface = AST::isInterface(&ifaceName);
     const Interface *iface = nullptr;
-    std::string baseName{};
     std::string klassName{};
 
     if(isInterface) {
         iface = mRootScope->getInterface();
-        baseName = iface->getBaseName();
-        klassName = "IHw" + baseName;
+        klassName = iface->getHwName();
     } else {
         klassName = "hwtypes";
     }
@@ -471,8 +471,8 @@
         if (item.name() == "types") {
             generateCppPackageInclude(out, item, "hwtypes");
         } else {
-            generateCppPackageInclude(out, item, "Bn" + item.getInterfaceBaseName());
-            generateCppPackageInclude(out, item, "Bp" + item.getInterfaceBaseName());
+            generateCppPackageInclude(out, item, item.getInterfaceStubName());
+            generateCppPackageInclude(out, item, item.getInterfaceProxyName());
         }
     }
 
@@ -706,8 +706,7 @@
     }
 
     const Interface *iface = mRootScope->getInterface();
-    const std::string baseName = iface->getBaseName();
-    const std::string klassName = "Bn" + baseName;
+    const std::string klassName = iface->getStubName();
 
     std::string path = outputPath;
     path.append(mCoordinator->convertPackageRootToPath(mPackage));
@@ -729,29 +728,30 @@
     out << "#ifndef " << guard << "\n";
     out << "#define " << guard << "\n\n";
 
-    generateCppPackageInclude(out, mPackage, "IHw" + baseName);
+    generateCppPackageInclude(out, mPackage, iface->getHwName());
     out << "\n";
 
     enterLeaveNamespace(out, true /* enter */);
     out << "\n";
 
     out << "struct "
-        << "Bn"
-        << baseName;
+        << klassName;
     if (iface->isIBase()) {
         out << " : public ::android::hardware::BBinder";
         out << ", public ::android::hardware::HidlInstrumentor {\n";
     } else {
-        out << " : public ::android::hidl::base::V1_0::BnBase {\n";
+        out << " : public "
+            << gIBaseFqName.getInterfaceStubFqName().cppName()
+            << " {\n";
     }
 
     out.indent();
-    out << "explicit Bn"
-        << baseName
+    out << "explicit "
+        << klassName
         << "(const ::android::sp<" << ifaceName << "> &_hidl_impl);"
         << "\n";
-    out << "explicit Bn"
-        << baseName
+    out << "explicit "
+        << klassName
         << "(const ::android::sp<" << ifaceName << "> &_hidl_impl,"
         << " const std::string& prefix);"
         << "\n\n";
@@ -789,13 +789,12 @@
     }
 
     const Interface *iface = mRootScope->getInterface();
-    const std::string baseName = iface->getBaseName();
+    const std::string proxyName = iface->getProxyName();
 
     std::string path = outputPath;
     path.append(mCoordinator->convertPackageRootToPath(mPackage));
     path.append(mCoordinator->getPackagePath(mPackage, true /* relative */));
-    path.append("Bp");
-    path.append(baseName);
+    path.append(proxyName);
     path.append(".h");
 
     CHECK(Coordinator::MakeParentHierarchy(path));
@@ -807,7 +806,7 @@
 
     Formatter out(file);
 
-    const std::string guard = makeHeaderGuard("Bp" + baseName);
+    const std::string guard = makeHeaderGuard(proxyName);
 
     out << "#ifndef " << guard << "\n";
     out << "#define " << guard << "\n\n";
@@ -818,23 +817,22 @@
     getPackageAndVersionComponents(
             &packageComponents, false /* cpp_compatible */);
 
-    generateCppPackageInclude(out, mPackage, "IHw" + baseName);
+    generateCppPackageInclude(out, mPackage, iface->getHwName());
     out << "\n";
 
     enterLeaveNamespace(out, true /* enter */);
     out << "\n";
 
     out << "struct "
-        << "Bp"
-        << baseName
-        << " : public ::android::hardware::BpInterface<I"
-        << baseName
+        << proxyName
+        << " : public ::android::hardware::BpInterface<"
+        << iface->localName()
         << ">, public ::android::hardware::HidlInstrumentor {\n";
 
     out.indent();
 
-    out << "explicit Bp"
-        << baseName
+    out << "explicit "
+        << proxyName
         << "(const ::android::sp<::android::hardware::IBinder> &_hidl_impl);"
         << "\n\n";
 
@@ -910,14 +908,14 @@
         // This is a no-op for IServiceManager itself.
         out << "#include <android/hidl/manager/1.0/IServiceManager.h>\n";
 
-        generateCppPackageInclude(out, mPackage, "Bp" + baseName);
-        generateCppPackageInclude(out, mPackage, "Bn" + baseName);
-        generateCppPackageInclude(out, mPackage, "Bs" + baseName);
+        generateCppPackageInclude(out, mPackage, iface->getProxyName());
+        generateCppPackageInclude(out, mPackage, iface->getStubName());
+        generateCppPackageInclude(out, mPackage, iface->getPassthroughName());
 
         for (const Interface *superType : iface->superTypeChain()) {
             generateCppPackageInclude(out,
                                       superType->fqName(),
-                                      "Bp" + superType->getBaseName());
+                                      superType->fqName().getInterfaceProxyName());
         }
 
         out << "#include <hidl/ServiceManagement.h>\n";
@@ -937,42 +935,42 @@
         const Interface *iface = mRootScope->getInterface();
 
         // need to be put here, generateStubSource is using this.
-        out << "const char* I"
-            << iface->getBaseName()
+        out << "const char* "
+            << iface->localName()
             << "::descriptor(\""
             << iface->fqName().string()
             << "\");\n\n";
 
-        out << "int I"
-            << iface->getBaseName()
+        out << "int "
+            << iface->localName()
             << "::hidlStaticBlock = []() -> int {\n";
         out.indent([&] {
-            out << "::android::hardware::gBnConstructorMap[I"
-                << iface->getBaseName()
+            out << "::android::hardware::gBnConstructorMap["
+                << iface->localName()
                 << "::descriptor]\n";
             out.indent(2, [&] {
                 out << "= [](void *iIntf) -> ::android::sp<::android::hardware::IBinder> {\n";
                 out.indent([&] {
-                    out << "return new Bn"
-                        << iface->getBaseName()
-                        << "(reinterpret_cast<I"
-                        << iface->getBaseName()
+                    out << "return new "
+                        << iface->getStubName()
+                        << "(reinterpret_cast<"
+                        << iface->localName()
                         << " *>(iIntf));\n";
                 });
                 out << "};\n";
             });
-            out << "::android::hardware::gBsConstructorMap[I"
-                << iface->getBaseName()
+            out << "::android::hardware::gBsConstructorMap["
+                << iface->localName()
                 << "::descriptor]\n";
             out.indent(2, [&] {
                 out << "= [](void *iIntf) -> ::android::sp<"
                     << gIBaseFqName.cppName()
                     << "> {\n";
                 out.indent([&] {
-                    out << "return new Bs"
-                        << iface->getBaseName()
-                        << "(reinterpret_cast<I"
-                        << iface->getBaseName()
+                    out << "return new "
+                        << iface->getPassthroughName()
+                        << "(reinterpret_cast<"
+                        << iface->localName()
                         << " *>(iIntf));\n";
                 });
                 out << "};\n";
@@ -985,11 +983,11 @@
     }
 
     if (err == OK && isInterface) {
-        err = generateProxySource(out, baseName);
+        err = generateProxySource(out, iface->fqName());
     }
 
     if (err == OK && isInterface) {
-        err = generateStubSource(out, iface, baseName);
+        err = generateStubSource(out, iface);
     }
 
     if (err == OK && isInterface) {
@@ -1005,7 +1003,7 @@
             std::string package = iface->fqName().package()
                     + iface->fqName().atVersion();
 
-            implementServiceManagerInteractions(out, baseName, package);
+            implementServiceManagerInteractions(out, iface->fqName(), package);
         }
     }
 
@@ -1133,9 +1131,7 @@
             out, method->results(), true /* forResults */);
 
     out << "_hidl_err = _hidl_data.writeInterfaceToken(";
-    out << superInterface->fqName().cppNamespace()
-        << "::I"
-        << superInterface->getBaseName();
+    out << superInterface->fqName().cppName();
     out << "::descriptor);\n";
     out << "if (_hidl_err != ::android::OK) { goto _hidl_error; }\n\n";
 
@@ -1270,8 +1266,8 @@
 }
 
 status_t AST::generateProxySource(
-        Formatter &out, const std::string &baseName) const {
-    const std::string klassName = "Bp" + baseName;
+        Formatter &out, const FQName &fqName) const {
+    const std::string klassName = fqName.getInterfaceProxyName();
 
     out << klassName
         << "::"
@@ -1282,13 +1278,13 @@
     out.indent();
 
     out << ": BpInterface"
-        << "<I"
-        << baseName
+        << "<"
+        << fqName.getInterfaceName()
         << ">(_hidl_impl),\n"
         << "  ::android::hardware::HidlInstrumentor(\""
         << mPackage.string()
-        << "::I"
-        << baseName
+        << "::"
+        << fqName.getInterfaceName()
         << "\") {\n";
 
     out.unindent();
@@ -1304,14 +1300,14 @@
 
 status_t AST::generateStubSource(
         Formatter &out,
-        const Interface *iface,
-        const std::string &baseName) const {
-    const std::string klassName = "Bn" + baseName;
+        const Interface *iface) const {
+    const std::string interfaceName = iface->localName();
+    const std::string klassName = iface->getStubName();
 
     out << klassName
         << "::"
         << klassName
-        << "(const ::android::sp<I" << baseName <<"> &_hidl_impl)\n";
+        << "(const ::android::sp<" << interfaceName <<"> &_hidl_impl)\n";
 
     out.indent();
     out.indent();
@@ -1319,12 +1315,14 @@
     if (iface->isIBase()) {
         out << ": ::android::hardware::HidlInstrumentor(\"";
     } else {
-        out << ": ::android::hidl::base::V1_0::BnBase(_hidl_impl, \"";
+        out << ": "
+            << gIBaseFqName.getInterfaceStubFqName().cppName()
+            << "(_hidl_impl, \"";
     }
 
     out << mPackage.string()
-        << "::I"
-        << baseName
+        << "::"
+        << interfaceName
         << "\") { \n";
     out.indent();
     out << "_hidl_mImpl = _hidl_impl;\n";
@@ -1340,7 +1338,7 @@
         out << klassName
             << "::"
             << klassName
-            << "(const ::android::sp<I" << baseName <<"> &_hidl_impl,"
+            << "(const ::android::sp<" << interfaceName <<"> &_hidl_impl,"
             << " const std::string &prefix)\n";
 
         out.indent();
@@ -1440,13 +1438,9 @@
         return OK;
     }
 
-    out << "if (!_hidl_data.enforceInterface(";
-
-    out << iface->fqName().cppNamespace()
-        << "::I"
-        << iface->getBaseName();
-
-    out << "::descriptor)) {\n";
+    out << "if (!_hidl_data.enforceInterface("
+        << iface->fullName()
+        << "::descriptor)) {\n";
 
     out.indent();
     out << "_hidl_err = ::android::BAD_TYPE;\n";
@@ -1666,8 +1660,7 @@
 
     const Interface *iface = mRootScope->getInterface();
 
-    const std::string baseName = iface->getBaseName();
-    const std::string klassName = "Bs" + baseName;
+    const std::string klassName = iface->getPassthroughName();
 
     bool supportOneway = iface->hasOnewayMethods();
 
@@ -1763,8 +1756,8 @@
     for (const Interface *superType : iface->typeChain()) {
         out << "// static \n"
             << childTypeResult
-            << " I"
-            << iface->getBaseName()
+            << " "
+            << iface->localName()
             << "::castFrom("
             << superType->getCppArgumentType()
             << " parent) {\n";
@@ -1773,9 +1766,9 @@
             out << "return parent;\n";
         } else {
             out << "return ::android::hardware::castInterface<";
-            out << "I" << iface->getBaseName() << ", "
+            out << iface->localName() << ", "
                 << superType->fqName().cppName() << ", "
-                << iface->getProxyFqName().cppLocalName() << ", "
+                << iface->getProxyName() << ", "
                 << superType->getProxyFqName().cppName()
                 << ">(\n";
             out.indent();
@@ -1796,8 +1789,7 @@
 status_t AST::generatePassthroughSource(Formatter &out) const {
     const Interface *iface = mRootScope->getInterface();
 
-    const std::string baseName = iface->getBaseName();
-    const std::string klassName = "Bs" + baseName;
+    const std::string klassName = iface->getPassthroughName();
 
     out << klassName
         << "::"
@@ -1846,7 +1838,7 @@
                                     InstrumentationEvent event,
                                     const Method *method) const {
     const Interface *iface = mRootScope->getInterface();
-    std::string baseString = "HIDL::I" + iface->getBaseName() + "::" + method->name();
+    std::string baseString = "HIDL::" + iface->localName() + "::" + method->name();
     switch (event) {
         case SERVER_API_ENTRY:
         {
diff --git a/generateCppImpl.cpp b/generateCppImpl.cpp
index cb3487b..3c2d9b7 100644
--- a/generateCppImpl.cpp
+++ b/generateCppImpl.cpp
@@ -108,7 +108,7 @@
     out << "#ifndef " << guard << "\n";
     out << "#define " << guard << "\n\n";
 
-    generateCppPackageInclude(out, mPackage, "I" + baseName);
+    generateCppPackageInclude(out, mPackage, iface->localName());
 
     out << "#include <hidl/MQDescriptor.h>\n";
     out << "#include <hidl/Status.h>\n\n";
diff --git a/main.cpp b/main.cpp
index 6367e39..e347a91 100644
--- a/main.cpp
+++ b/main.cpp
@@ -953,10 +953,10 @@
             [&pathPrefix](Formatter &out, const FQName &fqName) {
                 out << "\"" << pathPrefix << fqName.name() << ".h\",\n";
                 if (fqName.name() != "types") {
-                    out << "\"" << pathPrefix << "IHw" << fqName.name().substr(1) << ".h\",\n";
-                    out << "\"" << pathPrefix << "Bn" << fqName.name().substr(1) << ".h\",\n";
-                    out << "\"" << pathPrefix << "Bp" << fqName.name().substr(1) << ".h\",\n";
-                    out << "\"" << pathPrefix << "Bs" << fqName.name().substr(1) << ".h\",\n";
+                    out << "\"" << pathPrefix << fqName.getInterfaceHwName() << ".h\",\n";
+                    out << "\"" << pathPrefix << fqName.getInterfaceStubName() << ".h\",\n";
+                    out << "\"" << pathPrefix << fqName.getInterfaceProxyName() << ".h\",\n";
+                    out << "\"" << pathPrefix << fqName.getInterfacePassthroughName() << ".h\",\n";
                 }
             });