It’s the early afternoon, and your Android phone is already running on “E.” What’s the deal? A smartphone is supposed to be the hub of your digital life, but it can’t do that very well when the battery has run dry, can it?
You probably shouldn’t wait until your phone has failed you at a critical moment before you figure out what’s destroying your battery life—there’s no better time than now to track down the culprit. If you're lucky, you might even be able to fix the issue without sacrificing functionality.
Wakelocks and misery
Android has gotten much better at managing background processes in the last few years. Anyone who has used Google's platform since the early days can tell you how bad things used to be when “task killers” were a necessity. Even though Android as a whole isn't subject to the same horrible battery life issues, the wrong combination of apps can still break Android’s elegant process management scheme.
Conventional wisdom used to be that you should open the multitasking interface and kill any application you’re not using to save battery life, and unfortunately this superstition still persists. But Android knows how to manage background tasks, and swiping apps out of the multitasking interface only closes the foreground process. If an app is indeed causing issues, it's usually the background process that's doing it. This sort of micromanagement will only waste time.
The stock Android battery use menu can be helpful, but it only tells part of the story. Most apps show up here because you're actually using them a lot—that's to be expected. This menu merely shows you the system process and app packages that are using juice, but the 'Awake' and 'Screen on' lines are the most important. If you have a lot more awake time than screen on, something might be keeping your phone from sleeping. This is called a wakelock, and it's the number one enemy of your battery life.
When an app or service needs to run a process, it can wake the device with an alarm. The wakelock mode keeps the CPU awake so the app can do its business. This is usually no big deal: the app finishes up, and the device slips back into deep sleep. Conflicts and bugs can cause wakelocks to persist, essentially keeping your phone from sleeping at all. In order to figure out what's messing with the battery, we need to find the root cause of this baffling case of smartphone insomnia.
Solving the case
It might not be immediately obvious that a phone is in wakelock for long periods. By all appearances, the screen is off and it seems to be asleep like it should be. One clue that something is going wrong is excess heat generation. When the CPU is cranked up instead of in deep sleep, the device might be noticeably warmer than usual when you pick it up. You'll need to do a little detective work, though, and that's where the apps come in handy.
One quick and easy way to watch for a phone that won't sleep is to use an app like System Monitor to track CPU clock speed. This app breaks down CPU activity as a percentage. Unless you've been using the device almost constantly, ”Deep Sleep” should be the largest part of the chart. If not, you've probably got a misbehaving app or system process.
You'll have to dig a little deeper in order to sort out the exact cause of your shortened battery life. The best app for this is BetterBatteryStats. The developer posts free beta builds on the XDA forums, but it's also for sale in Google Play. Rooted users see more information in the app, but you can still get some data on wakelocks with almost all devices.
Just give the app a few hours to calibrate, and then filter for Kernel Wakelocks and Since unplugged. If you see a process up near the top of that list with a lot of wakelock time, that's the guilty party. Kernel wakelocks are system processes like suspend_backoff or wlan. BBS BetterBatteryStats sometimes includes links to more information about wakelocks with some ideas for fixing them. Otherwise, you can search for information on the exact system process and find a likely solution. Often, a reboot will knock some sense into your phone and clear this up.
If you suspect a misbehaving app on your device, check for the PowerManagerService listing. This is a catchall for so-called partial wakelocks caused by apps. Rooted users can see the partial wakelocks in the app, but everyone else will have to do some detective work by comparing recently installed apps and the onset of the PowerManagerService issue. To confirm, uninstall suspect apps, create a custom reference point in BBS, put the phone to sleep, then check the wakelocks a little later. If PowerManagerService is no longer eating up most of your sleep time, you’ve cracked the case. Well done, gumshoe!
More often than not, the root of your problem will be some app you installed. The easiest way to deal with the issue is to leave the offending app or game uninstalled, but maybe you actually want to use the app despite its battery sucking behavior. In that case, you need a way to end the process safely. Android has a built-in way of hibernating processes, and you can easily trigger it with an app called Greenify.
Simply use Greenify to identify the problematic apps, and hit the hibernate button after you're done using them. Greenify works best with root access—it can handle all this in the background. For non-rooted devices, you can use the in-app button or a widget to manually trigger the hibernation routine.
Going through this process might seem like a hassle, but it's preferable to having a phone that can't hold a charge. It can also save you from disabling useful features like GPS or background sync in the name of eking a bit more life out of your device.