Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

In android version 6.0+ assuming user has left the android somewhere, unplugged, power button pressed to lock it etc..

How much time does android spend in each state such as inactive, idle pending etc before it finally gets into idle ?

Now once in idle mode how long does it take to get into idle_maintenance mode and for how long does it stay there in idle_maintenance mode ?

Are these values constant or configurable or dependent on android version/manufacturer..

Please advise this is important for me to make important decisions about how to adjust my app for android ver 6.0/api 23+

like image 546
Ahmed Avatar asked Apr 07 '16 17:04

Ahmed


People also ask

How do I know if my device is in doze mode?

Testing your app with DozeConfigure a hardware device or virtual device with an Android 6.0 (API level 23) or higher system image. Connect the device to your development machine and install your app. Run your app and leave it active. Observe the behavior of your app after you reactivate the device.

How does doze work?

In order to make the battery life of your phone more efficient and increase the screen on time duration, Doze mode tunes down the background processing ability of your Android device by automatically recognizing that the phone isn't being used for a long duration.


1 Answers

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 version
Android Debug Bridge version 1.0.32
Revision eac51f2bb6a8-android
$ adb shell dumpsys deviceidle | grep mState
  mState=ACTIVE
$ adb shell dumpsys deviceidle force-idle
Now 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 step
Stepped to: ACTIVE
$ adb shell dumpsys battery unplug # emulate unplugging the charging cable
$ for i in {1..5}; do adb shell dumpsys deviceidle step; done
Stepped to: IDLE_PENDING
Stepped to: SENSING
Stepped to: LOCATING
Stepped to: IDLE
Stepped to: IDLE_MAINTENANCE
# repeats IDLE and IDLE_MAINTENANCE forever
$ adb shell dumpsys battery reset
$ adb shell dumpsys deviceidle step
Stepped 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.

like image 86
Irfy Avatar answered Sep 22 '22 16:09

Irfy