How to force Doze on Marshmallow?


Everything seems to point to these two commands:

adb shell dumpsys battery unplug
adb shell dumpsys deviceidle step

I followed the instructions on my Nexus 6 running the Marshmallow official release. I plug in my phone to my test machine. I set up my app for testing the piece I want to test with doze. I turn off my screen. After running battery unplug above I get no output so I assume it works, but every time I run deviceidle step the output is always Stepped to: ACTIVE.

I'm not sure if it matters, but the particular feature of my app I'm trying to test is an alarm I'm setting that should wake the phone out of Doze. I'm wanting my device to be mid-doze when my PendingIntent scheduled by AlarmManager.setAlarmClock goes off. Could that prevent my device from entering Doze?

use below commands to force idle you device.

To unplug battery

adb shell dumpsys battery unplug

You can use below commands to Force Idle state

adb shell dumpsys deviceidle force-idle
adb shell dumpsys deviceidle enable

Check you are in doze more or not with below command

adb shell dumpsys deviceidle enabled

disable mode:

adb shell dumpsys deviceidle disable

Reset device battery status:

adb shell dumpsys battery reset