From 192ca30b7a8b8a1220db8bf9966e7d807f856f65 Mon Sep 17 00:00:00 2001 From: Artur Satayev Date: Wed, 22 Jan 2020 21:38:23 +0000 Subject: [PATCH] Remove unused UnsupportedAppUsage annotations. The new annotation is android.compat.annotation.UnsupportedAppUsage. Test: m Bug: 145132366 Exempt-From-Owner-Approval: previously approved change Change-Id: Ie12e28eee0ed20b5677ee3162143700813b7ab64 --- Android.bp | 3 - .../annotation/UnsupportedAppUsage.java | 170 ------------------ .../InputMethodManagerService.java | 2 +- .../com/android/codegen/ImportsProvider.kt | 2 +- 4 files changed, 2 insertions(+), 175 deletions(-) delete mode 100644 core/java/android/annotation/UnsupportedAppUsage.java diff --git a/Android.bp b/Android.bp index df276a053dfc8..ffb4d3a6ff730 100644 --- a/Android.bp +++ b/Android.bp @@ -583,7 +583,6 @@ java_library { host_supported: true, srcs: [ "core/java/android/annotation/IntDef.java", - "core/java/android/annotation/UnsupportedAppUsage.java", ], static_libs: [ "art.module.api.annotations", @@ -664,7 +663,6 @@ filegroup { "core/java/android/annotation/SystemApi.java", "core/java/android/annotation/SystemService.java", "core/java/android/annotation/TestApi.java", - "core/java/android/annotation/UnsupportedAppUsage.java", "core/java/com/android/internal/annotations/GuardedBy.java", "core/java/com/android/internal/annotations/VisibleForTesting.java", "core/java/com/android/internal/annotations/Immutable.java", @@ -1073,7 +1071,6 @@ java_library { "core/java/android/annotation/Nullable.java", "core/java/android/annotation/SystemApi.java", "core/java/android/annotation/TestApi.java", - "core/java/android/annotation/UnsupportedAppUsage.java", "core/java/android/os/HidlMemory.java", "core/java/android/os/HwBinder.java", "core/java/android/os/HwBlob.java", diff --git a/core/java/android/annotation/UnsupportedAppUsage.java b/core/java/android/annotation/UnsupportedAppUsage.java deleted file mode 100644 index 1af48cb63079b..0000000000000 --- a/core/java/android/annotation/UnsupportedAppUsage.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (C) 2018 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.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; - -/** - * Indicates that this non-SDK interface is used by apps. A non-SDK interface is a - * class member (field or method) that is not part of the public SDK. Since the - * member is not part of the SDK, usage by apps is not supported. - * - *

If you are an Android App developer

- * - * This annotation indicates that you may be able to access the member, but that - * this access is discouraged and not supported by Android. If there is a value - * for {@link #maxTargetSdk()} on the annotation, access will be restricted based - * on the {@code targetSdkVersion} value set in your manifest. - * - *

Fields and methods annotated with this are likely to be restricted, changed - * or removed in future Android releases. If you rely on these members for - * functionality that is not otherwise supported by Android, consider filing a - * feature request. - * - *

If you are an Android OS developer

- * - * This annotation acts as a heads up that changing a given method or field - * may affect apps, potentially breaking them when the next Android version is - * released. In some cases, for members that are heavily used, this annotation - * may imply restrictions on changes to the member. - * - *

This annotation also results in access to the member being permitted by the - * runtime, with a warning being generated in debug builds. Which apps can access - * the member is determined by the value of {@link #maxTargetSdk()}. - * - *

For more details, see go/UnsupportedAppUsage. - * - * {@hide} - */ -@Retention(CLASS) -@Target({CONSTRUCTOR, METHOD, FIELD, TYPE}) -@Repeatable(UnsupportedAppUsage.Container.class) -public @interface UnsupportedAppUsage { - - /** - * Associates a bug tracking the work to add a public alternative to this API. Optional. - * - * @return ID of the associated tracking bug - */ - long trackingBug() default 0; - - /** - * Indicates that usage of this API is limited to apps based on their target SDK version. - * - *

Access to the API is allowed if the targetSdkVersion in the apps manifest is no greater - * than this value. Access checks are performed at runtime. - * - *

This is used to give app developers a grace period to migrate off a non-SDK interface. - * When making Android version N, existing APIs can have a maxTargetSdk of N-1 added to them. - * Developers must then migrate off the API when their app is updated in future, but it will - * continue working in the meantime. - * - *

Possible values are: - *

- * - * @return The maximum value for an apps targetSdkVersion in order to access this API. - */ - int maxTargetSdk() default Integer.MAX_VALUE; - - /** - * For debug use only. The expected dex signature to be generated for this API, used to verify - * parts of the build process. - * - * @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 ""; - - /** - * Public API alternatives to this API. - * - *

If non-empty, the string must be a description of the public API alternative(s) to this - * API. The explanation must contain at least one Javadoc link tag to public API methods or - * fields. e.g.: - * {@literal @UnsupportedAppUsage(publicAlternatives="Use {@link foo.bar.Baz#bat()} instead.")} - * - *

Any elements that can be deduced can be omitted, e.g.: - *

- * @return A Javadoc-formatted string. - */ - @SuppressWarnings("JavadocReference") - String publicAlternatives() default ""; - - /** - * Override the default source position when generating an index of the annotations. - * - *

This is intended for use by tools that generate java source code, to point to the - * original source position of the annotation, rather than the position within the generated - * code. It should never be set manually. - * - *

The format of the value is "path/to/file:startline:startcol:endline:endcol" indicating - * the position of the annotation itself. - */ - String overrideSourcePosition() default ""; - - /** - * Container for {@link UnsupportedAppUsage} that allows it to be applied repeatedly to types. - */ - @Retention(CLASS) - @Target(TYPE) - @interface Container { - UnsupportedAppUsage[] value(); - } -} diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 905a94f572623..15698e9795ec6 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -3510,7 +3510,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } /** - * This is kept due to {@link android.annotation.UnsupportedAppUsage} in + * This is kept due to {@code @UnsupportedAppUsage} in * {@link InputMethodManager#getInputMethodWindowVisibleHeight()} and a dependency in * {@link InputMethodService#onCreate()}. * diff --git a/tools/codegen/src/com/android/codegen/ImportsProvider.kt b/tools/codegen/src/com/android/codegen/ImportsProvider.kt index ba0a0318c8439..c830aaa0df3da 100644 --- a/tools/codegen/src/com/android/codegen/ImportsProvider.kt +++ b/tools/codegen/src/com/android/codegen/ImportsProvider.kt @@ -46,7 +46,7 @@ interface ImportsProvider { val Parcelling: String get() { return classRef("com.android.internal.util.Parcelling") } val Parcelable: String get() { return classRef("android.os.Parcelable") } val Parcel: String get() { return classRef("android.os.Parcel") } - val UnsupportedAppUsage: String get() { return classRef("android.annotation.UnsupportedAppUsage") } + val UnsupportedAppUsage: String get() { return classRef("android.compat.annotation.UnsupportedAppUsage") } /** * Optionally shortens a class reference if there's a corresponding import present