31

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

Manishika
  • 5,478
  • 2
  • 22
  • 28

2 Answers2

28

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.

TheWanderer
  • 16,775
  • 6
  • 49
  • 63
4

The above annotation source description is correct. I am getting an exception in my code for Pie now where it wasn't before. I'm setting cursor handler color by some fields in TextView.class which are now unsupported and causing an exception to occur where I cannot set the handle color in Pie. This is not just a warning.

Thomas
  • 320
  • 2
  • 6
  • 2
    This flag is just a warning. You're hitting an error because of the hidden API blacklist introduced in Pie, and further restricted in Q. I wrote up a few ways to bypass this restriction here: https://stackoverflow.com/questions/55970137/bypass-androids-hidden-api-restrictions – TheWanderer Jul 17 '19 at 11:47