When does android device go to sleep mode?-ThrowExceptions

Exception or error:

I was searching SO and web but i couldn’t find sufficient answer for my particular question. Ok here we go:

Every user can modify screen timeout on android. (when screen turns off when its idle for __ seconds/minutes – users choice ). But user can modify ONLY screen timeout and not when device goes actually to sleep. I found here what happens when device goes to sleep: (Really nice answer by CommonsWare) Android Sleep/Standby Mode

Ok my question is simple. How do i know when my phone will go to sleep? Will it go to sleep immediately after turning screen off? Will it stay “awake” a while after screen was turned off? And most important: Does sleep mode in particular device varies from brand device ( how manufacturer implement this ) or it depends on ROM version (For instance, all ICS powered devices will go to sleep X seconds after screen was turned off )?

How to solve:

You can never really be sure if the device has gone to sleep. At best, I can give you a list of things that would make sure that the device hasn’t gone to sleep:

  • Screen being on – Requires CPU and GPU, and hence RAM, to stay active
  • Any app holding a wakelock – Even the lowest wakelocks keep the CPU on, though the screen may be switched off

Apart from this, there is no guarantee that the device will go to sleep n seconds after the screen is turned off, even if no wakelocks are being held. This is upto the OEM, and they can alter this.

Keep in mind that Android devices have an option to keep the device unlocked for a certain amount of time after the screen has gone to sleep.


There is small difference in power consumption when you compare a phone with laptops.
Laptops most of the times runs on direct power through charger. (Mostly we carry charge with laptop).
Mobiles mostly run on battery power. (Rarely we carry charger with us).

By keeping this in mind, android has designed in a such a way that, phone will not consume battery power if user is not interacting with the phone. This is to increase battery back up time for user.

That’s why when LCD screen power is off (that means user is not interacting with phone), with in fraction of seconds CPU will also go to a mode (sleep mode) where it does minimal work and saves battery power. When CPU is in sleep mode, it accepts commands only from RIL (radio interface layer) which is basically SMS and call functions, and alarms. Other than this CPU will stop executing other applications functions.

Note : If any application wants CPU time for its emergency work when CPU is in sleep mode, then it can request CPU time by using WAKE LOCKS.

For eg : MP3 application has to keep playing songs in its service, even though user has turned off LCD screen. That means MP3 application’s service has requested CPU time by using WAKE LOCKS.

Your question : How do i know when my phone will go to sleep?
Ans : Simple it goes sleep mode when LCD power is off, with in fraction of seconds.

Your question : Does sleep mode in particular device varies from brand device
Ans : Since android is open source, any OEM can take driver layer , which is GPU license and can modify the power manager drive to behave differently. All these sleep modes and wake locks are finally under control of Power manager driver of Linux kernel layer.


for testing sleep mode/doze in Android 6.0 you should use next commands:

$ adb shell dumpsys battery unplug
$ adb shell dumpsys deviceidle step

more info see here: Optimizing for Doze and App Standby

Leave a Reply

Your email address will not be published. Required fields are marked *