diff options
author | Jiyong Park <jiyong@google.com> | 2019-12-04 17:17:48 +0900 |
---|---|---|
committer | Jiyong Park <jiyong@google.com> | 2019-12-13 14:58:16 +0900 |
commit | 119afc0695cf7632700119bab62a965793c34fd1 (patch) | |
tree | be18bd3626459a8e3140f6bb477c90c544bce8c1 | |
parent | 74798fd9076badd23b9c236e9d3ba78f22636970 (diff) |
SystemApi is parameterized
We have decided to reuse the existing annotation @SystemApi for all Java
APIs regardless of whether they are for apps or platform internal
modules. This was because introducing new annotation types every time
when we have to create new API surfaces will only increase the confusion
without giving much benefit.
Instead, to differenciate the different API surfaces of @SystemApi, the
annotation type is parameterized. Specifically, it has to axises.
client: specifies the intended client of the API.
process: specifies the process(es) that the API is available.
The default for client and process are priv-apps and all, respectively,
which corresponds to the today's @SystemApi for privileged apps like
GMS.
Bug: 140202860
Test: m
Change-Id: I3305b71e22970e80db95f3daf3d7713603c7d68d
-rw-r--r-- | Android.bp | 10 | ||||
-rw-r--r-- | core/java/android/annotation/SystemApi.java | 25 | ||||
-rw-r--r-- | media/Android.bp | 2 | ||||
-rw-r--r-- | services/Android.bp | 2 |
4 files changed, 32 insertions, 7 deletions
diff --git a/Android.bp b/Android.bp index 04b4e6edf2ec..df118138cb33 100644 --- a/Android.bp +++ b/Android.bp @@ -1172,7 +1172,7 @@ droidstubs { arg_files: [ "core/res/AndroidManifest.xml", ], - args: metalava_framework_docs_args + " --show-annotation android.annotation.SystemApi ", + args: metalava_framework_docs_args + " --show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.PRIVILEGED_APPS,process=android.annotation.SystemApi.Process.ALL\\) ", write_sdk_values: true, } @@ -1483,7 +1483,7 @@ droidstubs { merge_annotations_dirs: [ "metalava-manual", ], - args: " --show-annotation android.annotation.SystemApi", + args: " --show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.PRIVILEGED_APPS,process=android.annotation.SystemApi.Process.ALL\\)", } java_library_static { @@ -1505,7 +1505,7 @@ droidstubs { removed_dex_api_filename: "removed-dex.txt", args: metalava_framework_docs_args + " --show-unannotated " + - " --show-annotation android.annotation.SystemApi " + + " --show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.PRIVILEGED_APPS,process=android.annotation.SystemApi.Process.ALL\\) " + " --show-annotation android.annotation.TestApi ", } @@ -1524,7 +1524,7 @@ droidstubs { " --hide ReferencesHidden " + " --hide UnhiddenSystemApi " + " --show-unannotated " + - " --show-annotation android.annotation.SystemApi " + + " --show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.PRIVILEGED_APPS,process=android.annotation.SystemApi.Process.ALL\\) " + " --show-annotation android.annotation.TestApi ", } @@ -1568,7 +1568,7 @@ droidstubs { arg_files: [ "core/res/AndroidManifest.xml", ], - args: metalava_framework_docs_args + " --show-annotation android.annotation.SystemApi", + args: metalava_framework_docs_args + " --show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.PRIVILEGED_APPS,process=android.annotation.SystemApi.Process.ALL\\)", check_api: { current: { api_file: "api/system-current.txt", diff --git a/core/java/android/annotation/SystemApi.java b/core/java/android/annotation/SystemApi.java index e96ff01d0850..f589cc5704b4 100644 --- a/core/java/android/annotation/SystemApi.java +++ b/core/java/android/annotation/SystemApi.java @@ -41,4 +41,29 @@ import java.lang.annotation.Target; @Target({TYPE, FIELD, METHOD, CONSTRUCTOR, ANNOTATION_TYPE, PACKAGE}) @Retention(RetentionPolicy.RUNTIME) public @interface SystemApi { + enum Client { + /** + * Specifies that the intended clients of a SystemApi are privileged apps. + * This is the default value for {@link #client}. + */ + PRIVILEGED_APPS, + } + + enum Process { + /** + * Specifies that the SystemAPI is available in every Java processes. + * This is the default value for {@link #process}. + */ + ALL, + } + + /** + * The intended client of this SystemAPI. + */ + Client client() default android.annotation.SystemApi.Client.PRIVILEGED_APPS; + + /** + * The process(es) that this SystemAPI is available + */ + Process process() default android.annotation.SystemApi.Process.ALL; } diff --git a/media/Android.bp b/media/Android.bp index 1912930f2081..e2bdad1f21b9 100644 --- a/media/Android.bp +++ b/media/Android.bp @@ -82,7 +82,7 @@ metalava_updatable_media_args = " --error UnhiddenSystemApi " + "--hide MissingPermission --hide BroadcastBehavior " + "--hide HiddenSuperclass --hide DeprecationMismatch --hide UnavailableSymbol " + "--hide SdkConstant --hide HiddenTypeParameter --hide Todo --hide Typo " + - "--hide HiddenTypedefConstant --show-annotation android.annotation.SystemApi " + "--hide HiddenTypedefConstant --show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.PRIVILEGED_APPS,process=android.annotation.SystemApi.Process.ALL\\) " droidstubs { name: "updatable-media-stubs", diff --git a/services/Android.bp b/services/Android.bp index fd4094f2a7c2..8376d2bcc0f5 100644 --- a/services/Android.bp +++ b/services/Android.bp @@ -111,7 +111,7 @@ droidstubs { srcs: [":services-sources"], installable: false, // TODO: remove the --hide options below - args: " --show-single-annotation android.annotation.SystemApi" + + args: " --show-single-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.INTERNAL,process=android.annotation.SystemApi.Process.SYSTEM_SERVER\\)" + " --hide-annotation android.annotation.Hide" + " --hide-package com.google.android.startop.iorap" + " --hide ReferencesHidden" + |