hiddenapi: Fix class hierarchy traversal

`hiddenapi` builds and traverses the class hierarchy, visiting all
class members that methods/fields in stubs may resolve to.

The algorithm wouldn't work when:
* an interface declares a method which is in stubs, and
* a class implements the interface by inheriting the method from its
  superclass; neither the class nor its superclass are in stubs.
The problem was that once a matching method was found, only subclasses
would be traversed. In this case, the method would be found in the
interface, the class which implements it would be traversed but its
superclass would not.

This patch simplifies the algorithm and partially reverts a performance
optimization which caused the problem. As a result, there is a build
time regression from 5s to 8s.

The patch also adds gtests which test this behaviour. There were no
tests until now because stubs are not present in master-art manifest.
Get around this issue by using the actual core JARs as stubs but test
the behaviour on other classes.

Bug: 122551864
Test: m test-art-host-gtest-hiddenapi_test
Change-Id: I63751c5ef517c8e9d3a157dfbec8de01bd99c2d4
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index 67d85c1..eac3511 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -38,6 +38,7 @@
   GetMethodSignature \
   HiddenApi \
   HiddenApiSignatures \
+  HiddenApiStubs \
   ImageLayoutA \
   ImageLayoutB \
   IMTA \
@@ -188,7 +189,7 @@
 ART_GTEST_dex2oat_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS) ManyMethods Statics VerifierDeps MainUncompressed EmptyUncompressed StringLiterals
 ART_GTEST_dex2oat_image_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS) Statics VerifierDeps
 ART_GTEST_exception_test_DEX_DEPS := ExceptionHandle
-ART_GTEST_hiddenapi_test_DEX_DEPS := HiddenApi
+ART_GTEST_hiddenapi_test_DEX_DEPS := HiddenApi HiddenApiStubs
 ART_GTEST_hidden_api_test_DEX_DEPS := HiddenApiSignatures
 ART_GTEST_image_test_DEX_DEPS := ImageLayoutA ImageLayoutB DefaultMethods VerifySoftFailDuringClinit
 ART_GTEST_imtable_test_DEX_DEPS := IMTA IMTB