@RavenwoodSupported to show APIs supported by...
subclasses on the dashboard.
Bug: 414821464
Test: $ANDROID_BUILD_TOP/frameworks/base/ravenwood/scripts/run-ravenwood-tests.sh -s
Flag: TEST_ONLY
Change-Id: I3e4a93ff543ceddd3e8988349cee180f9ff54d02
diff --git a/java/android/ravenwood/annotation/RavenwoodClassLoadHook.java b/java/android/ravenwood/annotation/RavenwoodClassLoadHook.java
index c47aa94..4be38c9 100644
--- a/java/android/ravenwood/annotation/RavenwoodClassLoadHook.java
+++ b/java/android/ravenwood/annotation/RavenwoodClassLoadHook.java
@@ -44,4 +44,7 @@
*/
public static String LIBANDROID_LOADING_HOOK
= "com.android.platform.test.ravenwood.runtimehelper.ClassLoadHook.onClassLoaded";
+
+ /** Optional, human-readable comment */
+ String comment() default "";
}
diff --git a/java/android/ravenwood/annotation/RavenwoodIgnore.java b/java/android/ravenwood/annotation/RavenwoodIgnore.java
index 775cfab..8c5ed2a 100644
--- a/java/android/ravenwood/annotation/RavenwoodIgnore.java
+++ b/java/android/ravenwood/annotation/RavenwoodIgnore.java
@@ -48,4 +48,7 @@
* Tracking bug number, if any.
*/
long bug() default 0;
+
+ /** Optional, human-readable comment */
+ String comment() default "";
}
diff --git a/java/android/ravenwood/annotation/RavenwoodKeep.java b/java/android/ravenwood/annotation/RavenwoodKeep.java
index 52c3b70..4caea9e 100644
--- a/java/android/ravenwood/annotation/RavenwoodKeep.java
+++ b/java/android/ravenwood/annotation/RavenwoodKeep.java
@@ -35,4 +35,6 @@
@Target({FIELD, METHOD, CONSTRUCTOR})
@Retention(RetentionPolicy.CLASS)
public @interface RavenwoodKeep {
+ /** Optional, human-readable comment */
+ String comment() default "";
}
diff --git a/java/android/ravenwood/annotation/RavenwoodKeepPartialClass.java b/java/android/ravenwood/annotation/RavenwoodKeepPartialClass.java
index 61bb613..ffe6ba0 100644
--- a/java/android/ravenwood/annotation/RavenwoodKeepPartialClass.java
+++ b/java/android/ravenwood/annotation/RavenwoodKeepPartialClass.java
@@ -35,4 +35,6 @@
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface RavenwoodKeepPartialClass {
+ /** Optional, human-readable comment */
+ String comment() default "";
}
diff --git a/java/android/ravenwood/annotation/RavenwoodKeepStaticInitializer.java b/java/android/ravenwood/annotation/RavenwoodKeepStaticInitializer.java
index abd1074..793f7dd 100644
--- a/java/android/ravenwood/annotation/RavenwoodKeepStaticInitializer.java
+++ b/java/android/ravenwood/annotation/RavenwoodKeepStaticInitializer.java
@@ -34,4 +34,6 @@
@Target(TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface RavenwoodKeepStaticInitializer {
+ /** Optional, human-readable comment */
+ String comment() default "";
}
diff --git a/java/android/ravenwood/annotation/RavenwoodKeepWholeClass.java b/java/android/ravenwood/annotation/RavenwoodKeepWholeClass.java
index 7310b4b..3a27e54 100644
--- a/java/android/ravenwood/annotation/RavenwoodKeepWholeClass.java
+++ b/java/android/ravenwood/annotation/RavenwoodKeepWholeClass.java
@@ -37,4 +37,6 @@
@Target({TYPE, FIELD, METHOD, CONSTRUCTOR})
@Retention(RetentionPolicy.CLASS)
public @interface RavenwoodKeepWholeClass {
+ /** Optional, human-readable comment */
+ String comment() default "";
}
diff --git a/java/android/ravenwood/annotation/RavenwoodPartiallyAllowlisted.java b/java/android/ravenwood/annotation/RavenwoodPartiallyAllowlisted.java
index 166db7b..939790d 100644
--- a/java/android/ravenwood/annotation/RavenwoodPartiallyAllowlisted.java
+++ b/java/android/ravenwood/annotation/RavenwoodPartiallyAllowlisted.java
@@ -35,4 +35,6 @@
@Target({TYPE})
@Retention(RetentionPolicy.CLASS)
public @interface RavenwoodPartiallyAllowlisted {
+ /** Optional, human-readable comment */
+ String comment() default "";
}
diff --git a/java/android/ravenwood/annotation/RavenwoodRedirect.java b/java/android/ravenwood/annotation/RavenwoodRedirect.java
index aae4c3c..f82a25c 100644
--- a/java/android/ravenwood/annotation/RavenwoodRedirect.java
+++ b/java/android/ravenwood/annotation/RavenwoodRedirect.java
@@ -67,4 +67,6 @@
@Target({METHOD})
@Retention(RetentionPolicy.CLASS)
public @interface RavenwoodRedirect {
+ /** Optional, human-readable comment */
+ String comment() default "";
}
diff --git a/java/android/ravenwood/annotation/RavenwoodRedirectionClass.java b/java/android/ravenwood/annotation/RavenwoodRedirectionClass.java
index bb8bddb..553f2dc 100644
--- a/java/android/ravenwood/annotation/RavenwoodRedirectionClass.java
+++ b/java/android/ravenwood/annotation/RavenwoodRedirectionClass.java
@@ -36,4 +36,7 @@
@Retention(RetentionPolicy.CLASS)
public @interface RavenwoodRedirectionClass {
String value();
+
+ /** Optional, human-readable comment */
+ String comment() default "";
}
diff --git a/java/android/ravenwood/annotation/RavenwoodRemove.java b/java/android/ravenwood/annotation/RavenwoodRemove.java
index db41a2a..7b7ffeb 100644
--- a/java/android/ravenwood/annotation/RavenwoodRemove.java
+++ b/java/android/ravenwood/annotation/RavenwoodRemove.java
@@ -54,4 +54,7 @@
* Tracking bug number, if any.
*/
long bug() default 0;
+
+ /** Optional, human-readable comment */
+ String comment() default "";
}
diff --git a/java/android/ravenwood/annotation/RavenwoodReplace.java b/java/android/ravenwood/annotation/RavenwoodReplace.java
index 197f65f..3487966 100644
--- a/java/android/ravenwood/annotation/RavenwoodReplace.java
+++ b/java/android/ravenwood/annotation/RavenwoodReplace.java
@@ -66,4 +66,7 @@
* Tracking bug number, if any.
*/
long bug() default 0;
+
+ /** Optional, human-readable comment */
+ String comment() default "";
}
diff --git a/java/android/ravenwood/annotation/RavenwoodSupported.java b/java/android/ravenwood/annotation/RavenwoodSupported.java
new file mode 100644
index 0000000..37d86c3
--- /dev/null
+++ b/java/android/ravenwood/annotation/RavenwoodSupported.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.ravenwood.annotation;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Denotes that the annotated method is supported on Ravenwood with a subclass in the ravenwood
+ * runtime.
+ *
+ * For example, most of the {@link android.content.Context} class is supported via
+ * the {@code RavenwoodContext} class in the ravenwood runtime.
+ *
+ * Note, this annotation is purely for documentation and for the dashboard.
+ *
+ * The annotations are validated by
+ * {@code com.android.ravenwoodtest.coretest.RavenwoodSupportedAnnotationTest}.
+ *
+ * TODO: Make it work class-wide too.
+ *
+ * @hide
+ */
+@Target({METHOD})
+@Retention(RetentionPolicy.CLASS)
+public @interface RavenwoodSupported {
+ enum SupportType {
+ OTHER,
+ /**
+ * The API is supported by a subclass in ravenwood-runtime.
+ * {@link #subclass} should contain the name of the class.
+ */
+ SUBCLASS,
+ }
+
+ /** How the API is supported. */
+ SupportType type();
+
+ /** If it's implemented by a subclass, then its name. */
+ String subclass() default "";
+
+ /** Optional, human-readable comment */
+ String comment() default "";
+
+ /**
+ * Tracking bug number, if any.
+ */
+ long bug() default 0;
+
+ /**
+ * A marker annotation for a class that provides implementation for {@link RavenwoodSupported}
+ * methods. It's just for documentation and doesn't do anything at runtime.
+ */
+ @Target({TYPE})
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface RavenwoodProvidingImplementation {
+ /** Target class that has methods that are implemented by this class. */
+ Class<?> target();
+
+ /** Optional, human-readable comment */
+ String comment() default "";
+ }
+}
diff --git a/java/android/ravenwood/annotation/RavenwoodThrow.java b/java/android/ravenwood/annotation/RavenwoodThrow.java
index 4cc9d1c..68cda18 100644
--- a/java/android/ravenwood/annotation/RavenwoodThrow.java
+++ b/java/android/ravenwood/annotation/RavenwoodThrow.java
@@ -30,7 +30,7 @@
* will throw a runtime exception with a message indicating that the method is unsupported
* on Ravenwood.
*
- * TODO: Create "whole-class-throw"?
+ * TODO: Make it work class-wide too.
*
* @hide
*/
@@ -51,4 +51,7 @@
* Tracking bug number, if any.
*/
long bug() default 0;
+
+ /** Optional, human-readable comment */
+ String comment() default "";
}