hidl-gen: auto-generate depdendencies for nested types

HIDL allows for types to be defined within interfaces, and for these
types to be able to be referred to from outside of these interfaces.
hidl-gen was not emitting the correct #include and import paths in C++
and Java respectively for such cases, and also Makefile dependencies.

b/31268323

Change-Id: I168c52823098348b4161b5d2c151d1d8eadec9b8
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/main.cpp b/main.cpp
index e7d959a..6f0f248 100644
--- a/main.cpp
+++ b/main.cpp
@@ -338,6 +338,17 @@
             << hidl_gen
             << "$(HOST_EXECUTABLE_SUFFIX)";
 
+        if (!importedPackages.empty()) {
+            out << "\n"
+                << "\nLOCAL_JAVA_LIBRARIES := \\";
+            out.indent();
+            for (const auto &importedPackage : importedPackages) {
+                out << "\n" << makeLibraryName(importedPackage) << "-java \\";
+            }
+            out << "\n";
+            out.unindent();
+        }
+
         generateMakefileSectionForLanguage(
                 out,
                 coordinator,