Start warning on hidden API greylist
Insert checks into reflection, JNI and the verifier to print
a warning when greylisted methods are invoked and fields accessed.
We do this on actual access, because reflection allows to list
all methods/fields and simply listing a greylisted member would
print too many false positives.
Issuing a warning also sets a boolean flag in Runtime. This will
be made accessible through VMRuntime to the framework which will
issue a Toast on Activity start.
The change was tested with internal microbenchmarks of reflection
and those flagged one issue. Microbenchmark invoking a field getter
has regressed by 35%. We will profile this benchmark in detail and
consider options for improvement. Bug b/72482474 was created to track
progress.
Test: art/test.py -b -r -t 674-hiddenapi
Bug: 64382372
Bug: 72482474
Change-Id: I323244935e9091a2f8d012385cefaac6b1fe3777
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 33bebe0..6d065d6 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -266,6 +266,8 @@
is_low_memory_mode_(false),
safe_mode_(false),
do_hidden_api_checks_(false),
+ pending_hidden_api_warning_(false),
+ dedupe_hidden_api_warnings_(true),
dump_native_stack_on_sig_quit_(true),
pruned_dalvik_cache_(false),
// Initially assume we perceive jank in case the process state is never updated.