androiddevice-admindevice-owner

How to remove Battery Optimization restrictions for Device Owner app


Battery optimization settings creates some difficulties for the device owner app I am currently developing, such as not receiving BOOT_COMPLETED broadcast in MIUI. I want to know if there is any way of removing restrictions of device owner app programmatically, like granting permissions to the device owner app itself. I could not find about this anywhere or alternative solution to the similar problems, such as keeping background services alive and auto starting services on boot.


Solution

  • I didn't find a way to whitelist an app from doze mode silently and programatically. The only option is to ask user of the app to do it for you.

    The intent action that takes the user to Battery Optimization settings to do this is described here: https://developer.android.com/training/monitoring-device-state/doze-standby#support_for_other_use_cases

    I have seen other MDMs using this approach too.