diff options
author | Mårten Kongstad <amhk@google.com> | 2024-04-28 00:21:11 +0200 |
---|---|---|
committer | Mårten Kongstad <amhk@google.com> | 2024-05-02 09:53:54 +0200 |
commit | b4a14bfaa9915d8da91a4ad4987c39b033aab5ac (patch) | |
tree | 90dcd8d23ddc433a4d3363dd69aba13ec7a61ddb | |
parent | ece054c856fa083a343ac13be6e286c6da3853f3 (diff) | |
download | build-b4a14bfaa9915d8da91a4ad4987c39b033aab5ac.tar.gz |
check-flagged-apis: add support for method with parameters
Teach check-flagged-apis to parse methods containing parameters.
Bug: 334870672
Test: atest --host check-flagged-apis-test
Change-Id: I171660b914b73fd85e03ed9300c2c81f33d80d61
-rw-r--r-- | tools/check-flagged-apis/src/com/android/checkflaggedapis/CheckFlaggedApisTest.kt | 27 | ||||
-rw-r--r-- | tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt | 7 |
2 files changed, 28 insertions, 6 deletions
diff --git a/tools/check-flagged-apis/src/com/android/checkflaggedapis/CheckFlaggedApisTest.kt b/tools/check-flagged-apis/src/com/android/checkflaggedapis/CheckFlaggedApisTest.kt index 04c2f80e79..2f76b2a5a7 100644 --- a/tools/check-flagged-apis/src/com/android/checkflaggedapis/CheckFlaggedApisTest.kt +++ b/tools/check-flagged-apis/src/com/android/checkflaggedapis/CheckFlaggedApisTest.kt @@ -34,6 +34,9 @@ private val API_SIGNATURE = ctor @FlaggedApi("android.flag.foo") public Clazz(); field @FlaggedApi("android.flag.foo") public static final int FOO = 1; // 0x1 method @FlaggedApi("android.flag.foo") public int getErrorCode(); + method @FlaggedApi("android.flag.foo") public boolean setData(int, int[][], @NonNull android.util.Utility<T, U>); + method @FlaggedApi("android.flag.foo") public boolean setVariableData(int, android.util.Atom...); + method @FlaggedApi("android.flag.foo") public boolean innerClassArg(android.Clazz.Builder); } @FlaggedApi("android.flag.bar") public static class Clazz.Builder { } @@ -49,6 +52,9 @@ private val API_VERSIONS = <method name="<init>()V"/> <field name="FOO"/> <method name="getErrorCode()I"/> + <method name="setData(I[[ILandroid/util/Utility;)Z"/> + <method name="setVariableData(I[Landroid/util/Atom;)Z"/> + <method name="innerClassArg(Landroid/Clazz${"$"}Builder;)"/> </class> <class name="android/Clazz${"$"}Builder" since="2"> </class> @@ -93,6 +99,15 @@ class CheckFlaggedApisTest { Pair(Symbol("android/Clazz/Clazz()"), Flag("android.flag.foo")), Pair(Symbol("android/Clazz/FOO"), Flag("android.flag.foo")), Pair(Symbol("android/Clazz/getErrorCode()"), Flag("android.flag.foo")), + Pair( + Symbol("android/Clazz/setData(I[[ILandroid/util/Utility;)"), + Flag("android.flag.foo")), + Pair( + Symbol("android/Clazz/setVariableData(I[Landroid/util/Atom;)"), + Flag("android.flag.foo")), + Pair( + Symbol("android/Clazz/innerClassArg(Landroid/Clazz/Builder;)"), + Flag("android.flag.foo")), Pair(Symbol("android/Clazz/Builder"), Flag("android.flag.bar")), ) val actual = parseApiSignature("in-memory", API_SIGNATURE.byteInputStream()) @@ -115,6 +130,9 @@ class CheckFlaggedApisTest { Symbol("android/Clazz/Clazz()"), Symbol("android/Clazz/FOO"), Symbol("android/Clazz/getErrorCode()"), + Symbol("android/Clazz/setData(I[[ILandroid/util/Utility;)"), + Symbol("android/Clazz/setVariableData(I[Landroid/util/Atom;)"), + Symbol("android/Clazz/innerClassArg(Landroid/Clazz/Builder;)"), Symbol("android/Clazz/Builder"), ) val actual = parseApiVersions(API_VERSIONS.byteInputStream()) @@ -143,6 +161,15 @@ class CheckFlaggedApisTest { DisabledFlaggedApiIsPresentError( Symbol("android/Clazz/getErrorCode()"), Flag("android.flag.foo")), DisabledFlaggedApiIsPresentError( + Symbol("android/Clazz/setData(I[[ILandroid/util/Utility;)"), + Flag("android.flag.foo")), + DisabledFlaggedApiIsPresentError( + Symbol("android/Clazz/setVariableData(I[Landroid/util/Atom;)"), + Flag("android.flag.foo")), + DisabledFlaggedApiIsPresentError( + Symbol("android/Clazz/innerClassArg(Landroid/Clazz/Builder;)"), + Flag("android.flag.foo")), + DisabledFlaggedApiIsPresentError( Symbol("android/Clazz/Builder"), Flag("android.flag.bar")), ) val actual = diff --git a/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt b/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt index 0f2fbef719..e15e7fa6eb 100644 --- a/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt +++ b/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt @@ -178,7 +178,6 @@ The tool will exit with a non-zero exit code if any flagged APIs are found to be } internal fun parseApiSignature(path: String, input: InputStream): Set<Pair<Symbol, Flag>> { - // TODO(334870672): add support for metods val output = mutableSetOf<Pair<Symbol, Flag>>() val visitor = object : BaseItemVisitor() { @@ -203,11 +202,7 @@ internal fun parseApiSignature(path: String, input: InputStream): Set<Pair<Symbo append(".") append(method.name()) append("(") - // TODO(334870672): replace this early return with proper parsing of the command line - // arguments, followed by translation to Lname/of/class; + III format - if (!method.parameters().isEmpty()) { - return - } + method.parameters().joinTo(this, separator = "") { it.type().internalName() } append(")") } val symbol = Symbol.create(name) |