Don't generate a Java Android.mk if we don't need to.

If an interface consists solely of a types.hal file that itself
contains nothing but typedefs, we won't generate any Java code,
so we don't need a makefile.

Bug: 32156804
Test: visual inspection
Change-Id: I9e2950c149a012b5092227fa70139be9c0ca4113
diff --git a/main.cpp b/main.cpp
index e69069b..9286de5 100644
--- a/main.cpp
+++ b/main.cpp
@@ -317,6 +317,32 @@
     return OK;
 }
 
+static bool packageNeedsJavaCode(
+        const std::vector<FQName> &packageInterfaces, AST *typesAST) {
+    // If there is more than just a types.hal file to this package we'll
+    // definitely need to generate Java code.
+    if (packageInterfaces.size() > 1
+            || packageInterfaces[0].name() != "types") {
+        return true;
+    }
+
+    CHECK(typesAST != nullptr);
+
+    // We'll have to generate Java code if types.hal contains any non-typedef
+    // type declarations.
+
+    Scope *rootScope = typesAST->scope();
+    std::vector<NamedType *> subTypes = rootScope->getSubTypes();
+
+    for (const auto &subType : subTypes) {
+        if (!subType->isTypeDef()) {
+            return true;
+        }
+    }
+
+    return false;
+}
+
 static status_t generateMakefileForPackage(
         const FQName &packageFQName,
         const char *hidl_gen,
@@ -370,6 +396,10 @@
         return OK;
     }
 
+    if (!packageNeedsJavaCode(packageInterfaces, typesAST)) {
+        return OK;
+    }
+
     std::string path =
         coordinator->getPackagePath(packageFQName, false /* relative */);