Search code examples
androidannotationsandroid-source

What does @UnsupportedAppUsage annotation depict


I am building an Enterprise app which has system permission and it requires to use a function from BluetoothAdapter class setScanMode. This is a hidden API which is only available for system signed apks, now this function has @UnsupportedAppUsage above it, can anyone help me understand this annotation.

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


Solution

  • If we go to the 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}
     */
    

    Basically, it means it's being used by apps, even though it's not technically part of the SDK, and thus isn't supported. It seems to be more of a warning for anyone contributing to AOSP rather than something you need to worry about too much.