Log for light grey API accesses.

For the public Beta 1 build, it seems likely that 3P devs will want to
check the logcat for hidden API accesses by their own apps. So enable
this logging for light grey API accesses.

The option can easily be diabled again later by setting the new flag to
false (which should be done before public release).

Bug: 64382372
Test: m
Test: Verify logcat output
Change-Id: Ie610ebcf712a0abc3f1c200510048e2c93b712f7
diff --git a/runtime/hidden_api.cc b/runtime/hidden_api.cc
index 98feb4d..a711a63 100644
--- a/runtime/hidden_api.cc
+++ b/runtime/hidden_api.cc
@@ -25,6 +25,11 @@
 namespace art {
 namespace hiddenapi {
 
+// Set to true if we should always print a warning in logcat for all hidden API accesses, not just
+// dark grey and black. This can be set to true for developer preview / beta builds, but should be
+// false for public release builds.
+static constexpr bool kLogAllAccesses = true;
+
 static inline std::ostream& operator<<(std::ostream& os, AccessMethod value) {
   switch (value) {
     case kNone:
@@ -131,7 +136,7 @@
   // - for non-debuggable apps, there is no distinction between light grey & whitelisted APIs.
   // - we want to avoid the overhead of checking for exemptions for light greylisted APIs whenever
   //   possible.
-  if (action == kDeny || runtime->IsJavaDebuggable()) {
+  if (kLogAllAccesses || action == kDeny || runtime->IsJavaDebuggable()) {
     if (member_signature.IsExempted(runtime->GetHiddenApiExemptions())) {
       action = kAllow;
       // Avoid re-examining the exemption list next time.