Refactor Core Plaform API checking
Move Core Platform API check logic to hidden_api_jni.{h,cc}.
Use libunwindstack for walking stack as builtin isn't robust without
frame pointers. This is moderately expensive so we currently walk a
maximum of 3 frames.
Checks are now performed by placing ScopedCorePlatformApiCheck
instances at potential points of entry via JNI. Specifically, where
JNI interfaces implement methods for getting field and method ids. The
check is only performed on the outermost instance of the
ScopedCorePlatformApiCheck since only the outer caller is of interest.
State for the checks is stored in the current Thread instance since
the JNI interface signatures are fixed and we need a way to be able to
determine whether a ScopedCorePlatformApiCheck is the outermost
instance and whether the outmost instance was approved.
Test: build eng build (has checkjni), boot, grep logcat nio/Buffer
Test: build user build (regular jni), boot, grep logcat nio/Buffer
Bug: 130336799
Bug: 136276414
Change-Id: If1261046dd57c007bc77b213daaa5f733151123e
7 files changed