Remove the primary boot image from the ART APEX.

Move to `/system/framework`.

Test: -
  1. Build a system image and flash it to a device.
  2. Run `atest art_standalone_dexpreopt_tests`.
Test: atest odsign_e2e_tests
Test: All ART test suites.
Change-Id: I45aaa598438cc8573839a4b7cae1335c142734fa
diff --git a/libartbase/base/file_utils.cc b/libartbase/base/file_utils.cc
index 139d904..0b670e7 100644
--- a/libartbase/base/file_utils.cc
+++ b/libartbase/base/file_utils.cc
@@ -54,6 +54,7 @@
 #if defined(__APPLE__)
 #include <crt_externs.h>
 #include <sys/syscall.h>
+
 #include "AvailabilityMacros.h"  // For MAC_OS_X_VERSION_MAX_ALLOWED
 #endif
 
@@ -87,7 +88,7 @@
 // Return the empty string if that directory cannot be found or if this code is
 // run on Windows or macOS.
 static std::string GetRootContainingLibartbase() {
-#if !defined( _WIN32) && !defined(__APPLE__)
+#if !defined(_WIN32) && !defined(__APPLE__)
   // Check where libartbase is from, and derive from there.
   Dl_info info;
   if (dladdr(reinterpret_cast<const void*>(&GetRootContainingLibartbase), /* out */ &info) != 0) {
@@ -155,7 +156,6 @@
   return ret;
 }
 
-
 static const char* GetAndroidDirSafe(const char* env_var,
                                      const char* default_dir,
                                      bool must_exist,
@@ -200,9 +200,8 @@
   const char* android_art_root_from_env = getenv(kAndroidArtRootEnvVar);
   if (android_art_root_from_env != nullptr) {
     if (must_exist && !OS::DirectoryExists(android_art_root_from_env)) {
-      *error_msg = StringPrintf("Failed to find %s directory %s",
-                                kAndroidArtRootEnvVar,
-                                android_art_root_from_env);
+      *error_msg = StringPrintf(
+          "Failed to find %s directory %s", kAndroidArtRootEnvVar, android_art_root_from_env);
       return "";
     }
     return android_art_root_from_env;
@@ -234,8 +233,8 @@
 
   // Try the default path.
   if (must_exist && !OS::DirectoryExists(kAndroidArtApexDefaultPath)) {
-    *error_msg = StringPrintf("Failed to find default ART root directory %s",
-                              kAndroidArtApexDefaultPath);
+    *error_msg =
+        StringPrintf("Failed to find default ART root directory %s", kAndroidArtApexDefaultPath);
     return "";
   }
   return kAndroidArtApexDefaultPath;
@@ -275,16 +274,22 @@
   return (android_dir != nullptr) ? android_dir : "";
 }
 
-std::string GetAndroidData() {
-  return GetAndroidDir(kAndroidDataEnvVar, kAndroidDataDefaultPath);
-}
+std::string GetAndroidData() { return GetAndroidDir(kAndroidDataEnvVar, kAndroidDataDefaultPath); }
 
 std::string GetArtApexData() {
   return GetAndroidDir(kArtApexDataEnvVar, kArtApexDataDefaultPath, /*must_exist=*/false);
 }
 
+static std::string GetPrebuiltPrimaryBootImageDir(const std::string& android_root) {
+  return StringPrintf("%s/framework", android_root.c_str());
+}
+
 std::string GetPrebuiltPrimaryBootImageDir() {
-  return StringPrintf("%s/javalib", kAndroidArtApexDefaultPath);
+  std::string android_root = GetAndroidRoot();
+  if (android_root.empty()) {
+    return "";
+  }
+  return GetPrebuiltPrimaryBootImageDir(android_root);
 }
 
 std::string GetDefaultBootImageLocation(const std::string& android_root,
@@ -342,7 +347,7 @@
   // Typically "/apex/com.android.art/javalib/boot.art!/apex/com.android.art/etc/boot-image.prof:
   // /system/framework/boot-framework.art!/system/etc/boot-image.prof".
   return StringPrintf("%s/%s.art!%s/%s:%s/framework/%s-framework.art!%s/%s",
-                      GetPrebuiltPrimaryBootImageDir().c_str(),
+                      GetPrebuiltPrimaryBootImageDir(android_root).c_str(),
                       kBootImageStem,
                       kAndroidArtApexDefaultPath,
                       kEtcBootImageProf,
@@ -363,9 +368,9 @@
 static /*constinit*/ std::string_view dalvik_cache_sub_dir = "dalvik-cache";
 
 void OverrideDalvikCacheSubDirectory(std::string sub_dir) {
-    static std::string overridden_dalvik_cache_sub_dir;
-    overridden_dalvik_cache_sub_dir = std::move(sub_dir);
-    dalvik_cache_sub_dir = overridden_dalvik_cache_sub_dir;
+  static std::string overridden_dalvik_cache_sub_dir;
+  overridden_dalvik_cache_sub_dir = std::move(sub_dir);
+  dalvik_cache_sub_dir = overridden_dalvik_cache_sub_dir;
 }
 
 static std::string GetDalvikCacheDirectory(std::string_view root_directory,
@@ -378,8 +383,12 @@
   return oss.str();
 }
 
-void GetDalvikCache(const char* subdir, const bool create_if_absent, std::string* dalvik_cache,
-                    bool* have_android_data, bool* dalvik_cache_exists, bool* is_global_cache) {
+void GetDalvikCache(const char* subdir,
+                    const bool create_if_absent,
+                    std::string* dalvik_cache,
+                    bool* have_android_data,
+                    bool* dalvik_cache_exists,
+                    bool* is_global_cache) {
 #ifdef _WIN32
   UNUSED(subdir);
   UNUSED(create_if_absent);
@@ -423,8 +432,7 @@
     return false;
   }
   std::string cache_file(&location[1]);  // skip leading slash
-  if (!android::base::EndsWith(location, ".dex") &&
-      !android::base::EndsWith(location, ".art") &&
+  if (!android::base::EndsWith(location, ".dex") && !android::base::EndsWith(location, ".art") &&
       !android::base::EndsWith(location, ".oat")) {
     cache_file += "/";
     cache_file += kClassesDex;
@@ -629,22 +637,20 @@
                       kAndroidSystemExtRootEnvVar,
                       kAndroidSystemExtRootDefaultPath,
                       /* subdir= */ "framework/") ||
-      // When the 'system_ext' partition is not present, builds will create
-      // '/system/system_ext' instead.
-      IsLocationOn(full_path,
-                   kAndroidRootEnvVar,
-                   kAndroidRootDefaultPath,
-                   /* subdir= */ "system_ext/framework/");
+         // When the 'system_ext' partition is not present, builds will create
+         // '/system/system_ext' instead.
+         IsLocationOn(full_path,
+                      kAndroidRootEnvVar,
+                      kAndroidRootDefaultPath,
+                      /* subdir= */ "system_ext/framework/");
 }
 
 bool LocationIsOnConscryptModule(std::string_view full_path) {
-  return IsLocationOn(
-      full_path, kAndroidConscryptRootEnvVar, kAndroidConscryptApexDefaultPath);
+  return IsLocationOn(full_path, kAndroidConscryptRootEnvVar, kAndroidConscryptApexDefaultPath);
 }
 
 bool LocationIsOnI18nModule(std::string_view full_path) {
-  return IsLocationOn(
-      full_path, kAndroidI18nRootEnvVar, kAndroidI18nApexDefaultPath);
+  return IsLocationOn(full_path, kAndroidI18nRootEnvVar, kAndroidI18nApexDefaultPath);
 }
 
 bool LocationIsOnApex(std::string_view full_path) {
@@ -690,9 +696,8 @@
                                            kAndroidArtApexDefaultPath,
                                            /* must_exist= */ kIsTargetBuild,
                                            &error_msg);
-  return (android_root != nullptr)
-      && (art_root != nullptr)
-      && (std::string_view(android_root) != std::string_view(art_root));
+  return (android_root != nullptr) && (art_root != nullptr) &&
+         (std::string_view(android_root) != std::string_view(art_root));
 }
 
 int DupCloexec(int fd) {