Remove implementation details from stub flags in sdk snapshot
Previously, the build applied the same filtering to remove
implementation details from the sdk snapshot's stub-flags.csv file as
it did for its all-flags.csv, i.e. removing the signatures that only
had a "blocked" flag. Unfortunately, that had no effect on the stub
flags as the implementation signatures had no flags, not a single
blocked flag. That meant that the sdk snapshot's
filtered-stub-flags.csv file contained a lot of implementation details.
This change removes signatures from stub-flags.csv that have no flags
which removes all implementation details from the sdk snapshot.
Bug: 194063708
Test: atest --host verify_overlaps_test
m out/soong/hiddenapi/hiddenapi-flags.csv
m art-module-sdk
# Check contents of its filtered-stub-flags.csv file
Change-Id: I30edc77348fad118ea732e787ae8e206c8841f84
diff --git a/scripts/hiddenapi/verify_overlaps_test.py b/scripts/hiddenapi/verify_overlaps_test.py
index ead8a4e..0a489ee 100755
--- a/scripts/hiddenapi/verify_overlaps_test.py
+++ b/scripts/hiddenapi/verify_overlaps_test.py
@@ -221,7 +221,8 @@
modular = self.read_signature_csv_from_string_as_dict("""
Ljava/lang/Object;->hashCode()I,public-api,system-api,test-api
""")
- mismatches = vo.compare_signature_flags(monolithic, modular)
+ mismatches = vo.compare_signature_flags(monolithic, modular,
+ ["blocked"])
expected = []
self.assertEqual(expected, mismatches)
@@ -232,7 +233,8 @@
modular = self.read_signature_csv_from_string_as_dict("""
Ljava/lang/Object;->toString()Ljava/lang/String;,public-api,system-api,test-api
""")
- mismatches = vo.compare_signature_flags(monolithic, modular)
+ mismatches = vo.compare_signature_flags(monolithic, modular,
+ ["blocked"])
expected = [
(
"Ljava/lang/Object;->toString()Ljava/lang/String;",
@@ -249,7 +251,8 @@
modular = self.read_signature_csv_from_string_as_dict("""
Ljava/lang/Object;->toString()Ljava/lang/String;,public-api,system-api,test-api
""")
- mismatches = vo.compare_signature_flags(monolithic, modular)
+ mismatches = vo.compare_signature_flags(monolithic, modular,
+ ["blocked"])
expected = [
(
"Ljava/lang/Object;->toString()Ljava/lang/String;",
@@ -266,7 +269,8 @@
modular = self.read_signature_csv_from_string_as_dict("""
Ljava/lang/Object;->toString()Ljava/lang/String;,blocked
""")
- mismatches = vo.compare_signature_flags(monolithic, modular)
+ mismatches = vo.compare_signature_flags(monolithic, modular,
+ ["blocked"])
expected = [
(
"Ljava/lang/Object;->toString()Ljava/lang/String;",
@@ -281,7 +285,8 @@
modular = self.read_signature_csv_from_string_as_dict("""
Ljava/lang/Object;->toString()Ljava/lang/String;,public-api,system-api,test-api
""")
- mismatches = vo.compare_signature_flags(monolithic, modular)
+ mismatches = vo.compare_signature_flags(monolithic, modular,
+ ["blocked"])
expected = [
(
"Ljava/lang/Object;->toString()Ljava/lang/String;",
@@ -296,7 +301,8 @@
Ljava/lang/Object;->hashCode()I,public-api,system-api,test-api
""")
modular = {}
- mismatches = vo.compare_signature_flags(monolithic, modular)
+ mismatches = vo.compare_signature_flags(monolithic, modular,
+ ["blocked"])
expected = [
(
"Ljava/lang/Object;->hashCode()I",
@@ -311,7 +317,47 @@
Ljava/lang/Object;->hashCode()I,blocked
""")
modular = {}
- mismatches = vo.compare_signature_flags(monolithic, modular)
+ mismatches = vo.compare_signature_flags(monolithic, modular,
+ ["blocked"])
+ expected = []
+ self.assertEqual(expected, mismatches)
+
+ def test_match_treat_missing_from_modular_as_empty(self):
+ monolithic = self.read_signature_csv_from_string_as_dict("")
+ modular = self.read_signature_csv_from_string_as_dict("""
+Ljava/lang/Object;->toString()Ljava/lang/String;,public-api,system-api,test-api
+""")
+ mismatches = vo.compare_signature_flags(monolithic, modular, [])
+ expected = [
+ (
+ "Ljava/lang/Object;->toString()Ljava/lang/String;",
+ ["public-api", "system-api", "test-api"],
+ [],
+ ),
+ ]
+ self.assertEqual(expected, mismatches)
+
+ def test_mismatch_treat_missing_from_modular_as_empty(self):
+ monolithic = self.read_signature_csv_from_string_as_dict("""
+Ljava/lang/Object;->hashCode()I,public-api,system-api,test-api
+""")
+ modular = {}
+ mismatches = vo.compare_signature_flags(monolithic, modular, [])
+ expected = [
+ (
+ "Ljava/lang/Object;->hashCode()I",
+ [],
+ ["public-api", "system-api", "test-api"],
+ ),
+ ]
+ self.assertEqual(expected, mismatches)
+
+ def test_empty_missing_from_modular(self):
+ monolithic = self.read_signature_csv_from_string_as_dict("""
+Ljava/lang/Object;->hashCode()I
+""")
+ modular = {}
+ mismatches = vo.compare_signature_flags(monolithic, modular, [])
expected = []
self.assertEqual(expected, mismatches)