hiddenapi: check for CorePlatform domain

Set Hidden API Domain to CorePlatform if dex file is in the Runtime
Module.

Bug: 119068555
Test: 674-hiddenapi

Change-Id: I24475098deb6f8d9d51d218ab1a8ee0caf01ae81
diff --git a/libartbase/base/file_utils.cc b/libartbase/base/file_utils.cc
index 9490798..4953bab 100644
--- a/libartbase/base/file_utils.cc
+++ b/libartbase/base/file_utils.cc
@@ -278,6 +278,17 @@
   }
 }
 
+bool LocationIsOnRuntimeModule(const char* full_path) {
+  std::string error_msg;
+  const char* runtime_path = GetAndroidDirSafe("ANDROID_RUNTIME_ROOT",
+                                               "/apex/com.android.runtime",
+                                               &error_msg);
+  if (runtime_path == nullptr) {
+    return false;
+  }
+  return android::base::StartsWith(full_path, runtime_path);
+}
+
 bool LocationIsOnSystem(const char* path) {
 #ifdef _WIN32
   UNUSED(path);
diff --git a/libartbase/base/file_utils.h b/libartbase/base/file_utils.h
index c249bcc..bddfaa1 100644
--- a/libartbase/base/file_utils.h
+++ b/libartbase/base/file_utils.h
@@ -72,6 +72,9 @@
 //          ReplaceFileExtension("foo", "abc") == "foo.abc"
 std::string ReplaceFileExtension(const std::string& filename, const std::string& new_extension);
 
+// Return whether the location is on apex/com.android.runtime
+bool LocationIsOnRuntimeModule(const char* location);
+
 // Return whether the location is on system (i.e. android root).
 bool LocationIsOnSystem(const char* location);