Fix the check on apex-versions for boot images.
This change replaces `kIsTargetBuild` with `kIsTargetAndroid` to avoid
crashes in some environment that has kIsTargetBuild = true but is not
Android (e.g., ARM benchmarking environment).
Bug: 211973309
Test: Presubmits
Change-Id: If9730300ba81d5f82cc187558ba2c5d92811d74b
diff --git a/libartbase/base/globals.h b/libartbase/base/globals.h
index 700d4e6..8d37b8a 100644
--- a/libartbase/base/globals.h
+++ b/libartbase/base/globals.h
@@ -71,12 +71,15 @@
# if defined(ART_TARGET_LINUX)
static constexpr bool kIsTargetLinux = true;
static constexpr bool kIsTargetFuchsia = false;
+static constexpr bool kIsTargetAndroid = false;
# elif defined(ART_TARGET_ANDROID)
static constexpr bool kIsTargetLinux = false;
static constexpr bool kIsTargetFuchsia = false;
+static constexpr bool kIsTargetAndroid = true;
# elif defined(ART_TARGET_FUCHSIA)
static constexpr bool kIsTargetLinux = false;
static constexpr bool kIsTargetFuchsia = true;
+static constexpr bool kIsTargetAndroid = false;
# else
# error "Either ART_TARGET_LINUX, ART_TARGET_ANDROID or ART_TARGET_FUCHSIA " \
"needs to be defined for target builds."
@@ -92,6 +95,7 @@
# else
static constexpr bool kIsTargetLinux = false;
static constexpr bool kIsTargetFuchsia = false;
+static constexpr bool kIsTargetAndroid = false;
# endif
#endif
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index c8ce0b7..633ae7f 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -3484,7 +3484,7 @@
// The OAT files in the ART APEX is built on host, so they don't have the right APEX versions. It
// is safe to assume that they are always up-to-date because they are shipped along with the
// runtime and the dex files.
- if (kIsTargetBuild && android::base::StartsWith(oat_file.GetLocation(), GetArtRoot())) {
+ if (kIsTargetAndroid && android::base::StartsWith(oat_file.GetLocation(), GetArtRoot())) {
return true;
}