In our android app we ask for ignore battery optimization permission, and the user has an option to allow or deny the permission
On some Xiaomi android 11 devices , even when the user clicks allow permission , it brings back an error that the permission couldn't be set. But when the user manually searches for Battery Optimization setting and selects dont optimise , and retries granting it through our app , the permission for ignoring battery optimization is granted
We are not able to grant ignore battery optimization permission on Xiaomi devices programmatically when we follow the android standard by using ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS to white list our app
On other devices users are able to grant the permission through our app
I am not sure if there is any bug from MIUI on android 11 devices that doesn't allow apps to stop battery optimization
Can anyone suggest a workaround on how do we programmatically disable battery optimization on xiaomi devices running on android 11 ?