Fix buildbots hidden_api_test

Target buildbots set /system to be the runtime module root because they
are running without an apex. The test assumes that /system dex files are assigned
to the application domain but here they get assigned to the core-platform domain.

Adjust the domain setting logic to check if the runtime module root is
distict from the android root (as a proxy for 'is running with apex').
If not (as is the case with the buildbots), skip checks against apex
locations.

Test: m test-art-target-gtest-hidden_api_test
Change-Id: Iff3890ec69cb04a1e4ed5bc2a3b5c652ada05f36
diff --git a/libartbase/base/file_utils.cc b/libartbase/base/file_utils.cc
index 1f8457a..865c8a6 100644
--- a/libartbase/base/file_utils.cc
+++ b/libartbase/base/file_utils.cc
@@ -334,6 +334,16 @@
   return android::base::StartsWith(full_path, framework_path);
 }
 
+bool RuntimeModuleRootDistinctFromAndroidRoot() {
+  std::string error_msg;
+  std::string android_root = GetAndroidRootSafe(&error_msg);
+  const char* runtime_root =
+      GetAndroidDirSafe(kRuntimeApexEnvVar, kRuntimeApexDefaultPath, &error_msg);
+  return !android_root.empty()
+      && (runtime_root != nullptr)
+      && (android_root != std::string_view(runtime_root));
+}
+
 int DupCloexec(int fd) {
 #if defined(__linux__)
   return fcntl(fd, F_DUPFD_CLOEXEC, 0);
diff --git a/libartbase/base/file_utils.h b/libartbase/base/file_utils.h
index 1da19c8..c5e55d1 100644
--- a/libartbase/base/file_utils.h
+++ b/libartbase/base/file_utils.h
@@ -90,6 +90,10 @@
 // Return whether the location is on /apex/.
 bool LocationIsOnApex(const char* location);
 
+// Compare the runtime module root against android root. Returns true if they are
+// both known and distinct. This is meant to be a proxy for 'running with apex'.
+bool RuntimeModuleRootDistinctFromAndroidRoot();
+
 // dup(2), except setting the O_CLOEXEC flag atomically, when possible.
 int DupCloexec(int fd);