@UnsupportedAppUsage注释描述了什么

时间:2018-09-25 13:45:48

标签: android annotations android-source

我正在构建具有系统许可权的企业应用程序,它需要使用BluetoothAdapter类setScanMode中的功能。这是一个隐藏的API,仅适用于系统签名的apk,现在此函数上方有@UnsupportedAppUsage,任何人都可以帮助我理解此注释。

https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/bluetooth/BluetoothAdapter.java

2 个答案:

答案 0 :(得分:2)

如果我们转到annotation source

/**
 * Indicates that a class member, that is not part of the SDK, is used by apps.
 * Since the member is not part of the SDK, such use is not supported.
 *
 * <p>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.
 *
 * <p>This annotation also results in access to the member being permitted by the
 * runtime, with a warning being generated in debug builds.
 *
 * <p>For more details, see go/UnsupportedAppUsage.
 *
 * {@hide}
 */

基本上,这意味着它正在被应用程序使用,即使它在技术上不是SDK的一部分,因此也不被支持。对于对AOSP做出贡献的任何人来说,这似乎都是警告,而不是您需要担心太多的事情。

答案 1 :(得分:2)

以上注释源描述正确。我现在在Pie的代码中遇到了以前没有的异常。我正在通过TextView.class中的某些字段设置光标处理程序颜色,这些字段现在不受支持,并导致发生异常,导致无法在Pie中设置句柄颜色。 这不仅仅是警告。