Make signature tests work with system-current.txt changes

This is a big change but breaking it down into smaller pieces would
have taken longer and there just is not time to do that work. The goal
with this is to fix the tests so that they can be used to test some
other changes that are a priority.

Fundamentally the tests broke because they depended heavily on the
API definition files being a close match for the actual implementation
of the API. When the API definition files were changed the tests broke.

See b/71887619 for more details.

The InterfaceChecker was added to address the main issue that the API
definition changes caused. It collates information about all the
interface definitions it finds so that it can compute the transitive
set of methods defined by an interface and the interfaces it extends in
the API definition and compare it with the equivalent set computed from
the runtime classes.

A base-api-files option was added to allow the apache and system test
modules to provide additional definitions for interfaces referenced
from their main API definition file but not defined there.

The above changes fixed a lot of the issues but they also highlighted
some other test failures which needed fixing. In particular there was
an interaction between the above fix and the annotation check that was
recently added.

The CtsSystemCurrentApiSignatureTestCases was doing two separate but
related tests. One to check that the API signatures defined in the
system-current.txt were visible at runtime and the other to check that
the only runtime classes/members that were annotated with @SystemApi
were those defined in the system-current.txt.

The problem is that those tests would not both work at the same time.
In order for the signature test to work it needed access to some
interface definitions in the current.txt - which were merged into the
definitions from system-current.txt. However, that broke the annotation
test because it assumed that all members in its class definitions were
expected to have @SystemApi on but the ones merged from current.txt
obviously did not.

One approach would have been to maintain information about where the
API definitions came from and use that to handle the two different
cases but that would have added a lot of complexity to the
ApiComplianceChecker that was only needed for one test. That complexity
would make maintenance more difficult and also would have impacted
plans for additional tests.

Instead the SignatureTest and ApiComplianceChecker classes were each
split into three parts, one for testing the API signatures, one for
testing the annotations and a base class where the common code lives.

* SignatureTest was split into AbstractApiTest and AnnotationTest
* ApiComplianceChecker was split into AbstractApiChecker and
  AnnotationChecker - with corresponding changes to its test.

A new CtsSystemApiAnnotationTestCases module was added that will run
the AnnotationTest.

Previously each CTS module had only included a single JUnit test class
and just ran all the tests it could find. The addition of
AnnotationTest, required that every module had to explicitly specify
the test to run, hence the addition of the class option to the
AndroidTest.xml files.

Another significant change was to change ApiDocumentParser to produce
a Stream<JDiffClassDescription> objects rather than use its own
Listener mechanism. That avoided the replication of Stream like
capabilities around the Listener class.

Other miscellaneous changes:
* The android-test-base-27-api had an incorrect package name in its
  manifest.
* The BootClassPathClassesProvider cached a Stream but it was
  unnecessary because they can only be used once.
* Tightened up accessiblity and added final where appropriate.

Unit tests ran using:
m -j20 tradefed hosttestlib signature-hostside signature-tests &&
   cts/tests/signature/tests/run_unit_tests.sh

CTS tests run using:
cts/tests/signature/runSignatureTests.sh

The new CtsSystemApiAnnotationTestCases test fails. That is a known
issue with the API definition file which is being corrected in a
separate change.

Test: See above.
Bug: 71887619
Bug: 71420101
Bug: 18027885
Change-Id: I5e1d85e13759f486e263919d43be3fdf9a42f8f0
32 files changed