A new metric to measure performance
For a long time now, Android has offered its developers a compatibility-library, the “Support library”. Since Android version 9, this library is deprecated and has been replaced by a new version called “AndroidX”. To keep it short, this compatibility layer provides developers a relatively easy way to gracefully handle a new API on older Android devices that may not support it.
Android Performance class is different than AndroidX. Instead of directly providing a fallback for those deprecations, its goal is to give you as a developer insight into what the current device’s hardware is capable of. This also gives hint at another major difference: Android performance classes are available at runtime instead of build time, like AndroidX is.
To be more specific, as of writing Android offers three performance classes: Media, Camera and Generic. These classes will be fully available starting with Android 12, as they were introduced with this version. For Android 11, a subset of these classes will be available.
// Example taken directly from
// Android's explanation, just
// to give a quick overview.
if (Build.VERSION.MEDIA_PERFORMANCE_CLASS >= Build.VERSION_CODES.S) {
// Provide the most premium experience for highest performing devices
...
}
else if (Build.VERSION.MEDIA_PERFORMANCE_CLASS == Build.VERSION_CODES.R)
// Provide a high quality experience
...
}
else {
// Remove extras to keep experience functional
...
}
A new way to group devices
Performance classes allow you to group consumers in a new way. Instead of just relying on the Android version, or far worse, checking for specific device vendor identities to match against a custom set of rules, these new performance classes can be used to group consumers directly (and reliably) by capabilities.
What exactly is supported by each version can be seen in the “Android Compatibility Definition Document”. A new tool called “Compatibility Test Suite”, also developed by the Android team, verifies the proposed compatibilities for a device. But don’t worry, these things only concern hardware manufacturers and their engineers. What’s important to you as an app developer is to use the new API in your application code.
A forward-compatible strategy
Lastly, it’s important to note how this new performance class will be used in future Android versions. For example, a device with Android 12 also supports the media performance class version 12. Now when Android 13 gets released, this device can still upgrade to Android 13, but will keep its performance class version 12. It might have already been obvious to you, but I nevertheless wanted to highlight this behavior. Performance class versions don’t block manufacturers from updating to the latest Android version.