From ed4d7c282051a9f20f125ac00f8f8efa29cf65f6 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Fri, 7 Dec 2018 10:40:38 +0000 Subject: [PATCH] UnsupportedAppUsage - support implicit member signatures Allows the signature of implicit members, i.e. members that are added by the compiler, e.g. enum values() and valueOf(String) methods or default constructors to be specified per class. The UnsupportedAppUsage can now be repeated on a class so as to specify multiple implicit members. Bug: 119861512 Test: atest class2greylisttest, m -j20 framework Change-Id: I73c8402e9c2053e3a04ef0ff8875ce446593ec8f --- .../annotation/UnsupportedAppUsage.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/core/java/android/annotation/UnsupportedAppUsage.java b/core/java/android/annotation/UnsupportedAppUsage.java index 28145a06ecf2e..65e3f25f8fb6b 100644 --- a/core/java/android/annotation/UnsupportedAppUsage.java +++ b/core/java/android/annotation/UnsupportedAppUsage.java @@ -18,8 +18,10 @@ package android.annotation; import static java.lang.annotation.ElementType.CONSTRUCTOR; import static java.lang.annotation.ElementType.FIELD; import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.CLASS; +import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; import java.lang.annotation.Target; @@ -40,7 +42,8 @@ import java.lang.annotation.Target; * {@hide} */ @Retention(CLASS) -@Target({CONSTRUCTOR, METHOD, FIELD}) +@Target({CONSTRUCTOR, METHOD, FIELD, TYPE}) +@Repeatable(UnsupportedAppUsage.Container.class) public @interface UnsupportedAppUsage { /** @@ -90,4 +93,27 @@ public @interface UnsupportedAppUsage { * @return A dex API signature. */ String expectedSignature() default ""; + + /** + * The signature of an implicit (not present in the source) member that forms part of the + * hiddenapi. + * + *

Allows access to non-SDK API elements that are not represented in the input source to be + * managed. + * + *

This must only be used when applying the annotation to a type, using it in any other + * situation is an error. + * + * @return A dex API signature. + */ + String implicitMember() default ""; + + /** + * Container for {@link UnsupportedAppUsage} that allows it to be applied repeatedly to types. + */ + @Retention(CLASS) + @Target(TYPE) + @interface Container { + UnsupportedAppUsage[] value(); + } }