what is the difference between Sleep mode and Deep sleep mode? - android

I would like to know what is the difference between Sleep mode and Deep sleep mode in android phone and what will be the impact of when phone goes to sleep mode and deep sleep mode.
Please provide me the answer in details.
regards,
Piks

Deep sleep mode doesn't have anything to do with hibernate and boot time, as somebody wrote in deleted answer.
You should not avoid the phone sleep, this will drain your battery very fast. To receive messages from server, you should use [C2DM] GCM which has the same basic characteristics as old fashion deprecated C2DM.
More info about the android sleep here:
http://developer.android.com/reference/android/os/PowerManager.html

You can use WAKE_LOCK to prevent device going to deep sleep. But you must take into account battery drain. More info: http://developer.android.com/reference/android/os/PowerManager.html

Deep sleep: turns your phone CPU central processing unit ie brain to the lowest clock cycle speed. On mine it is 200mhz, where max is 1600mhz.
it also disables some sensors it figures you might not be using, such as dependin on phone camera, gyro, etc. some of it gets shut off to save power.
When you wake up your phone depending on governer, it rams cpu clock cycle up to 500mhz, or 800mhz, or 1600mhz, and re activates the sensors, sending power back to the camera, cyro, magnet, etc that your phone may have proxi sensor
This is more or less what deep sleep really IS. program, to save power, by disableing unused sensors, and clocking cpu way down to minimum.
Credits: vrigil kellogg http://forums.androidcentral.com/sprint-galaxy-s-iii/247066-what-deep-sleep.html post#14

Related

What exactly do wake-locks prevent?

In the wake-lock training doc it says:
If you need to keep the CPU running in order to complete some work before the device goes to sleep, you can use a PowerManager system service feature called wake locks.
It was my impression that "before the device goes to sleep" referred to doze mode. However, the answer to the SO post Wakelock and doze mode states:
Holding a PARTIAL_WAKE_LOCK is insufficient to block Doze mode
So, if a wake-lock doesn't prevent doze mode, then what exactly is meant by "keep the CPU running in order to complete some work before the device goes to sleep"?
Also, in the doze standby training doc it says:
An app that is partially exempt can use the network and hold partial wake locks during Doze and App Standby.
If (for some reason) "before the devices goes to sleep" does refer to doze mode, then does this mean that wake-locks have absolutely no effect unless you are on the white list for no battery optimizations?
Specifically, I'm talking about partial wake-locks on API 31+.
what exactly is meant by "keep the CPU running in order to complete some work before the device goes to sleep"?
Android devices can power down their CPUs to reduce battery consumption. This usually happens shortly after the screen turns off.
A partial wakelock says "allow the screen to turn off but keep the CPU powered on". This is used for things like long-running audio playback (music, audiobooks, podcasts, etc.).
A full wakelock says "do not allow the screen to turn off either". This is used for things like video players, where the user's expectation is that the screen will stay on despite limited user input.

Android phone , what units are shut off In sleep mode

I have a scenario that the android device exchanges data with a FTP server via Roaming service. I hope to make OS enter proper sleep mode by setting WakeLock type during the data transferring because it really has no interaction with enduser.
I am going through the sleep threads and trying to verifying that what units will be shut down in sleep mode to prevent data sending. So far, no official doc indicates them .
So , Would you please help to enlighten me on the questions: When Android enters sleep mode , what components will stop working , like WIFI , Data Roaming ?
Thanks a lot.
When Android enters sleep mode, almost everything is shut off. Only basic system apps and GSM/CDMA radios are left on to receive texts, calls, push notifications etc. Services, Activities are all shut off, and the CPU is put into a low power mode. Depending on what the user chose in the wifi settings, the wifi connection may or may not switch to mobile data or shut off completely.
If you want to keep processing, but don't need the screen on to interact with the user, you should acquire a PARTIAL_WAKE_LOCK in which the screen and keyboard are off, but the CPU is kept on. However, remember to release the wake lock when you are done, as PARTIAL_WAKE_LOCK is the only one of the four wake locks in which the CPU will continue to run until you release it or your app is killed. Forgetting to release the wake lock can be a huge drain on the user's battery.
When the power off button (lights off) is pressed by user then phone into sleep mode.
Sleep mode means CPU will be in sleep mode and will accept only command from radio interface layer and alarms. Within fraction of seconds the CPU will go into sleep mode.
When we need only CPU on and other things off we use PARTIAL_WAKE_LOCK which suits perfect in your scenario. Weather this lock is generally used in apps like mp3 player etc.
As you want data transfer here in this mode then you have to override already given methods from class PowerManager with specifically by allowing some function to be turned on in this mode.

