how long does it take for android to transition into doze mode? how long does it take for android to transition into doze mode? android android

how long does it take for android to transition into doze mode?


You should not concern yourself with when the device enters doze mode, rather with how does my app behave when the phone is in doze mode. To test this, you simply need to force your phone into doze and observe your app's behavior:

$ adb versionAndroid Debug Bridge version 1.0.32Revision eac51f2bb6a8-android$ adb shell dumpsys deviceidle | grep mState  mState=ACTIVE$ adb shell dumpsys deviceidle force-idleNow forced in to idle mode$ adb shell dumpsys deviceidle | grep mState  mState=IDLE

Even better, you should test your application under all the various pre-doze states:

$ adb shell dumpsys deviceidle stepStepped to: ACTIVE$ adb shell dumpsys battery unplug # emulate unplugging the charging cable$ for i in {1..5}; do adb shell dumpsys deviceidle step; doneStepped to: IDLE_PENDINGStepped to: SENSINGStepped to: LOCATINGStepped to: IDLEStepped to: IDLE_MAINTENANCE# repeats IDLE and IDLE_MAINTENANCE forever$ adb shell dumpsys battery reset$ adb shell dumpsys deviceidle stepStepped to: ACTIVE

You should test your app in all of the above states to ensure proper operation. See also the official documentation.


Now, if you insist on knowing the parameters of doze and maintenance, you should consult the full output of adb shell dumpsys deviceidle. When the device is IDLE, near the end of the output you will see:

mNextAlarmTime=+59m35s863ms

which derives from:

idle_to=+60m0s0ms

Also, unless the phone is woken up by the user, the next idle timeout is going to be larger, influenced by this parameter:

mNextIdleDelay=+2h0m0s0ms

etc. I am unaware of any official documentation about this, so take my interpretation with a grain of salt.