Hide conscrypt package classes for app AOT compilation.

Since app AOT compilation is usually done without conscrypt
on the boot class path, classes defined by app class loader
in conscrypt packages could be resolved differently, i.e.
from conscrypt, at runtime. Reject such definitions during
AOT compilation to ensure correct runtime behavior.

Add a test that when compiling the conscrypt module as an
app, we cannot resolve any class defined in its dex files.

Test: module_exclusion_test
Bug: 122937705
Change-Id: I1fcb4c21937f59772206ee50b688a75053231bc0
diff --git a/runtime/oat_file_assistant_test.cc b/runtime/oat_file_assistant_test.cc
index 92b61e0..9a5409f 100644
--- a/runtime/oat_file_assistant_test.cc
+++ b/runtime/oat_file_assistant_test.cc
@@ -1179,10 +1179,12 @@
 // A task to generate a dex location. Used by the RaceToGenerate test.
 class RaceGenerateTask : public Task {
  public:
-  RaceGenerateTask(const std::string& dex_location,
+  RaceGenerateTask(OatFileAssistantTest& test,
+                   const std::string& dex_location,
                    const std::string& oat_location,
                    Mutex* lock)
-      : dex_location_(dex_location),
+      : test_(test),
+        dex_location_(dex_location),
         oat_location_(oat_location),
         lock_(lock),
         loaded_oat_file_(nullptr)
@@ -1201,7 +1203,7 @@
       args.push_back("--dex-file=" + dex_location_);
       args.push_back("--oat-file=" + oat_location_);
       std::string error_msg;
-      ASSERT_TRUE(DexoptTest::Dex2Oat(args, &error_msg)) << error_msg;
+      ASSERT_TRUE(test_.Dex2Oat(args, &error_msg)) << error_msg;
     }
 
     dex_files = Runtime::Current()->GetOatFileManager().OpenDexFilesFromOat(
@@ -1222,6 +1224,7 @@
   }
 
  private:
+  OatFileAssistantTest& test_;
   std::string dex_location_;
   std::string oat_location_;
   Mutex* lock_;
@@ -1248,7 +1251,8 @@
   std::vector<std::unique_ptr<RaceGenerateTask>> tasks;
   Mutex lock("RaceToGenerate");
   for (size_t i = 0; i < kNumThreads; i++) {
-    std::unique_ptr<RaceGenerateTask> task(new RaceGenerateTask(dex_location, oat_location, &lock));
+    std::unique_ptr<RaceGenerateTask> task(
+        new RaceGenerateTask(*this, dex_location, oat_location, &lock));
     thread_pool.AddTask(self, task.get());
     tasks.push_back(std::move(task));
   }