Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@y-polek
Last active April 20, 2024 09:36
Show Gist options
  • Star 60 You must be signed in to star a gist
  • Fork 23 You must be signed in to fork a gist
  • Save y-polek/febff143df8dd92f4ed2ce4035c99248 to your computer and use it in GitHub Desktop.
Save y-polek/febff143df8dd92f4ed2ce4035c99248 to your computer and use it in GitHub Desktop.
adb commands to test Doze mode
#! /bin/zsh
# Buttery powered state
adb shell dumpsys battery | grep powered
# Unplug battery
adb shell dumpsys battery unplug
# Reset battery
adb shell dumpsys battery reset
# Dump Doze mode info
adb shell dumpsys deviceidle
# Enable Doze mode (may be required on Android Emulator)
adb shell dumpsys deviceidle enable
# Get status of Light Doze mode
adb shell dumpsys deviceidle get light
# Get status of Deep Doze mode
adb shell dumpsys deviceidle get deep
# Enter Light Doze mode (should be called several times to pass all phases)
adb shell dumpsys deviceidle step light
# Enter Deep Doze mode (should be called several times to pass all phases)
adb shell dumpsys deviceidle step deep
@chaoscreater
Copy link

chaoscreater commented Oct 4, 2022

I have found the following information about step commands:

Each of the doze modes will have multiple states.
Light: ACTIVE -> IDLE -> IDLE_MAINTENANCE -> OVERRIDE
Deep: ACTIVE -> IDLE_PENDING -> SENSING -> LOCATING -> IDLE -> IDLE_MAINTENANCE

Regarding the force idle issues - in my case, that was exactly what I expected. I wanted to see what happens with my app when the phone goes to sleep, and it is expected that it will kill some background tasks and interrupt the network. That's very much expected on real devices, so your app should deal with such situations properly. The behavior differs among devices from different manufacturers. dontkillmyapp.com this is a very insightful site that tells more about the problems your apps can expect from deep idle states.

Thanks for the info. Yep I know about dontkillmyapp and don't really have any issues with the apps on my phone, they're all whitelisted and run fine. I'm just trying to force my phone to go into doze mode properly. I know there are apps like ForceDoze and NapTime and some other ones, but I don't the doze profiles that they use and prefer to use my own. I also wanted to use a single app to automate everything (hence using Tasker and MacroDroid) and so the last thing I needed was to force doze mode using either step deep or force idle, but obviously wasn't sure what the difference was between them, until now.

Just to confirm, you mentioned that using step deep that it "does not cause any real deep sleep side effects". So does that mean your phone was in deep sleep and yet it wasn't having any issues? E.g. apps that are whitelisted can still generate notifications, etc?

@progmars
Copy link

progmars commented Oct 4, 2022

I think at that time I did not call step deep enough times. force idle felt more convenient because it worked immediately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment