Do not change hidden API ArtMethod/ArtField access flags on AOT

Hidden API may change the access flags of ArtMethod/ArtField in order
to dedupe warnings in logcat. Avoid doing that during AOT compilation
as the updated access flags would survive until runtime in the
boot/app image. This is not a problem for correctness, but better
matches expectations of what the access flags should be and whether we
should warn at runtime.

Test: compiles
Bug: 129063331
Merged-In: I44e235d73914bd42eacf3df69f9ed5285c1e864a
Change-Id: I44e235d73914bd42eacf3df69f9ed5285c1e864a
(cherry picked from commit 0039bc553788c18ba7f619b555d744f548ae749e)
diff --git a/runtime/hidden_api.cc b/runtime/hidden_api.cc
index 97d2f8d..388ed33 100644
--- a/runtime/hidden_api.cc
+++ b/runtime/hidden_api.cc
@@ -306,7 +306,13 @@
 template<typename T>
 static ALWAYS_INLINE void MaybeUpdateAccessFlags(Runtime* runtime, T* member, uint32_t flag)
     REQUIRES_SHARED(Locks::mutator_lock_) {
-  if (CanUpdateRuntimeFlags(member) && runtime->ShouldDedupeHiddenApiWarnings()) {
+  // Update the access flags unless:
+  // (a) `member` is an intrinsic
+  // (b) this is AOT compiler, as we do not want the updated access flags in the boot/app image
+  // (c) deduping warnings has been explicitly switched off.
+  if (CanUpdateRuntimeFlags(member) &&
+      !runtime->IsAotCompiler() &&
+      runtime->ShouldDedupeHiddenApiWarnings()) {
     member->SetAccessFlags(member->GetAccessFlags() | flag);
   }
 }