Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does @UnsupportedAppUsage annotation depict

Tags:

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

like image 281
Manishika Avatar asked Sep 25 '18 13:09

Manishika


People also ask

What is unsupported app usage?

* * <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.

How do I use annotations on Android support?

To enable annotations in your project, add the support-annotations dependency to your library or app. Any annotations you add then get checked when you run a code inspection or lint task.


1 Answers

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.

like image 94
TheWanderer Avatar answered Sep 21 '22 19:09

TheWanderer