Add is_inherited field for each API in generated .vts file

* Currently if a HAL interface is extended from another inteface,
  hidl-gen will generate all methods (both inherited and defined within
  the interface) in the output .vts file. Add the flag is_inherited to
  distinguish the ones inherited from other APIs.
* This is used in vts to get the total APIs defiend with each interface
  which which be used for API coverage measurment.

Bug: 110851162
Test: make vts
Change-Id: I307178d1c849b5dc8be01338b458cb96e6dc1294
diff --git a/Interface.cpp b/Interface.cpp
index e0c99d6..9fb7442 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -918,7 +918,7 @@
     }
 }
 
-void Interface::emitVtsMethodDeclaration(Formatter& out) const {
+void Interface::emitVtsMethodDeclaration(Formatter& out, bool isInherited) const {
     for (const auto &method : methods()) {
         if (method->isHidlReserved()) {
             continue;
@@ -927,6 +927,7 @@
         out << "api: {\n";
         out.indent();
         out << "name: \"" << method->name() << "\"\n";
+        out << "is_inherited: " << (isInherited ? "true" : "false") << "\n";
         // Generate declaration for each return value.
         for (const auto &result : method->results()) {
             out << "return_type_hidl: {\n";
diff --git a/Interface.h b/Interface.h
index 0c94c0c..005beff 100644
--- a/Interface.h
+++ b/Interface.h
@@ -127,7 +127,7 @@
     void emitVtsAttributeType(Formatter& out) const override;
 
     void emitVtsAttributeDeclaration(Formatter& out) const;
-    void emitVtsMethodDeclaration(Formatter& out) const;
+    void emitVtsMethodDeclaration(Formatter& out, bool isInherited) const;
 
     bool hasOnewayMethods() const;
 
diff --git a/generateVts.cpp b/generateVts.cpp
index 40e08c9..722a656 100644
--- a/generateVts.cpp
+++ b/generateVts.cpp
@@ -78,17 +78,15 @@
         out << "interface: {\n";
         out.indent();
 
-        std::vector<const Interface *> chain = iface->typeChain();
-
         // Generate all the attribute declarations first.
         emitVtsTypeDeclarations(out);
 
         // Generate all the method declarations.
-        for (auto it = chain.rbegin(); it != chain.rend(); ++it) {
-            const Interface *superInterface = *it;
-            superInterface->emitVtsMethodDeclaration(out);
+        for (const Interface* superInterface : iface->superTypeChain()) {
+            superInterface->emitVtsMethodDeclaration(out, true /*isInhereted*/);
         }
 
+        iface->emitVtsMethodDeclaration(out, false /*isInhereted*/);
         out.unindent();
         out << "}\n";
     } else {