Simple Android DOZE MODE testing

Mateusz Wołkowicz
2 min readJan 12, 2019

--

Starting from Android Marshmallow (Android 6.0; API level 23) all Android devices takes care of battery optimization by default and force system to use as small connectivity, resources and CPU as possible to achieve it.

There are two power-saving features which reduce battery consumption and one of it is DOZE MODE.

What is DOZE MODE in details you can find here: https://developer.android.com/training/monitoring-device-state/doze-standby

If you are reading this article you probably know what it is and you are only looking for some simple answers for a few questions :

  1. “How to test DOZE MODE ?
  2. “How to set DOZE MODE on a testing device ? … to find out how your new killer (fancy app feature) will act in that state”

So the simples solution is to connect your real device via USB and test your app with it using a debugger.

When your app is running you are able to temporary change device settings straight from the command line using ADB (Android Debug Bridge).

In the command line type :

adb shell dumpsys battery unplug

which will force the device to temporarily act as unplugged (not charging, not connected via USB) even if it really is (and it is because you connect it via USB to your computer).

Next type :

adb shell dumpsys deviceidle force-idle

which will force the device to go to DOZE MODE.

And that’s it. Now your device is in DOZE MODE and you are able to test it in this state.

To check if your device is really in DOZE MODE via ADB, type :

adb shell dumpsys deviceidle

On the printed list with settings find mState.

If mState=ACTIVE it means your device is ACTIVE and NOT in DOZE MODE.

If mState=IDLE it means DOZE MODE is ON.

There are a few more helpful commands and tricks which you can find here.

--

--