【问题标题】:What does @UnsupportedAppUsage annotation depict@UnsupportedAppUsage 注释描述了什么
【发布时间】:2019-03-01 04:05:53
【问题描述】:

我正在构建一个具有系统权限的企业应用程序,它需要使用来自 BluetoothAdapter 类 setScanMode 的函数。这是一个隐藏的API,仅适用于系统签名的apk,现在这个函数上面有@UnsupportedAppUsage,谁能帮我理解这个注释。

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

【问题讨论】:

    标签: android annotations android-source


    【解决方案1】:

    如果我们去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 做出贡献的人来说,这似乎更像是一个警告,而不是您需要过多担心的事情。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • 这个标志只是一个警告。由于 Pie 中引入了隐藏的 API 黑名单,并且在 Q 中进一步受到限制,您遇到了错误。我在这里写了一些绕过此限制的方法:stackoverflow.com/questions/55970137/…
      猜你喜欢
      • 2010-11-22
      • 1970-01-01
      • 2015-04-30
      • 2011-08-24
      • 2014-12-15
      • 2022-12-30
      • 2013-07-15
      • 2021-08-12
      • 1970-01-01
      相关资源
      最近更新 更多