Updates hidden api CTS tests to filter out APIs we are moving to the
non-SDK API list.
Bug: 168812851
Test: atest CtsHiddenApiBlocklistCurrentApiTestCases
Change-Id: I241c3c3c3fc6412b2a86c5fb49e20dc19b0cdaec
diff --git a/tests/signature/api-check/Android.bp b/tests/signature/api-check/Android.bp
index cfc4850..d4dfc5f 100644
--- a/tests/signature/api-check/Android.bp
+++ b/tests/signature/api-check/Android.bp
@@ -72,12 +72,20 @@
filename: "hiddenapi-flags.csv",
}
+filegroup {
+ name: "cts-api-hiddenapi-filter-csv",
+ srcs: [
+ "hiddenapi-filter.csv",
+ ],
+}
+
// Defaults for hiddenapi blocklist checks.
java_defaults {
name: "hiddenapi-blocklist-check-defaults",
defaults: ["signature-api-check-defaults"],
java_resources: [
":cts-hiddenapi-flags-csv",
+ ":cts-api-hiddenapi-filter-csv"
],
jni_libs: [
"libcts_dexchecker",
diff --git a/tests/signature/api-check/hidden-api-blocklist-27-api/AndroidTest.xml b/tests/signature/api-check/hidden-api-blocklist-27-api/AndroidTest.xml
index 2d1a0a9..fdf5bfa 100644
--- a/tests/signature/api-check/hidden-api-blocklist-27-api/AndroidTest.xml
+++ b/tests/signature/api-check/hidden-api-blocklist-27-api/AndroidTest.xml
@@ -29,6 +29,7 @@
<option name="class" value="android.signature.cts.api.api27.HiddenApiTest" />
<option name="instrumentation-arg" key="hiddenapi-files" value="hiddenapi-flags.csv" />
<option name="instrumentation-arg" key="hiddenapi-test-flags" value="blocked" />
+ <option name="instrumentation-arg" key="hiddenapi-filter-file" value="hiddenapi-filter.csv" />
<option name="test-api-access" value="false" />
<option name="runtime-hint" value="30s" />
</test>
diff --git a/tests/signature/api-check/hidden-api-blocklist-28-api/AndroidTest.xml b/tests/signature/api-check/hidden-api-blocklist-28-api/AndroidTest.xml
index 5d7d885..30d29f0 100644
--- a/tests/signature/api-check/hidden-api-blocklist-28-api/AndroidTest.xml
+++ b/tests/signature/api-check/hidden-api-blocklist-28-api/AndroidTest.xml
@@ -29,6 +29,7 @@
<option name="class" value="android.signature.cts.api.api28.HiddenApiTest" />
<option name="instrumentation-arg" key="hiddenapi-files" value="hiddenapi-flags.csv" />
<option name="instrumentation-arg" key="hiddenapi-test-flags" value="blocked,max-target-o" />
+ <option name="instrumentation-arg" key="hiddenapi-filter-file" value="hiddenapi-filter.csv" />
<option name="test-api-access" value="false" />
<option name="runtime-hint" value="30s" />
</test>
diff --git a/tests/signature/api-check/hidden-api-blocklist-current-api/AndroidTest.xml b/tests/signature/api-check/hidden-api-blocklist-current-api/AndroidTest.xml
index 5d020ea..7063418 100644
--- a/tests/signature/api-check/hidden-api-blocklist-current-api/AndroidTest.xml
+++ b/tests/signature/api-check/hidden-api-blocklist-current-api/AndroidTest.xml
@@ -29,6 +29,7 @@
<option name="class" value="android.signature.cts.api.current.HiddenApiTest" />
<option name="instrumentation-arg" key="hiddenapi-files" value="hiddenapi-flags.csv" />
<option name="instrumentation-arg" key="hiddenapi-test-flags" value="blocked,max-target-o,max-target-p" />
+ <option name="instrumentation-arg" key="hiddenapi-filter-file" value="hiddenapi-filter.csv" />
<option name="test-api-access" value="false" />
<option name="runtime-hint" value="30s" />
</test>
diff --git a/tests/signature/api-check/hidden-api-blocklist-debug-class/AndroidTest.xml b/tests/signature/api-check/hidden-api-blocklist-debug-class/AndroidTest.xml
index 73212ad..2ab58bd 100644
--- a/tests/signature/api-check/hidden-api-blocklist-debug-class/AndroidTest.xml
+++ b/tests/signature/api-check/hidden-api-blocklist-debug-class/AndroidTest.xml
@@ -29,6 +29,7 @@
<option name="class" value="android.signature.cts.api.DebugClassHiddenApiTest" />
<option name="instrumentation-arg" key="hiddenapi-files" value="hiddenapi-flags.csv" />
<option name="instrumentation-arg" key="hiddenapi-test-flags" value="blocked,max-target-o,max-target-p" />
+ <option name="instrumentation-arg" key="hiddenapi-filter-file" value="hiddenapi-filter.csv" />
<option name="test-api-access" value="false" />
<option name="runtime-hint" value="30s" />
</test>
diff --git a/tests/signature/api-check/hiddenapi-filter.csv b/tests/signature/api-check/hiddenapi-filter.csv
new file mode 100644
index 0000000..eb4ef42
--- /dev/null
+++ b/tests/signature/api-check/hiddenapi-filter.csv
@@ -0,0 +1,36 @@
+# These APIs were reverted from the blocklist to the non-SDK API list (b/168812851)
+Landroid/bluetooth/BluetoothCodecConfig;-><init>(I)V,blocked
+Landroid/bluetooth/BluetoothCodecConfig;-><init>(IIIIIJJJJ)V,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->BITS_PER_SAMPLE_16:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->BITS_PER_SAMPLE_24:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->BITS_PER_SAMPLE_32:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->BITS_PER_SAMPLE_NONE:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->CHANNEL_MODE_MONO:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->CHANNEL_MODE_NONE:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->CHANNEL_MODE_STEREO:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->CODEC_PRIORITY_DEFAULT:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->CODEC_PRIORITY_DISABLED:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->CODEC_PRIORITY_HIGHEST:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->SAMPLE_RATE_176400:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->SAMPLE_RATE_192000:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->SAMPLE_RATE_44100:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->SAMPLE_RATE_48000:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->SAMPLE_RATE_88200:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->SAMPLE_RATE_96000:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->SAMPLE_RATE_NONE:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->SOURCE_CODEC_TYPE_AAC:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->SOURCE_CODEC_TYPE_APTX:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->SOURCE_CODEC_TYPE_APTX_HD:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->SOURCE_CODEC_TYPE_INVALID:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->SOURCE_CODEC_TYPE_LDAC:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->SOURCE_CODEC_TYPE_MAX:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->SOURCE_CODEC_TYPE_SBC:I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->getBitsPerSample()I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->getCodecPriority()I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->getCodecSpecific1()J,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->getCodecType()I,blocked
+Landroid/bluetooth/BluetoothCodecConfig;->getSampleRate()I,blocked
+Landroid/bluetooth/BluetoothCodecStatus;->EXTRA_CODEC_STATUS:Ljava/lang/String;,blocked
+Landroid/bluetooth/BluetoothCodecStatus;->getCodecConfig()Landroid/bluetooth/BluetoothCodecConfig;,blocked
+Landroid/bluetooth/BluetoothCodecStatus;->getCodecsLocalCapabilities()[Landroid/bluetooth/BluetoothCodecConfig;,blocked
+Landroid/bluetooth/BluetoothCodecStatus;->getCodecsSelectableCapabilities()[Landroid/bluetooth/BluetoothCodecConfig;,blocked
\ No newline at end of file
diff --git a/tests/signature/api-check/src/java/android/signature/cts/api/HiddenApiTest.java b/tests/signature/api-check/src/java/android/signature/cts/api/HiddenApiTest.java
index feca46d..31c2fb3 100644
--- a/tests/signature/api-check/src/java/android/signature/cts/api/HiddenApiTest.java
+++ b/tests/signature/api-check/src/java/android/signature/cts/api/HiddenApiTest.java
@@ -26,7 +26,10 @@
import android.signature.cts.VirtualPath;
import java.io.BufferedReader;
+import java.io.IOException;
import java.io.InputStreamReader;
+import java.text.ParseException;
+import java.util.HashSet;
import java.util.Set;
import java.util.function.Predicate;
@@ -37,17 +40,22 @@
private String[] hiddenapiFiles;
private String[] hiddenapiTestFlags;
+ private String hiddenapiFilterFile;
+ private Set<String> hiddenapiFilterSet;
@Override
protected void initializeFromArgs(Bundle instrumentationArgs) {
hiddenapiFiles = getCommaSeparatedList(instrumentationArgs, "hiddenapi-files");
hiddenapiTestFlags = getCommaSeparatedList(instrumentationArgs, "hiddenapi-test-flags");
+ hiddenapiFilterFile = instrumentationArgs.getString("hiddenapi-filter-file");
+ hiddenapiFilterSet = new HashSet<>();
}
@Override
protected void setUp() throws Exception {
super.setUp();
DexMemberChecker.init();
+ loadFilters();
}
// We have four methods to split up the load, keeping individual test runs small.
@@ -146,7 +154,8 @@
String line = reader.readLine();
while (line != null) {
DexMember dexMember = DexApiDocumentParser.parseLine(line, lineIndex);
- if (memberFilter.test(dexMember) && shouldTestMember(dexMember)) {
+ if (memberFilter.test(dexMember) && shouldTestMember(dexMember)
+ && !hiddenapiFilterSet.contains(line)) {
DexMemberChecker.checkSingleMember(dexMember, reflection, jni,
observer);
}
@@ -167,4 +176,21 @@
return false;
}
+ private void loadFilters() throws IOException, ParseException {
+ // Avoids testing members in filter file (only a single filter file can be supplied)
+ if (hiddenapiFilterFile != null) {
+ VirtualPath.ResourcePath resourcePath =
+ VirtualPath.get(getClass().getClassLoader(), hiddenapiFilterFile);
+ BufferedReader reader = new BufferedReader(
+ new InputStreamReader(resourcePath.newInputStream()));
+ String filterFileLine = reader.readLine();
+ while (filterFileLine != null) {
+ if (!filterFileLine.startsWith("#")) {
+ hiddenapiFilterSet.add(filterFileLine);
+ }
+ filterFileLine = reader.readLine();
+ }
+ }
+ }
+
}