hiddenapi domain: Use oat dex file location if available

To determine the caller and callee domains of a hidden API access check,
the logic will test the dex location against several known system
locations. However, DexFile instances backed by an OatFile have relative
dex locations to avoid need to rewrite the .oat file when moving files
between folders. The canonical dex location is stored in the OatDexFile
instead.

Because the OatDexFile data structure is not available in libdexfile,
move the domain resolution logic to hidden_api.cc and resolve when dex
files is first registered with the class linker.

Test: m test-art-gtest
Test: camera does not crash
Bug: 126901248
Bug: 127852529
Change-Id: Id494b1c47a2199c227dec046174e08320b9cbc3b
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index de9d9ca..e5dcc0d 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -3765,6 +3765,9 @@
   if (initialize_oat_file_data) {
     oat_file->InitializeRelocations();
   }
+  // Let hiddenapi assign a domain to the newly registered dex file.
+  hiddenapi::InitializeDexFileDomain(dex_file, class_loader);
+
   jweak dex_cache_jweak = vm->AddWeakGlobalRef(self, dex_cache);
   dex_cache->SetDexFile(&dex_file);
   DexCacheData data;