Ahmed
Ahmed

Reputation: 15059

Can not switch to Doze mode

I am following instructions on this android page to switch android to doz mode to test my app, I have used a real device as well as emulator. But in both cases when I give the second command once or several times, which is

adb shell dympsys deviceidle step

it only says Stepped: ACTIVE Before giving the commands I turned off/locked the device as well but no use. I wanted how my app behaves in doze mode but nothing seems to work,

I also tried

adb shell dumpsys deviceidle force-idle

but this gives me the message below.

 Unable to go idle; not enabled

Please advise. I am using motorola Moto G 2nd generation android 6.0 and also used emulator x86_64 bit image with android studio version 1.5.1

Upvotes: 34

Views: 9803

Answers (5)

Radu
Radu

Reputation: 973

I know that this is old, but you can't go to deep idle if there is a pending alarm. Some devices come configured that you can't go to doze even an hour before an alarm. So try this on newer Androids (via root or adb): sudo device_config put device_idle min_time_to_alarm 10000 or (on older androids) settings put global min_time_to_alarm 10000

Upvotes: 0

Noaman Akram
Noaman Akram

Reputation: 3830

try these commands for idle mode in emulator (you can use it in device also but if it is not working on device (clock timer or other reasons try these on emulator)

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

to check if device goes in idle mode or not try this command

adb shell dumpsys deviceidle get deep

Upvotes: 2

researcher
researcher

Reputation: 1788

Try this:

  1. Disconnect and reboot your device.
  2. Connect device and launch app from Android Studio, switch off the screen.
  3. In terminal:
adb shell dumpsys battery unplug
adb shell dumpsys deviceidle force-idle

This works for me.

Upvotes: 2

BrianMiz
BrianMiz

Reputation: 1181

try using

adb shell dumpsys deviceidle enable

that should enable the deep and light idle modes, then use

adb shell dumpsys deviceidle force-idle

Upvotes: 71

Ragesh Ramesh
Ragesh Ramesh

Reputation: 3520

It can sometimes misbehave. When it happend to me i used the command

   adb shell dumpsys battery reset

This will drain your battery. After letting it charge for sometime i used the below two commands

   adb shell dumpsys battery unplug
   adb shell dumpsys deviceidle step

Make sure you give the last command multiple times. Let me know if this works.

Upvotes: 3

Related Questions