Improve idle drain by tweaking Android Doze parameters

Search This thread

Doomkopf

Senior Member
May 14, 2016
273
111
Hey xda-Community!

I recently wanted to reduce my idle drain and searched for ways to edit Android Doze settings, because I remembered seeing a tutorial that said you can change deviceidle-constants, that dictate how Doze works (how fast it kicks in, how long it kicks in, light/deep doze).
I tried all those old tutorials, but I quickly realized the old ways to change the parameters are deprecated, so I asked people on android.stackexchange.com and someone actually gave me the answer (thanks Andrew) (https://android.stackexchange.com/questions/247680/is-device-idle-constants-deprecated-in-android-12).
This works from Android 12 on and is achieved using a shell.

Commands:
Note: When using an adb shell, you have to put "adb shell" before those commands. I'll just put the bare commands here, you add what you have to add.

Checking the settings:
You can check your current Doze settings (and statistics) with "dumpsys deviceidle".

Changing a setting;
Every parameter has to be set individually. It's not that bad tho, as you only have to do this once.

Syntax is: "device_config put device_idle [KEY] [VALUE]".
One example: "device_config put device_idle light_after_inactive_to 30000"

You can check "dumpsys deviceidle" to see what keys there even are. To help you out, here's an explanation of what each key actually sets. You can also get a visual sense of how the light mode and the deep mode work (not my work, thanks to easz from github).


First; reset parameters with: "device_config reset trusted_defaults device_idle"

light_after_inactive_to 30000
light_pre_idle_to 120000
light_idle_to 300000
light_idle_factor 2
light_max_idle_to 900000
light_idle_maintenance_min_budget 30000
light_idle_maintenance_max_budget 180000
inactive_to 900000
sensing_to 0
locating_to 0
motion_inactive_to 0
idle_after_inactive_to 900000
idle_pending_to 60000
max_idle_pending_to 120000
idle_pending_factor 2
idle_to 900000
max_idle_to 21600000
idle_factor 2
wait_for_unlock true

I also wrote a windows batch script (works via adb, you have to rename the .txt file to .bat) and a bash file that changes the parameters to my recommendations. See attachments.
 

Attachments

  • deviceidle.sh
    1.1 KB · Views: 21
  • deviceidle.txt
    1.2 KB · Views: 42
Last edited:

Doomkopf

Senior Member
May 14, 2016
273
111
@Doomkopf for me those settings won't stick.

For testing purpose I just applied those yesterday morning:
adb shell device_config put device_idle motion_inactive_to 300000
adb shell device_config put device_idle light_after_inactive_to 180000

This morning they are back to stock values. Any ideas? :S
I set mine like 6 weeks ago, it's still set. I miss many information, what phone do you use, what ROM, how you check if it's still set etc :D
 
I set mine like 6 weeks ago, it's still set. I miss many information, what phone do you use, what ROM, how you check if it's still set etc :D

Hi, oh well here are some more infos:

Pixel 6 Pro
Latest Android 13 Stock ROM
Kirisakura Kernel

I check via "adb shell dumpsys deviceidle".
I set it all your settings on friday and today (monday) there are back to stock values.
Previously I tried settings my own settings on wednesday morning and had stock values on the next day already as well :S
 
  • Like
Reactions: Doomkopf

Doomkopf

Senior Member
May 14, 2016
273
111
Hi, oh well here are some more infos:

Pixel 6 Pro
Latest Android 13 Stock ROM
Kirisakura Kernel

I check via "adb shell dumpsys deviceidle".
I set it all your settings on friday and today (monday) there are back to stock values.
Previously I tried settings my own settings on wednesday morning and had stock values on the next day already as well :S
That doesn't sound good :( I'd check right after setting it, so you can see if it was changed at all (which I assume). If it indeed gets set and unset again, you could check this github repo (https://github.com/easz/doze-tweak) at "Caveat".
Those values got reset in the past already, but as it didn't happen to me, I thought Google stopped doing that. Maybe that old workaround still works :) Otherwise, you'll have to flash a custom rom I guess xD

EDIT: I also recommend looking at values easy to distinguish. For example, "sensing_to" and "locating_to" were nonzero before, now they are zero (for me), so these values are easy to compare for me. The values you need to look at are at the most upper part of the output, but I guess you already knew that :D
 

crok.bic

Senior Member
Dec 22, 2010
472
289
Debrecen
That doesn't sound good :(

Did you ever mess with any other settings using device_config before? Like the number phantom processes, empty or cached processes, ActivityManager tweaks or anything else? Because I assume you did (and using Android 10 or higher) and disabled the settings sync back to the defauls.
Did you ever use the below command?
device_config set_sync_disabled_for_tests persistent
What does the below commands says?
device_config is_sync_disabled_for_tests
Perhaps it says true? If yes that's why your settings aren't changing.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    I set mine like 6 weeks ago, it's still set. I miss many information, what phone do you use, what ROM, how you check if it's still set etc :D

    Hi, oh well here are some more infos:

    Pixel 6 Pro
    Latest Android 13 Stock ROM
    Kirisakura Kernel

    I check via "adb shell dumpsys deviceidle".
    I set it all your settings on friday and today (monday) there are back to stock values.
    Previously I tried settings my own settings on wednesday morning and had stock values on the next day already as well :S
  • 3
    Hey xda-Community!

    I recently wanted to reduce my idle drain and searched for ways to edit Android Doze settings, because I remembered seeing a tutorial that said you can change deviceidle-constants, that dictate how Doze works (how fast it kicks in, how long it kicks in, light/deep doze).
    I tried all those old tutorials, but I quickly realized the old ways to change the parameters are deprecated, so I asked people on android.stackexchange.com and someone actually gave me the answer (thanks Andrew) (https://android.stackexchange.com/questions/247680/is-device-idle-constants-deprecated-in-android-12).
    This works from Android 12 on and is achieved using a shell.

    Commands:
    Note: When using an adb shell, you have to put "adb shell" before those commands. I'll just put the bare commands here, you add what you have to add.

    Checking the settings:
    You can check your current Doze settings (and statistics) with "dumpsys deviceidle".

    Changing a setting;
    Every parameter has to be set individually. It's not that bad tho, as you only have to do this once.

    Syntax is: "device_config put device_idle [KEY] [VALUE]".
    One example: "device_config put device_idle light_after_inactive_to 30000"

    You can check "dumpsys deviceidle" to see what keys there even are. To help you out, here's an explanation of what each key actually sets. You can also get a visual sense of how the light mode and the deep mode work (not my work, thanks to easz from github).


    First; reset parameters with: "device_config reset trusted_defaults device_idle"

    light_after_inactive_to 30000
    light_pre_idle_to 120000
    light_idle_to 300000
    light_idle_factor 2
    light_max_idle_to 900000
    light_idle_maintenance_min_budget 30000
    light_idle_maintenance_max_budget 180000
    inactive_to 900000
    sensing_to 0
    locating_to 0
    motion_inactive_to 0
    idle_after_inactive_to 900000
    idle_pending_to 60000
    max_idle_pending_to 120000
    idle_pending_factor 2
    idle_to 900000
    max_idle_to 21600000
    idle_factor 2
    wait_for_unlock true

    I also wrote a windows batch script (works via adb, you have to rename the .txt file to .bat) and a bash file that changes the parameters to my recommendations. See attachments.
    1
    will these settings persists even after a reboot? or upgrading rom?
    1
    will these settings persists even after a reboot? or upgrading rom?
    yes, these will stick after a reboot. Not sure about upgrading, but I would guess that it'll stay, because we don't actually modify anything on the system partition
    1
    I set mine like 6 weeks ago, it's still set. I miss many information, what phone do you use, what ROM, how you check if it's still set etc :D

    Hi, oh well here are some more infos:

    Pixel 6 Pro
    Latest Android 13 Stock ROM
    Kirisakura Kernel

    I check via "adb shell dumpsys deviceidle".
    I set it all your settings on friday and today (monday) there are back to stock values.
    Previously I tried settings my own settings on wednesday morning and had stock values on the next day already as well :S