Exit android doze mode

3k views Asked by At

I am playing around with the Android doze mode in my app and just wants to examine my apps behavior in doze mode.

My application enqueues some tasks in a job scheduler while in doze mode. I want to check if any event, that wakes up the device, triggers the jobs that my app had put in the job scheduler while in doze.

I programmatically put the device in doze mode by firing the below commands-

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

I also tried the other set of commands to put it in the doze mode

adb shell dumpsys deviceidle step deep

The above commands put the device in deep idle mode and I check for it with the command-

adb shell dumpsys deviceidle get deep

output: IDLE

But even if I give a phone call, which turns the device screen on and vibrates the device, the device status doesn't change. The above command continuous to give me IDLE status.

Question:

Can I emulate the scenario where I put the device in doze(by firing some commands) and then the device would move out of doze by some events that are stated by the android doc (moving it, turning on the screen, or connecting a charger).

EDIT

My observations after doing a lot of research-

When we program a device to go in the deep idle mode, the device doesn't come out of doze mode unless explicitly done using the command-

adb shell dumpsys deviceidle disable

So, even if you a send a text message or call the device which would cause
- the device screen to turn on
- the device to vibrate

but because if is programmatically set to idle mode, it continuous to remain in the same state.

1

There are 1 answers

3
Socram On

I believe the problem is that you are using force-idle.

When you do that the device enters IDLE mode until you "unforce" it with:

adb shell dumpsys deviceidle unforce

You can check for alternative ways of entering IDLE mode from adb in the docs or in other question, like here:

How to shift device in Doze Mode (Android Preview M / Marshmallow)?