Remove member signature and inner classes from signature-patterns.csv
Previously, the signature-patterns.csv file included a lot of
implementation details, e.g. the signatures of dex members or inner
classes that are not part of any API, including the hidden API.
This change will remove all member signatures and inner class names
from the file and replace them with just the outermost qualified class
name.
That will still leave some implementation details, e.g. the names of
implementation only classes and packages.
Bug: 194063708
Test: atest --host verify_overlaps_test signature_patterns_test
m out/soong/hiddenapi/hiddenapi-flags.csv
- manually change files to cause difference in flags to check
that it detects the differences.
Change-Id: I9de6a2a6129e875e19f7ded5fae578cbdb584660
diff --git a/scripts/hiddenapi/signature_patterns.py b/scripts/hiddenapi/signature_patterns.py
index 91328e6..a7c5bb4 100755
--- a/scripts/hiddenapi/signature_patterns.py
+++ b/scripts/hiddenapi/signature_patterns.py
@@ -30,11 +30,21 @@
return produce_patterns_from_stream(f)
def produce_patterns_from_stream(stream):
- patterns = []
- allFlagsReader = dict_reader(stream)
- for row in allFlagsReader:
+ # Read in all the signatures into a list and remove member names.
+ patterns = set()
+ for row in dict_reader(stream):
signature = row['signature']
- patterns.append(signature)
+ text = signature.removeprefix("L")
+ # Remove the class specific member signature
+ pieces = text.split(";->")
+ qualifiedClassName = pieces[0]
+ # Remove inner class names as they cannot be separated from the containing outer class.
+ pieces = qualifiedClassName.split("$", maxsplit=1)
+ pattern = pieces[0]
+ patterns.add(pattern)
+
+ patterns = list(patterns)
+ patterns.sort()
return patterns
def main(args):