Profman: Skip dex file verification for boot jars

The introduction of new access flags into boot jars causes them to
fail dex file verification. The files are verified in `hiddenapi`
and verification should be skipped in subsequent attempts to open
them. This patch adds a new flag '--skip-apk-verification' which
instructs `profman` to skip dex file verification.

Bug: 64382372
Test: make test-art-host-gtest-profile_assistant_test
Change-Id: Iad614e47feada293218c11cff985a8012ca49a0f
diff --git a/profman/profile_assistant_test.cc b/profman/profile_assistant_test.cc
index 642d26e..c75f3e9 100644
--- a/profman/profile_assistant_test.cc
+++ b/profman/profile_assistant_test.cc
@@ -209,7 +209,8 @@
 
   bool CreateProfile(const std::string& profile_file_contents,
                      const std::string& filename,
-                     const std::string& dex_location) {
+                     const std::string& dex_location,
+                     bool skip_verification) {
     ScratchFile class_names_file;
     File* file = class_names_file.GetFile();
     EXPECT_TRUE(file->WriteFully(profile_file_contents.c_str(), profile_file_contents.length()));
@@ -222,6 +223,9 @@
     argv_str.push_back("--reference-profile-file=" + filename);
     argv_str.push_back("--apk=" + dex_location);
     argv_str.push_back("--dex-location=" + dex_location);
+    if (skip_verification) {
+      argv_str.push_back("--skip-apk-verification");
+    }
     std::string error;
     EXPECT_EQ(ExecAndReturnCode(argv_str, &error), 0);
     return true;
@@ -238,6 +242,7 @@
     argv_str.push_back("--profile-file=" + filename);
     argv_str.push_back("--apk=" + GetLibCoreDexFileNames()[0]);
     argv_str.push_back("--dex-location=" + GetLibCoreDexFileNames()[0]);
+    argv_str.push_back("--skip-apk-verification");
     argv_str.push_back("--dump-output-to-fd=" + std::to_string(GetFd(output_file)));
     std::string error;
     EXPECT_EQ(ExecAndReturnCode(argv_str, &error), 0);
@@ -268,7 +273,8 @@
     ScratchFile profile_file;
     EXPECT_TRUE(CreateProfile(input_file_contents,
                               profile_file.GetFilename(),
-                              GetLibCoreDexFileNames()[0]));
+                              GetLibCoreDexFileNames()[0],
+                              /* skip_verification */ true));
     profile_file.GetFile()->ResetOffset();
     EXPECT_TRUE(DumpClassesAndMethods(profile_file.GetFilename(), output_file_contents));
     return true;
@@ -675,7 +681,8 @@
   ScratchFile profile_file;
   EXPECT_TRUE(CreateProfile(input_file_contents,
                             profile_file.GetFilename(),
-                            GetLibCoreDexFileNames()[0]));
+                            GetLibCoreDexFileNames()[0],
+                            /* skip_verification */ true));
   ProfileCompilationInfo info;
   profile_file.GetFile()->ResetOffset();
   ASSERT_TRUE(info.Load(GetFd(profile_file)));
@@ -731,7 +738,8 @@
       "H" + kHotMethod + "\n" +
       kUncommonDirtyClass;
   profiles.emplace_back(ScratchFile());
-  EXPECT_TRUE(CreateProfile(dex1, profiles.back().GetFilename(), core_dex));
+  EXPECT_TRUE(CreateProfile(
+      dex1, profiles.back().GetFilename(), core_dex, /* skip_verification */ true));
 
   // Create a bunch of boot profiles.
   std::string dex2 =
@@ -741,7 +749,8 @@
       "P" + kMultiMethod + "\n" +
       kUncommonDirtyClass;
   profiles.emplace_back(ScratchFile());
-  EXPECT_TRUE(CreateProfile(dex2, profiles.back().GetFilename(), core_dex));
+  EXPECT_TRUE(CreateProfile(
+      dex2, profiles.back().GetFilename(), core_dex, /* skip_verification */ true));
 
   // Create a bunch of boot profiles.
   std::string dex3 =
@@ -750,7 +759,8 @@
       "P" + kMultiMethod + "\n" +
       kDirtyClass + "\n";
   profiles.emplace_back(ScratchFile());
-  EXPECT_TRUE(CreateProfile(dex3, profiles.back().GetFilename(), core_dex));
+  EXPECT_TRUE(CreateProfile(
+      dex3, profiles.back().GetFilename(), core_dex, /* skip_verification */ true));
 
   // Generate the boot profile.
   ScratchFile out_profile;
@@ -763,6 +773,7 @@
   args.push_back("--reference-profile-file=" + out_profile.GetFilename());
   args.push_back("--apk=" + core_dex);
   args.push_back("--dex-location=" + core_dex);
+  args.push_back("--skip-apk-verification");
   for (const ScratchFile& profile : profiles) {
     args.push_back("--profile-file=" + profile.GetFilename());
   }
@@ -858,7 +869,8 @@
   ScratchFile profile_file;
   ASSERT_TRUE(CreateProfile(input_file_contents,
                             profile_file.GetFilename(),
-                            GetTestDexFileName("ProfileTestMultiDex")));
+                            GetTestDexFileName("ProfileTestMultiDex"),
+                            /* skip_verification */ false));
 
   // Load the profile from disk.
   ProfileCompilationInfo info;
@@ -1008,7 +1020,8 @@
   std::string dex_filename = GetTestDexFileName("ProfileTestMultiDex");
   ASSERT_TRUE(CreateProfile(input_file_contents,
                             profile_file.GetFilename(),
-                            dex_filename));
+                            dex_filename,
+                            /* skip_verification */ false));
 
   // Load the profile from disk.
   ProfileCompilationInfo info;