Does Handler.sendMessageDelayed() work when phone goes to sleep?

I am developing an android application and I want to reduce the power consumption. The method I believe is to put the phone into sleep mode whenever the user activity stops for a certain threshold period. I have three questions regarding this.
If I release the wakeLock and no other application is holding the wakeLock after how much time would the phone go to sleep?
I have multiple HandlerThreads running where I use sendMessageDelayed() function. Would these messages get delivered even after the phone goes to sleep mode?
Does putting the phone into aeroplane mode save more power rather than just putting the phone to sleep. if yes, then why is it because the only difference in those two modes is the use of cellular network.
If I release the wakeLock and no other application is holding the
wakeLock after how much time would the phone go to sleep?
There really is no definitive answer, but, from personal experience, I'd say it is likely that it will happen within 30 seconds to 1 minute.
I have multiple HandlerThreads running where I use
sendMessageDelayed() function. Would these messages get delivered even
after the phone goes to sleep mode?
I really wouldn't count on it because I've never seen anything that says it will wake up the device to send said Message. You can always test it, but I wouldn't trust it to work because the documentation does not claim that it will.
Does putting the phone into aeroplane mode save more power rather than
just putting the phone to sleep. if yes, then why is it because the
only difference in those two modes is the use of cellular network.
If you put it into sleep mode AND airplane mode, then you will save more battery than JUST sleep mode.
The reason for that is that even with the CPU pretty much asleep, the phone must keep a constant connection with the cellular network in order to know if you get a text or phone call. To do this, it must use the battery to constantly keep the antenna turned on. If you put it into airplane mode, it would basically turn the antenna off, and then the phone would not be using battery for that function.

How to adjust the time length for getting into a deep sleep

I am not sure if I had understood it correctly.. but it seems that android has a sleep mode
where everything is paused except the background services and a deep sleep mode that turns off
everything even the CPU.
So I wonder if there is there a way to control the time before getting into a deep sleep mode. Couldn't find any official documentation about the sleep modes.. Any help is appreciated!
Thanks
but it seems that android has a sleep mode where everything is paused except the background services and a deep sleep mode that turns off everything even the CPU.
AFAIK, there is only one sleep mode, corresponding to what you describe as "deep sleep". Certainly, from an SDK developer standpoint, either the device is awake, asleep, or off.
So I wonder if there is there a way to control the time before getting into a deep sleep mode.
Not really. You control how long the screen is on via the Settings app. How long before the device falls asleep after that will range from milliseconds to centuries depending upon what is going on with the device (e.g., is anything holding a WakeLock).

Android battery usage keep awake explanation

In the Battery usage screen there is a time for "Keep awake". What does that mean exactly? Is there any documentation somewhere about those numbers?
This appears to show the amount of time that an app has asked the OS to stay in a waking state.
You can see the options available to the developer in the PowerManager class.
For example, an app can request a PARTIAL_WAKE_LOCK. As long as at least one app has requested a partial wake lock, the device will stay active (and consuming battery) even when the screen is off. From the docs:
If the user presses the power button, then the screen will be turned
off but the CPU will be kept on until all partial wake locks have been
released.
I believe the Keep awake time is reporting for how long a given app had this flag set.
Examples on my phone right now,
Google Chrome Beta has an extremely short Keep awake time, 5s. This looks very well behaved.
Another app known to be a terrible battery hog has a Keep awake of nearly 2 hours, despite being actively used for only a few minutes. I would guess this app is not releasing its partial wake lock.
This talk from Google IO on Coding for Battery life kind of clears it a little better:
http://developer.android.com/videos/index.html#v=OUemfrKe65c
It keeps the screen awake while charging. You can check this discussion.
http://www.droidforums.net/forum/team-d1-miui/103349-battery-settings-question-stay-awake.html
You may also note that this time that you talk about seems like the time which this phone uses this function.
I believe it is to keep your screen from sleeping while you recharge your battery.
Here's a relevant topic:
http://www.droidforums.net/forum/team-d1-miui/103349-battery-settings-question-stay-awake.html

Categories

Resources