Background
For a wallpaper app, I'm trying to get the max/original/natural resolution of the display to prepare/prioritize images based on it. This can also be useful for apps that just show information about the device.
By "max/original/natural resolution", I mean the one that it published by the manufacturer, the max resolution that the device can reach.
The problem
There are plenty of solutions and questions about how to get the resolution on Android:
Get screen width and height in Android
I even wrote there the best one I've found that also checks the natural orientation in order to give the width&height in the correct order:
https://stackoverflow.com/a/47684256/878126
Thing is, sadly, all of the solutions either return the current resolution, or what's available for the app/window. Not what I'm searching for. Also this API is considered deprecated.
This is an issue because there are some devices that allow the user to change resolution of the display.
An example of such a device is "Honor magic4 pro".
What I've found/tried
Google gave me (here) a clue of how to do it, but it doesn't seem to work (still not the real resolution):
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val currentWindowMetrics =
createWindowContext(TYPE_WALLPAPER, null).getSystemService(WindowManager::class.java).currentWindowMetrics
val bounds = currentWindowMetrics.bounds
Log.d("AppLog", "currentWindowMetrics:${bounds.width()}x${bounds.height()}")
}
Most apps also fail to provide the this resolution. However, I've noticed there are at least 2 apps that somehow show the max resolution:
https://play.google.com/store/apps/details?id=ru.andr7e.deviceinfohw
https://play.google.com/store/apps/details?id=com.drhowdydoo.displayinfo
They mention there "modes", and so I tried this:
windowManager.defaultDisplay.supportedModes.forEach {
Log.d("AppLog", "${it.physicalWidth} ${it.physicalHeight}")
}
Still doesn't include the real resolution. In fact it doesn't even show all modes as the apps I've mentioned.
Another approach I've tried (based on here) is to get the system properties (code for doing this here) of either "ubootenv.var.outputmode" or "display-output-mode". Both didn't provide anything at all.
The question
How do you get the max/original/natural resolution?
How do the apps I've mentioned do it? Is it a part of the framework? Or some workaround?