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/AST.cpp b/AST.cpp
index fb5d333..4793021 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -117,7 +117,8 @@
         }
 
         for (const auto &subFQName : packageInterfaces) {
-            AST *ast = mCoordinator->parse(subFQName, &mImportedASTs);
+            // Do not enforce restrictions on imports.
+            AST *ast = mCoordinator->parse(subFQName, &mImportedASTs, false /* enforce */);
             if (ast == nullptr) {
                 return false;
             }
@@ -135,7 +136,8 @@
 
     // assume it is an interface, and try to import it.
     const FQName interfaceName = fqName.getTopLevelType();
-    importAST = mCoordinator->parse(interfaceName, &mImportedASTs);
+    // Do not enforce restrictions on imports.
+    importAST = mCoordinator->parse(interfaceName, &mImportedASTs, false /* enforce */);
 
     if (importAST != nullptr) {
         // cases like android.hardware.foo@1.0::IFoo.Internal
@@ -163,7 +165,9 @@
 
     // probably a type in types.hal, like android.hardware.foo@1.0::Abc.Internal
     FQName typesFQName = fqName.getTypesForPackage();
-    importAST = mCoordinator->parse(typesFQName, &mImportedASTs);
+
+    // Do not enforce restrictions on imports.
+    importAST = mCoordinator->parse(typesFQName, &mImportedASTs, false /* enforce */);
 
     if (importAST != nullptr) {
         // Attempt to find Abc.Internal in types.
@@ -522,7 +526,7 @@
 void AST::getAllImportedNames(std::set<FQName> *allImportNames) const {
     for (const auto& name : mImportedNames) {
         allImportNames->insert(name);
-        AST *ast = mCoordinator->parse(name);
+        AST *ast = mCoordinator->parse(name, nullptr /* imported */, false /* enforce */);
         ast->getAllImportedNames(allImportNames);
     }
 }