Do not enforce minor version uprev on imports.

For example, if A imports B and we run hidl-gen on A, we should
not check minor version uprev requirement on B; this is an overkill.
Eventually, hidl-gen needs to be run on B to generate the required
sources, then we can enforce the restrictions there.

This CL is needed because enforceRestrictionsOnPackage internally
calls parse, and the recursion should not go on forever. Stopping
at imports are a good base case for the recursion.

Test: pass
Test: hardware/interfaces/update-makefiles.sh
Test: ./system/tools/hidl/test/test.sh
Test: hidl-gen -o /tmp -Ljava -randroid.hardware:hardware/interfaces
-rtests:system/tools/hidl/test -randroid.hidl:system/libhidl/transport
android.hardware.usb@1.1::IUsbCallback

Bug: 36787547
Change-Id: Id4363a42d6ba8c9b747c7430c79348552cc8139d
Merged-In: Id4363a42d6ba8c9b747c7430c79348552cc8139d
diff --git a/Coordinator.cpp b/Coordinator.cpp
index d50b639..72c8557 100644
--- a/Coordinator.cpp
+++ b/Coordinator.cpp
@@ -53,7 +53,7 @@
     // empty
 }
 
-AST *Coordinator::parse(const FQName &fqName, std::set<AST *> *parsedASTs) {
+AST *Coordinator::parse(const FQName &fqName, std::set<AST *> *parsedASTs, bool enforce) {
     CHECK(fqName.isFullyQualified());
 
     auto it = mCache.find(fqName);
@@ -75,7 +75,8 @@
     if (fqName.name() != "types") {
         // Any interface file implicitly imports its package's types.hal.
         FQName typesName = fqName.getTypesForPackage();
-        typesAST = parse(typesName, parsedASTs);
+        // Do not enforce on imports.
+        typesAST = parse(typesName, parsedASTs, false /* enforce */);
 
         // fall through.
     }
@@ -163,13 +164,15 @@
     // parse fqName.
     mCache[fqName] = ast;
 
-    // For each .hal file that hidl-gen parses, the whole package will be checked.
-    err = enforceRestrictionsOnPackage(fqName);
-    if (err != OK) {
-        mCache[fqName] = nullptr;
-        delete ast;
-        ast = nullptr;
-        return nullptr;
+    if (enforce) {
+        // For each .hal file that hidl-gen parses, the whole package will be checked.
+        err = enforceRestrictionsOnPackage(fqName);
+        if (err != OK) {
+            mCache[fqName] = nullptr;
+            delete ast;
+            ast = nullptr;
+            return nullptr;
+        }
     }
 
     return ast;