Filter-out synthetic API elements in CtsSystemApiAnnotationTestCases

CtsSystemApiAnnotationTestCases checks if there is any runtime API
element that is annotated with @SystemApi that is not in the approved
System APIs. To do so, it gathers

R: all runtime API elements that are annotated with @SystemApi
A: approved System APIs

and triggers an error when R - A is not empty.

However, it turned out that R contains synthetic API elements which
are not found in A. Here's a concrete example:

@SystemApi
public abstract class Parent {
  @SystemApi
  public static class Result {...}

  @SystemApi
  public Result foo() {...}
}

@SystemApi
public class Child extends Parent {
  @SystemApi
  public static class DetailedResult extends Result {...}

  @SystemApi
  @Override
  public DetailedResult foo() {...}
}

Then Child.class.getDeclaredMethods() returns

* Parent$Result Child.foo() and
* Child$DetailedResult Child.foo()

The former method is a synthetic one and isn't of course in the approved
APIs.

This change fixes the problem by pruning the synthetic ones from R.

Bug: N/A
Test: atest CtsSystemApiAnnotationTestCases
Change-Id: I231ff4f55f7bba06bb97b4f6f18a96913c9bcd23
1 file changed