Stop generating IHw classes.

The main rationale of the IHw class was to be able
to cast binder objects to/from interfaces safely.
That functionality is now taking over by interfaceChain()
in IBase, together with the toBinder()/fromBinder() functions
in libhidl.

The remaining binder objects related to IFoo are now just
BpFoo and BnFoo, and both still inherit from IInterface.

Note that the IHw *header* itself remains, as it contains the
declarations for reading/writing datatypes related to the
interface into a Parcel.

Test: mma, hidl_test, hidl_test_java
Bug: 33173166
Change-Id: I6bbe1228830a413058d0e9dbb6345ed1c01aa97d
diff --git a/Interface.cpp b/Interface.cpp
index 36179e7..4117177 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -219,10 +219,6 @@
     return fqName().getInterfaceBaseName();
 }
 
-FQName Interface::getHwName() const {
-    return FQName(fqName().package(), fqName().version(), "IHw" + getBaseName());
-}
-
 FQName Interface::getProxyName() const {
     return FQName(fqName().package(), fqName().version(), "Bp" + getBaseName());
 }
@@ -295,10 +291,13 @@
 
         out << name
             << " = "
-            << fqName().cppNamespace()
-            << "::IHw"
-            << getBaseName()
-            << "::asInterface("
+            << "::android::hardware::fromBinder<"
+            << fqName().cppName()
+            << ","
+            << getProxyName().cppName()
+            << ","
+            << getStubName().cppName()
+            << ">("
             << binderName
             << ");\n";
 
@@ -316,13 +315,9 @@
         out << "::android::sp<::android::hardware::IBinder> _hidl_binder = "
             << "::android::hardware::toBinder<\n";
         out.indentBlock(2, [&] {
-            out << fqName().cppNamespace()
-                << "::I"
-                << getBaseName()
+            out << fqName().cppName()
                 << ", "
-                << fqName().cppNamespace()
-                << "::IHw"
-                << getBaseName()
+                << getProxyName().cppName()
                 << ">("
                 << name
                 << ");\n";
diff --git a/Interface.h b/Interface.h
index a786ce3..a21a036 100644
--- a/Interface.h
+++ b/Interface.h
@@ -65,7 +65,6 @@
 
     std::string getBaseName() const;
 
-    FQName getHwName() const;
     FQName getProxyName() const;
     FQName getStubName() const;
     FQName getPassthroughName() const;
diff --git a/generateCpp.cpp b/generateCpp.cpp
index 9bf1b33..e282353 100644
--- a/generateCpp.cpp
+++ b/generateCpp.cpp
@@ -369,6 +369,7 @@
             generateCppPackageInclude(out, item, "hwtypes");
         } else {
             generateCppPackageInclude(out, item, "Bn" + item.getInterfaceBaseName());
+            generateCppPackageInclude(out, item, "Bp" + item.getInterfaceBaseName());
         }
     }
 
@@ -377,35 +378,11 @@
     out << "#include <hidl/HidlTransportSupport.h>\n";
     out << "#include <hidl/Status.h>\n";
     out << "#include <hwbinder/IBinder.h>\n";
-    out << "#include <hwbinder/IInterface.h>\n";
 
     out << "\n";
 
     enterLeaveNamespace(out, true /* enter */);
 
-    if (isInterface) {
-        out << "\n";
-
-        out << "struct "
-            << klassName
-            << " : public "
-            << ifaceName;
-
-        const Interface *superType = iface->superType();
-
-        out << ", public ::android::hardware::IInterface";
-
-        out << " {\n";
-
-        out.indent();
-
-        out << "DECLARE_HWBINDER_META_INTERFACE(" << baseName << ");\n\n";
-
-        out.unindent();
-
-        out << "};\n\n";
-    }
-
     status_t err = mRootScope->emitGlobalHwDeclarations(out);
     if (err != OK) {
         return err;
@@ -643,7 +620,7 @@
         << "Bn"
         << baseName
         << " : public ::android::hardware::BnInterface<I"
-        << baseName << ", IHw" << baseName
+        << baseName
         << ">, public ::android::hardware::HidlInstrumentor {\n";
 
     out.indent();
@@ -725,7 +702,7 @@
     out << "struct "
         << "Bp"
         << baseName
-        << " : public ::android::hardware::BpInterface<IHw"
+        << " : public ::android::hardware::BpInterface<I"
         << baseName
         << ">, public ::android::hardware::HidlInstrumentor {\n";
 
@@ -1150,7 +1127,7 @@
     out.indent();
 
     out << ": BpInterface"
-        << "<IHw"
+        << "<I"
         << baseName
         << ">(_hidl_impl),\n"
         << "  ::android::hardware::HidlInstrumentor(\""
@@ -1172,14 +1149,6 @@
 
 status_t AST::generateStubSource(
         Formatter &out, const std::string &baseName) const {
-    out << "IMPLEMENT_HWBINDER_META_INTERFACE("
-        << baseName
-        << ", "
-        << mPackage.cppNamespace()
-        << "::I"
-        << baseName
-        << "::descriptor);\n\n";
-
     const std::string klassName = "Bn" + baseName;
 
     out << klassName
@@ -1193,8 +1162,6 @@
     out << ": BnInterface"
         << "<I"
         << baseName
-        << ", IHw"
-        << baseName
         << ">(_hidl_impl),\n"
         << "  ::android::hardware::HidlInstrumentor(\""
         << mPackage.string()
@@ -1251,7 +1218,7 @@
     out.indent();
 
     out << "return ::android::hardware::BnInterface<I"
-        << baseName << ", IHw" << baseName
+        << baseName
         << ">::onTransact(\n";
 
     out.indent();
@@ -1625,8 +1592,8 @@
             out << "return ::android::hardware::castInterface<";
             out << "I" << iface->getBaseName() << ", "
                 << superType->fqName().cppName() << ", "
-                << "Bp" << iface->getBaseName() << ", "
-                << superType->getHwName().cppName()
+                << iface->getProxyName().cppLocalName() << ", "
+                << superType->getProxyName().cppName()
                 << ">(\n";
             out.indent();
             out.indent();