Saving battery power on Android: Third-party apps and wake locks

Edit July 3, 2014:

Originally written based on Android 4.0, this post is now over two years old. I now own a Nexus 5 running Android 4.4.4, and the battery monitoring screen has apparently improved a great deal since version 4.0:
If any app holds a wake lock for an excessive amount of time, it will show up clearly as a power hog on the Settings –> Battery screen. This should make battery life troubleshooting much easier than it was in the past. Kudos to Google for this improvement.

 

Here is the original post from Feb 16, 2012:

Introduction
If you have an Android device and enjoy installing and using many different apps, chances are that you may have run into the problem of rapid battery drain even while the screen is off.

If you Google “how to save battery on Android”, you will often find tips such as disabling various wireless radios, lowering your screen timeout, lowering your brightness, etc. These tips may help, but a potentially more serious culprit is some third-party app constantly keeping the system awake, draining power in the background. If this is the case on your phone, it will by far outweigh the consumption of your wireless radios, possibly reducing your battery life to as little as 8 hours.

To understand how this is possible, let’s take a step back and compare Android to a few of its competitors.

On iOS and Windows Phone 7.5, developers have little freedom to run code in the background. In the case of WP7, apps can only execute code in the background for up to 30 seconds once every 30 minutes. This is a conscious design decision by Apple and Microsoft, respectively: to sacrifice some of the third-party developers’ freedom in order to ensure a reasonable battery life for their users.

On Android, however, depending on their permissions, third-party apps may have unlimited freedom to execute in the background and keep the phone awake. Without getting too technical, apps can request a so-called WakeLock that prevents the phone from entering a low-power state known as Sleep where the CPU is powered down. If an app for one reason or another fails to release its wake lock after use, the CPU will remain on, draining power.

Android apps don’t necessarily consume more power than their iOS and WP7 counterparts; the point is that they can.

Is an app on my phone draining power?
To determine whether your phone is being kept awake by an app:
Android 4.0: go to Settings –> Battery
Android 2.3: go to Settings –> About phone –> Battery
Versions prior to Android 2.3: Your built-in battery manager doesn’t display the detailed information required, but you may be able to find an app on Market that can display the same information.

You should see this screen:

Pressing the battery graph will bring up this screen:

Look at the 2nd image – notice how “Awake” and “Screen on” are more or less in sync with each other. This is a healthy sign, indicating that no app is holding a wake lock.
If this is the case on your phone, you may still be able to optimize your battery by examining the general battery page. For instance, if your screen is taking up a large percentage, your biggest potential gain may be turning the brightness down.

If, however, your blue Awake line is more or less constant – that is, not following ‘Screen on’:

… then you have a problem.

Contrary to common sense, we cannot necessarily determine the culprit simply by reviewing the app list on the main Battery page. Apps holding a wake lock may simply appear as part of ‘Android OS’ or ‘Android system’.

One thing you can try is to simply restart your system. If there are any old, abandoned wake locks, the act of restarting will remove them. If this doesn’t permanently solve the problem, read on.

How to determine which app is draining power
As far as I know, there is no easy way to pinpoint the problematic app. Third-party apps aren’t able to request a list of all current wake locks, so you probably won’t find a battery tool on Market that can release them for you.
There is, however, a method that can point you in the right direction, and that is determinng which apps have the ‘Wake lock’ permission.

You can go to Settings –> Apps and for each app check whether it has the permission “System tools – prevent phone from sleeping”. Or you can use a third-party tool to show a list of all apps with the wake lock permission:

1: Download aSpotCat from Market
2: Launch it and choose “List apps by permission” –> System tools –> Details –> “prevent phone from sleeping”.
3: You should see something like this:

Consider which of these apps may be the culprit. It’s probably one that you actually use and maybe consider to be ‘crappy’. Completely unused apps rarely cause trouble (it’s possible, though). Once you have your suspect, uninstall it, then restart the system and see if the problem goes away. If not, try uninstalling a different app.

Conclusion
As you can see, the freedom af Android comes with a potential downside. Google could likely remedy this by letting users get a list of current wake locks (this is actually possible using the so-called adb shell, but it’s not a very convenient method). It only takes one poorly-written app to ruin the user experince, so let’s hope that they elect to prioritize this problem in a future iteration of Android.
Check out my other blog post Saving battery power on Android: Tips that don’t work

Disclaimer: I’m not an Android framework developer, so I cannot guarantee that the above is 100% accurate. It is based on my own observations and research. Feel free to leave comments!

Advertisements

3 responses to “Saving battery power on Android: Third-party apps and wake locks

  1. Pingback: Saving battery power on Android: Tips that don’t work | Anders Nielsen's developer blog

  2. All the other power saving tips are crap, the reason you mentioned is the most important. If when the phone screen is locked and the android system consumes over 75% of battery, then it was obviously kept awake by a third party app. Which app, is very hard to find out, because the test itself for a single app takes time.

  3. Pingback: The Android thread - Page 351

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s