When does android device go to sleep mode?

半城伤御伤魂 提交于 2019-11-28 06:25:00

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!