8

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?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Corey Ogburn
  • 24,072
  • 31
  • 113
  • 188
  • `setAlarmClock()` reportedly blocks Doze mode for a window of time before the event goes off. – CommonsWare Oct 30 '15 at 15:24
  • I've seen that alarms set using `setAlarmClock()` are unaffected by Doze, but I haven't read anything about this "pre-awaking" window before the alarm goes off. Is there a link about those specifics? – Corey Ogburn Oct 30 '15 at 15:29
  • 1
    http://stackoverflow.com/a/33187763/115145 http://stackoverflow.com/questions/33110246/setexactandallowwhileidle-is-not-exact-as-of-developer-reference#comment54216992_33110418 – CommonsWare Oct 30 '15 at 15:31
  • A whole hour. Wow. As much as I believe that (no sarcasm intended, truthfully that seems to agree with my tests), it would be nice if Google had some documentation that says that. – Corey Ogburn Oct 30 '15 at 15:39
  • Please check [this answer](http://stackoverflow.com/a/35914341/2826147). – Amit Vaghela Mar 10 '16 at 10:53

2 Answers2

19

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
or
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
prGD
  • 1,501
  • 2
  • 12
  • 22
0

The Greenify app has an experimental feature to instantly turn on Doze mode when the screen turns off. You might need root for this however. Greenify runs in root AND non-root modes. Hope this helps. Good luck!

  • I'm testing the doze mode with the ADB commands, now I accidentaly trigger this feature you've mentioned: *instantly turn on Doze mode when the screen turns off*. I want to remove this, how can I do it? – sebasira Mar 12 '21 at 04:32