check whether android device in maintenance window

246 views Asked by At

I want to check whether device is in a maintenance window of doze mode.

so I used :

//on receive alarm broadcast
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
boolean isDeviceIdleMode = pm.isDeviceIdleMode();
//do work

but realized that it returned false always.

After referring to documentation, I found that,

it will return false if the device is in a long-term idle mode but currently running a maintenance window where restrictions have been lifted.

Is there a method like isDeviceInMaintenanceWindow or how can I programmatically detect it?

0

There are 0 answers