Fix test 674-hiddenapi when debuggable.

The runtime warns for debuggable apps even when access to an API is
allowed. Update the expectations of this test accordingly.

This requires exposing Runtime::IsJavaDebuggable to the java code so
it knows what to expect.

Test: $ art/test.py -b --host --debuggable -t 674-hiddenapi
Bug: 79914966

(cherry picked from commit eef7757941f2681814462b0f55d29a562c0200da)

Merged-In: I339f205d7153cf7b1c12dc06813c768608921684
Change-Id: Ifd260a2886e99159162a3d05bdf0f5af0c8620d6
diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc
index 9ba51c2..12332d2 100644
--- a/runtime/native/dalvik_system_VMRuntime.cc
+++ b/runtime/native/dalvik_system_VMRuntime.cc
@@ -185,6 +185,10 @@
   return Runtime::Current()->IsNativeDebuggable();
 }
 
+static jboolean VMRuntime_isJavaDebuggable(JNIEnv*, jobject) {
+  return Runtime::Current()->IsJavaDebuggable();
+}
+
 static jobjectArray VMRuntime_properties(JNIEnv* env, jobject) {
   DCHECK(WellKnownClasses::java_lang_String != nullptr);
 
@@ -709,6 +713,7 @@
   NATIVE_METHOD(VMRuntime, getTargetHeapUtilization, "()F"),
   FAST_NATIVE_METHOD(VMRuntime, isDebuggerActive, "()Z"),
   FAST_NATIVE_METHOD(VMRuntime, isNativeDebuggable, "()Z"),
+  NATIVE_METHOD(VMRuntime, isJavaDebuggable, "()Z"),
   NATIVE_METHOD(VMRuntime, nativeSetTargetHeapUtilization, "(F)V"),
   FAST_NATIVE_METHOD(VMRuntime, newNonMovableArray, "(Ljava/lang/Class;I)Ljava/lang/Object;"),
   FAST_NATIVE_METHOD(VMRuntime, newUnpaddedArray, "(Ljava/lang/Class;I)Ljava/lang/Object;"),
diff --git a/test/674-hiddenapi/src-ex/ChildClass.java b/test/674-hiddenapi/src-ex/ChildClass.java
index d5966cd..db3ba6d 100644
--- a/test/674-hiddenapi/src-ex/ChildClass.java
+++ b/test/674-hiddenapi/src-ex/ChildClass.java
@@ -87,16 +87,21 @@
     ChildClass.everythingWhitelisted = everythingWhitelisted;
 
     boolean isSameBoot = (isParentInBoot == isChildInBoot);
+    boolean isDebuggable = VMRuntime.getRuntime().isJavaDebuggable();
 
     // Run meaningful combinations of access flags.
     for (Hiddenness hiddenness : Hiddenness.values()) {
       final Behaviour expected;
       // Warnings are now disabled whenever access is granted, even for
       // greylisted APIs. This is the behaviour for release builds.
-      if (isSameBoot || hiddenness != Hiddenness.Blacklist || everythingWhitelisted) {
+      if (isSameBoot || everythingWhitelisted || hiddenness == Hiddenness.Whitelist) {
         expected = Behaviour.Granted;
-      } else {
+      } else if (hiddenness == Hiddenness.Blacklist) {
         expected = Behaviour.Denied;
+      } else if (isDebuggable) {
+        expected = Behaviour.Warning;
+      } else {
+        expected = Behaviour.Granted;
       }
 
       for (boolean isStatic : booleanValues) {