Welcome to the Cellar

Don Dohler: Uncontained Imagination « Baltimore Filmmakers

Baltimore Filmmakers posted a nice article about my friend, the late Don Dohler. Here's the link:  Don Dohle r: Uncontained Imagination...

Tuesday, April 15, 2014

I Finally Solved the Battery Drain Problem on My Android Phone


It's no secret that some Android devices have issues with battery life--at least if you actually use them. I have a Galaxy S3, and in the last few months, I've had major drain in battery even when I'm not using the phone. A friend of mine chose to get a higher-capacity battery, but I wasn't too keen on the required larger case. Plus, I really wanted to see if I could find a way to manage the battery life. Below is some background from my quest to resolve this challenge. But you can skip to the good part if you just want the solution.




Background


My phone does last through the day. It's usually at around 60% when I get home from work, and hits 45-50 % by around 10PM. So I have to charge every night. Okay. Fine. But here's the thing: I don't use it most of the day. I may make one or two short calls, a couple of texts, and check Facebook or Twitter a couple of times. That's not much, so I'd expect that the battery would trickle a few points between uses. But my phone drains a lot of battery while it's off.

So my quest began for better battery life. The first step was monitoring. I tried a few apps like Battery Mix, which does a pretty good job of showing usage, and has sister app to clear tasks. I also tried, and still use Auto Memory Manager. These apps help, but there was something else going on.

That's when I discovered the concept of wake locks. "What the hell is that?" you may ask, as I did. Basically, it's a trigger that wakes up your device and keeps it active for a period of time, whether the screen is on or not. Social networks and Google apps do this a lot, as do the apps installed by the phone makers. So I installed Wake Lock Detector. This is a great tool to help determine what's keeping your system awake. And with it I was able to find some key apps that were doing this. And again, this helped, but was not meeting my goal of not draining too much battery while I was not using the phone. Before I get to the final solution, I have one more helper that yet again helped and is another I still use: Greenify.

Greenify has a sort of a gentle brute-force way to close apps. Yeah, that doesn't make sense, but it fits in this case. Greenify closes apps by hacking an automated force close (called hibernating) on those you've selected as candidates. This tries to keep them from running when you don't need them. It's a cool idea, and it does work (it also shows which apps restart themselves, ah-hem, Google Drive and Twitter).  But it still didn't help me reach my goal. The app deserving the crown is Tasker!

The funny thing about Tasker is that while all the other apps propose to help with battery life, Tasker just controls stuff, but it does the best job of protecting your battery. Tasker can start apps, it can change setting, detect if you're plugged into power, are running your GPS, and just about anything else you can imagine.

It did take a while, but I finally found the sweet spot to contain the drain. I now get home from work with battery at about 77-80%, and it's still at about 70% at 10PM. Plus, it doesn't drain much over night.

The Solution: Tasker


My goal, as I said, was to make sure the phone didn't drain too much battery when I wasn't using it. To do that, I found you have to be able to turn off a few things that by default run constantly and set them to only run when you need them. I'm referring to autosync, mobile data, and wi-fi. These appear to be the biggest drain. Autosync, for instance runs constantly by default and can't be set to an interval. But you can do this with tasker. As for the data and wi-fi, you can control when they're on and off so you can use them when you need to, but have them off when you don't--all with Tasker profiles and tasks.

I won't get into how to use tasker here. There are plenty of good sites for that. But I will list out how I set up tasker to handle my battery usage:

Profile - Sync interval: This will turn on data/wifi, and autosync for 5 min (you can make it what you want) and then turn them back off. The interval for this can be set to whatever you want as well. I set for every hour.

The Task:
  • Mobile Data: On
  • Wi-fi: On
  • Autosync: On
  • Wait 5 min
  • If %SCREEN !=on (don't turn off data if screen is on)
    • Mobile Data: Off
    • Wi-fi: Off
  • EndIf
Profile - Screen Unlocked: When you turn on your screen and unlock it, turn on data/wi-fi.

The Task:
  • Mobile Data: On
  • Wi-fi: On

Profile - Screen Off: When the screen goes off, turn off data/wi-fi (sync interval will poll your services at the interval you set, so you don't need data when you're not using your phone).

The Task:
  • If %MYPOWERVAR=0 (not plugged in)
    • Mobile Data: Off
    • Wi-fi: Off
  • EndIf

Profile - Capture event of plugging into power: This allows you to keep data/wi-fi/autosync on when you're plugged in.

The Task: 
  • Set Variable: %MYPOWERVAR=1

Profile - Capture event of unplugging from power: Opposite of above.

The Task: 
  • Set Variable: %MYPOWERVAR=0

Of course, this is one method to address this. There are many other ways, I'm sure. And it can take some time to find what works for you. Good luck.



No comments:

Post a Comment