REQUEST_IGNORE_BATTERY_OPTIMIZATIONS not a dangerous permission. You do not need or do not need any of this code. Quoting documentation for REQUEST_IGNORE_BATTERY_OPTIMIZATIONS :
Application permission must be completed to use ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS. This is a normal permission: the application requesting it will always receive permission, without the need for approval or viewing.
So delete all this code.
I do not see my application in the white list.
This is because the user has not added you to the white list, apparently.
The REQUEST_IGNORE_BATTERY_OPTIMIZATIONS query gives you security authority to start with a ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS Intent . Be sure to include the application package as Uri :
startActivity(new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, Uri.parse("package:"+getPackageName())));
The user will be displayed on a screen where they can indicate that they are ready to pause parts of the effects of Doze mode in your application.
How to add an application to the white list without a ban?
If you do not want to be banned, do not do this. Do something in your application that starts the action with a ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS Intent . This leads the user to a general list of applications where the user can switch which of them are not included in the white list. This does not require permission.
The act of requesting REQUEST_IGNORE_BATTERY_OPTIMIZATIONS in the manifest is something that might ban you .
source share