| || |
Re: Demystifying Wakelocks
Put much more simply:
An application needs to apply for a "wakelock" if it wants to do something in the background even if the phone would otherwise go to sleep. A wakelock effectively prevents the phone fully going to sleep while the wakelock is in effect. This allows the application to finish whatever it wanted to do.
There are legitimate reasons for applications to use wakelocks - this includes any application that needs to do something in the background while the phone is not being used, and it can't simply wait until the phone "wakes up".
However, applications that make excessive or improper use of wakelocks run down the battery unnecessarily, and unfortunately there are many such applications.
Only applications that have "Prevent the phone from going to sleep" permission when you install them are allowed to use wakelocks. If you are installing an app and it requests that permission, you may wanna keep an eye on its battery use. Apps that don't request that permission can't use wakelocks.
The other vital thing to understand, and may be obvious to some but not others, is that just because your screen is off doesn't necessarily mean that your phone is asleep. When looking in the battery stats at how much time an application has kept the phone "awake", that doesn't necessarily mean the screen was on: the phone could have been working hard even while the screen was off. In this case "awake" vs "asleep" is referring not to the screen but to the CPU going into its sleep mode to save power, which is a different thing. This is the reason it's hard to tell what is using the battery without going into the battery stats.
More info, for technical people:
If you're concerned about the battery life used by an app, the in-built battery stats should give you a lot of useful information. Keep an eye out for an app whose overall battery use "bar graph" is way higher than the others (apart from "screen"). And for more detail on a particular app, you want to tap on the app itself. "Stay awake" is the specific stat associated with using wakelocks, however sometimes apps use wakelocks even when they're in the foreground, so if you have a high "Stay awake" value, but also a high "CPU foreground" value, it could mean that most of those wakelocks were used when the phone would have been awake anyway (nonetheless, it is still a helpful stat). The reason why some apps can still get stuff done without any need to use wakelocks is that they only react to interactive events such as key presses and screen touches that the device wakes up for anyway.