From 40ec862c13a9d087dee03db0f490d4f463cc7ac6 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Wed, 15 Jan 2020 00:12:34 +0900 Subject: [PATCH] SystemApi is @Repeatable This allows us to annotate a class as below: /** @hide */ @SystemApi @SystemApi(client=MODULE_APPS) public class SomeClass { /** @hide */ @SystemApi public void foo() {...} /** @hide */ @SystemApi(client=MODULE_APPS) public void bar() {...} } SomeClass is already annotated as @SystemApi. And we want to make bar() method in it as SystemApi(MODULE_APPS). To do so, the containing class SomeClass has additionally to be annotated as SystemApi(MODULE_APPS), resulting SystemApi annotation to be repeated. Bug: N/A Test: add @SystemApi(client=MODULE_APPS) to an hidden method of an existing SystemApi class (e.g. SystemProperties.set()) and execute `m updata-api`. -> api/module-app-current.txt is updated while api/system-current.txt is unchanged Change-Id: Ifd4d32a6983cfc38f0dd13618652439f6162e0d3 --- core/java/android/annotation/SystemApi.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/java/android/annotation/SystemApi.java b/core/java/android/annotation/SystemApi.java index 2cb93e4f8cea7..d4c6993607d82 100644 --- a/core/java/android/annotation/SystemApi.java +++ b/core/java/android/annotation/SystemApi.java @@ -23,6 +23,7 @@ import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.PACKAGE; import static java.lang.annotation.ElementType.TYPE; +import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @@ -40,6 +41,7 @@ import java.lang.annotation.Target; */ @Target({TYPE, FIELD, METHOD, CONSTRUCTOR, ANNOTATION_TYPE, PACKAGE}) @Retention(RetentionPolicy.RUNTIME) +@Repeatable(SystemApi.Container.class) // TODO(b/146727827): make this non-repeatable public @interface SystemApi { enum Client { /** @@ -86,4 +88,14 @@ public @interface SystemApi { * The process(es) that this SystemAPI is available */ Process process() default android.annotation.SystemApi.Process.ALL; + + + /** + * Container for {@link SystemApi} that allows it to be applied repeatedly to types. + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(TYPE) + @interface Container { + SystemApi[] value(); + } }