I am trying to force my device (Redmi S2) running MIUI into deep doze using ADB commands but it doesn't seem to work.
After running
adb shell dumpsys battery unplug
I can go into light doze by using:
adb shell dumpsys deviceidle step light
Stepped to light: IDLE
adb shell dumpsys deviceidle force-idle light
Now forced in to light idle mode
But if I try to enter deep doze, it doesn't work:
adb shell dumpsys deviceidle step deep
Stepped to deep: INACTIVE
adb shell dumpsys deviceidle force-idle deep
Unable to go deep idle; stopped at INACTIVE
Using only
adb shell dumpsys deviceidle step
returns the same output
Stepped to deep: INACTIVE
Any suggestions how to overcome this?
Related
When I turn on doze mode on an android emulator using adb shell it just freeze. I cannot reboot it and emulator restarting doesn't help.
I use the following commands for turn doze mode on:
adb shell dumpsys battery unplug
adb shell dumpsys deviceidle step deep
And the following to turn it off:
adb shell input keyevent KEYCODE_WAKEUP
adb shell dumpsys battery reset
I have a Nexus 5 that won't go into Doze/IDLE mode using ADB commands from Windows. It's adb connected using USB cable and it is working for all other ADB commands. The screen is off.
C:\>adb shell dumpsys deviceidle force-idle
Unable to go idle; stopped at ACTIVE
C:\>adb shell dumpsys deviceidle enable
C:\>adb shell dumpsys battery unplug
C:\>adb shell dumpsys deviceidle step
Stepped to: ACTIVE
C:\>adb shell dumpsys deviceidle step
Stepped to: ACTIVE
C:\>adb shell dumpsys deviceidle step
Stepped to: ACTIVE
C:\>adb shell dumpsys deviceidle enable
C:\>adb shell dumpsys deviceidle force-idle
Unable to go idle; stopped at ACTIVE
First you need run this command:
> adb shell dumpsys battery unplug
Then turn off the screen (this step is crucial), otherwise the device remains in ACTIVE state.
After that run this command until the device state changes to IDLE:
> adb shell dumpsys deviceidle step
Stepped to: IDLE_PENDING
> adb shell dumpsys deviceidle step
Stepped to: SENSING
> adb shell dumpsys deviceidle step
Stepped to: LOCATING
> adb shell dumpsys deviceidle step
Stepped to: IDLE
There may be a condition which prevents the phone from going into IDLE, such as a scheduled alarm clock. Make sure there are no alarm clock apps set to go off in less than an hour of you trying to force the phone into IDLE.
In android version 6.0+
assuming user has left the android somewhere, unplugged, power button pressed to lock it etc..
How much time does android spend in each state such as inactive, idle pending etc before it finally gets into idle ?
Now once in idle mode how long does it take to get into idle_maintenance mode and for how long does it stay there in idle_maintenance mode ?
Are these values constant or configurable or dependent on android version/manufacturer..
Please advise this is important for me to make important decisions about how to adjust my app for android ver 6.0/api 23+
You should not concern yourself with when the device enters doze mode, rather with how does my app behave when the phone is in doze mode. To test this, you simply need to force your phone into doze and observe your app's behavior:
$ adb version
Android Debug Bridge version 1.0.32
Revision eac51f2bb6a8-android
$ adb shell dumpsys deviceidle | grep mState
mState=ACTIVE
$ adb shell dumpsys deviceidle force-idle
Now forced in to idle mode
$ adb shell dumpsys deviceidle | grep mState
mState=IDLE
Even better, you should test your application under all the various pre-doze states:
$ adb shell dumpsys deviceidle step
Stepped to: ACTIVE
$ adb shell dumpsys battery unplug # emulate unplugging the charging cable
$ for i in {1..5}; do adb shell dumpsys deviceidle step; done
Stepped to: IDLE_PENDING
Stepped to: SENSING
Stepped to: LOCATING
Stepped to: IDLE
Stepped to: IDLE_MAINTENANCE
# repeats IDLE and IDLE_MAINTENANCE forever
$ adb shell dumpsys battery reset
$ adb shell dumpsys deviceidle step
Stepped to: ACTIVE
You should test your app in all of the above states to ensure proper operation. See also the official documentation.
Now, if you insist on knowing the parameters of doze and maintenance, you should consult the full output of adb shell dumpsys deviceidle. When the device is IDLE, near the end of the output you will see:
mNextAlarmTime=+59m35s863ms
which derives from:
idle_to=+60m0s0ms
Also, unless the phone is woken up by the user, the next idle timeout is going to be larger, influenced by this parameter:
mNextIdleDelay=+2h0m0s0ms
etc. I am unaware of any official documentation about this, so take my interpretation with a grain of salt.
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
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
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 followed steps described here:
https://developer.android.com/preview/testing/guide.html#doze-standby
Circumstances:
Android Debug Bridge version 1.0.32
Nexus 9 with Preview M
Shell:
$ adb shell dumpsys battery unplug
=> worked, device unplugged
$ adb shell dumpsys deviceidle step
=> Output: Stepped to: ACTIVE
$ adb shell dumpsys deviceidle -h
=> does not work => Output:
Device idle controller (deviceidle) dump options:
[-h] [CMD]
-h: print this help text.
Commands:
step
disable
enable
whitelist
I tried it with:
adb shell dumpsys deviceidle enable
But it didn't work.
So my question, as mentioned above, how to shift the device in Doze-Mode?
What did i make wrong?
EDIT - JUNE, 2016:
New Link:
https://developer.android.com/training/monitoring-device-state/doze-standby.html
There is a better way to achieve this in the new releases:
$ adb shell dumpsys deviceidle force-idle
No need to unplug from power, no need to wait for the screen to turn off.
Ok, i got it. The trick was to turn the screen off! After that
$ adb shell dumpsys deviceidle step
outputs:
IDLE_PENDING
then
SENSING
then
IDLE
then
IDLE_MAINTENANCE
then
IDLE
then
IDLE_MAINTENANCE
and so on...
Many thanks to this site:
https://newcircle.com/s/post/1739/2015/06/12/diving-into-android-m-doze
Yes, it appears that Google's developer testing guideline is incorrect. I just recently discovered this as well and posted a bug about it here with the correct steps to get the device to idle (aka doze).
$ adb shell dumpsys deviceidle -h
This command only outputs a help message like common unix program.
IDLE means Doze mode.
In the article you linked, you can regard Doze mode as device idle mode.
You can find my full answer posted on the similar topic here:
How to test Doze Mode on Android?
Idle State - In order to put the device into an Idle state you can use the following adb commands:
>adb shell dumpsys battery unplug
>adb shell dumpsys deviceidle force-idle
Active State - In order to put the device back into the Active state you may simulate the following key event:
> adb shell input keyevent KEYCODE_WAKEUP
I also needed a quick option to toggle between Active and Idle states so I wrote a batch script adbIdleModeSwitch.bat for these purposes, you may download and use it: https://drive.google.com/file/d/0B81qFnPX_eUUYTMxOTd1UG94NVk/view