Expand the number of signature tests

Replaces CtsApiSignatureTestCases which tests whether the runtime seen
by an app that has <uses-library android:name="android.test.runner"/> in
its manifest provides the API in frameworks/bases/api/current.txt with a
number of tests that test different app configurations.

CtsCurrentApiSignatureTestCases
    tests that an app that is targeted at the current API level and does
    not have any <uses-library> entries in its manifest can access the
    API described in frameworks/base/api/current.txt - excluding APIs
    provided by the android.test.runner and android.test.mock libraries.

CtsSystemCurrentApiSignatureTestCases
    tests that an app that is targeted at the current API level and does
    not have any <uses-library> entries in its manifest can access the
    API described in frameworks/base/api/system-current.txt - excluding
    APIs provided by the android.test.runner and android.test.mock
    libraries.

CtsAndroidTestMockCurrentApiSignatureTestCases
    tests that an app that is targeted at the current API level and has
    <uses-library android:name="android.test.mock"/> in its manifest can
    access the API described in
    frameworks/base/test-runner/api/android-test-mock-current.txt.

CtsAndroidTestRunnerCurrentApiSignatureTestCases
    tests that an app that is targeted at the current API level and has
    <uses-library android:name="android.test.runner"/> in its manifest
    can access the API described in
    frameworks/base/test-runner/api/android-test-runner-current.txt and
    in frameworks/base/test-runner/api/android-test-mock-current.txt.

CtsLegacyTest26ApiSignatureTestCases
    tests that an app that is targeted at API level 26 can access the
    API described in
    frameworks/base/legacy-test/api/legacy-test-current.txt.

Adds tests/signature/runSignatureTests.sh to run the above tests.

The rest of the changes are made to support the above tests:
* Changes SignatureTest and other Java files to support providing an API
  description file containing classes that are not expected to be
  accessible to the application. This is used to ensure that optional
  classes are not visible unless specifically requested.

* Generates additional *.api files for use by the above tests.

* Refactors the makefiles for generating *.api files and building test
  APKs to extract the common behavior into separate reusable *.mk files
  to reduce duplication.

Bug: 35192974
Bug: 30188076
Test: ran tests/signature/runSignatureTests.sh
Change-Id: Ibb178052a6098e4b42921067ae8ec86d6e7cb379
diff --git a/tests/signature/api-check/system-current-api/AndroidTest.xml b/tests/signature/api-check/system-current-api/AndroidTest.xml
new file mode 100644
index 0000000..ab7ea3c
--- /dev/null
+++ b/tests/signature/api-check/system-current-api/AndroidTest.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<configuration description="Config for CTS API Signature test cases">
+    <option name="config-descriptor:metadata" key="component" value="systems" />
+    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+        <option name="run-command" value="mkdir -p /data/local/tmp/signature-test" />
+        <option name="teardown-command" value="rm -rf /data/local/tmp/signature-test" />
+    </target_preparer>
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+        <option name="push" value="system-current.api->/data/local/tmp/signature-test/system-current.api" />
+    </target_preparer>
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+        <option name="push" value="android-test-mock-current.api->/data/local/tmp/signature-test/android-test-mock-current.api" />
+    </target_preparer>
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+        <option name="push" value="android-test-runner-current.api->/data/local/tmp/signature-test/android-test-runner-current.api" />
+    </target_preparer>
+    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsSystemCurrentApiSignatureTestCases.apk" />
+    </target_preparer>
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="package" value="android.signature.cts.api.system_current" />
+        <option name="runner" value="repackaged.android.test.InstrumentationTestRunner" />
+        <option name="instrumentation-arg" key="expected-api-files" value="system-current.api" />
+        <option name="instrumentation-arg" key="unexpected-api-files" value="android-test-mock-current.api,android-test-runner-current.api" />
+        <option name="runtime-hint" value="30s" />
+    </test>
+</configuration>