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
Related
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?
I have some old shell scripts that needs to be executed on an android device but the command to fetch the total cpu, memory and swap usage is top. More specific it is:
top -m 1 -d 1.0 -n $duration
Now I have been looking to find a replacement for this and I found out that I can use dumpsys. The problem what I have is that I want to give a timeout like this:
dumpsys -t 20 cpuinfo
I checked this site: https://developer.android.com/studio/command-line/dumpsys.html but didn't find out why this doesn't work. Even when I try the help I get the same error
dumpsys --help
Can't find the service: --help
Does someone know what is going on? My current android version is 6.0.1 if this is important.
Thanks in advance!
It is true that dumpsys --help does not work. I think there is a mistake in their document. However, below works:
# adb shell dumpsys input
# adb shell dumpsys -l
Add permission on your manifest "android.permission.DUMP".or
There's another (hacky) way to access dumpsys without rooting your device - through adb shell.
This will require allowing USB debugging, and finding the port of the adb service.
Enable USB debugging on your device. This option is found under Settings -> Developer Options.
Connect your device to a PC, and run the following command from the PC's shell/command line: adb tcpip 12345. Then, from your devices shell, issue the command adb connect localhost:12345 from your application. You can now disconnect the device from USB. Alternatively, you can scan the ports on your device one by one without USB connection, using adb connect localhost: and find the port adb service is listening to.
Authorize USB debugging from the pop up confirmation dialog, if prompted. Check the "always" checkbox to do not require this step again.
Now, when you have access to the adb service, use adb shell dumpsys ... from your application code to get whatever service dump you need.
I am using VS Android Emulator for Marshmallow and want to test my application (Xamarin) in Doze mode. The problem is the Emulator never seems to go to Doze mode.
Using adb I have issued the following commands, repeat step 2 again and again but the end result is always "Stepped to: ACTIVE".
adb shell dumpsys battery unplug.
adb shell dumpsys deviceidle step
Any help is appreciated.
Here is the answer. In all documentation, post, forum they don't mention that you have to enable the deviceidle state. Issue the following then run the two commands above. Thanks.
adb shell dumpsys deviceidle enable
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!