Using automation apps to save battery (and which one works best)

LeoRex

Retired Moderator
Nov 21, 2012
6,223
0
0
Visit site
Like probably everyone here, one of the things that annoyed me most about smartphones is battery life.... going from a 'feature' phone that could sit in standby for a couple of weeks between charges to one that would gorge on its charge in a day (or less), it was a bit of an adjustment, and one that I immediately tried to improve. I mean, this little phone had a 2100 mah battery in there! At first, I tried dedicated 'battery saver' apps, but they were only mildly effective, and they lacked the customization I wanted... I knew I could do better if I had the opportunity to go into the guts... So I looked around and discovered automation apps.... they would effectively do what those dedicated apps are doing, but I had full and total control of what and when it did.

After learning a bit about Android, I quickly learned that battery management basically boiled down to one thing; getting the processor to sleep and keeping it there. Short of turning it off, when the phone is sleeping, it is sipping power. Left to its own devices, most every smartphone will act like a newborn baby... waking up constantly even when you don't want it to... I learned about wakelocks... calls to the OS designed to wake up the phone and KEEP it awake so an app can do it's thing... and oh... there were plenty. Google Search, Gmail, Facebook, etc.. you name it... those apps would constantly wake the phone up to take care of some task or another... sapping power each and every time.

I also learning about managing data connections.. and how sitting on a strong Wifi signal will use next to no power (and connecting to a poor WiFi hotspot will conversely suck it dry) and that limiting when the phone is active on the 3/4 mobile data. So I figured that I only had to do a couple of (seemingly) simple tasks to reduce the screen-off awake time:

1) Limit when background sync is running. There are plenty of apps that will poll CONSTANTLY when the phone is sleeping... Google Now is probably the poster child for this...it is the champion of sync-related wakelocks (and even with sync off, Google Location Services comes kicking down the door... so I've turned that off, which is sad since that allows Google Now to really shine)... It is the Secretariat of wakelocks. But Gmail, Facebook, pretty much any app that has to sync with something online will throw WLs. I currently turn off sync when my screen goes out, and turn it on for 30 seconds every 15 minutes to allow apps like Gmail to check for anything new.

2) Disable my WiFi when I and not near a hotspot and poll occasionally to see if there is a known AP nearby (10 second poll every 15 minutes).

3) Go into a modified kind of 'Airplane Mode' overnight when I sleep (turn off everything except the phone radio).

(I also played with the CPU governor, thinking if I can force choke the cpu into lower CPU modes, I can save some cycles, but that ended up doing as much harm as good)

So far, I've tried three... AutomateitPro, Tasker and Llama. AutomateitPro was a good app, but the interface was a the least intuitive of the bunch, and on my phone... it was quite buggy... force closing on some tasks, lagging, etc... So it was down to two ends of the automation spectrum; Tasker and Llama.

Tasker is, of course, the most well known and used auto app out there... With a couple of 3rd party plug ins loaded, you pretty much have full and total control over most every function of the phone. The interface has a bit of a learning curve, but I come from the world of SW development, so it only took a little playing around with to get the tasks I needed.

Llama is a lesser known app out there, and it doesn't have all the bells and whistles that Tasker has. But it still supports a wide variety of functions and you are not going to find an easier and more intuitive interface... it is a breeze to configure.

Left to its own devices, my phone (Samsung Galaxy Stellar), with everything on, will slowly nibble around 4% an hour, even higher if I leave GLS on. So even with light usage, and the screen off for most of the day, I'd been running on fumes before the day was out, throwing it on the charger became part of my routine when I got home from work.... So that sucked.

Tasker, once set up, did a good job of reducing that... during the day, usage dropped to around 2.5% an hour. At night, it would drop to 1.5%/hr... So averaged out over a day, my screen-off battery usage dropped close to 50%... which was awesome. But there was one thing that bugged me a bit... Looking at the battery stats, the AlarmManager was now numero uno when it came to wakeups and it had a noticable affect on power usage and Tasker was responsible for a significant majority of those alarms. Much like the parasitic loss on an turbo or supercharged engine, Tasker appeared to be working quite hard behind the scenes to do its thing. Try as I might, playing around with how the tasks run, I couldn't reduce those alarms. Still, 50% less is 50% less.

I kind of knew going in that I will probably find that Llama had a lighter touch than Tasker. It has nowhere near the feature set of Tasker, so I figured that would also translate to less noise as it worked in the background. And the data I found most certainly backed that up. Over the course of the day, with tasks that performed pretty much identically as Tasker, my phone's standby battery drain dropped to 1.5-1.8%. At night, it dropped to a staggering 0.5%. Looking at the stats, Llama generated a tiny fraction of the alarms Tasker did... showing up far down the list.... doing its thing with virtually no impact on battery usage.

So that worked out to a 400% improvement in standby battery consumption. W00T! That rocks. Even with Tasker, I found my self charging daily... but with Llama calling the shots, I can go 2 or 3 days (depending on usage) if needed.

So for features and raw power, Tasker is King, but if you want an efficient little powerhouse, check out Llama.
 

garublador

Well-known member
May 20, 2013
1,135
0
0
Visit site
That's a lot of great information. I always kind of wondered how "light" Tasker was and I'm glad to hear that it's worth using for battery saving functions. It's also interesting to hear how much lighter Llama actually is.

I will point out that there are very few situations where you'll need to run your phone for more than a day at a time. Almost everyone sleeps for several hours every day and that's plenty of time to charge a phone. With that being said, you really only need to go a day on a charge (probably less than a full charge to make it easier on the battery). So if you can get it to where you're at ~20% at the end of the day you've maximized the features you can use while still having good battery life. Going any farther isn't really necessary and you may end up not using some useful features.

This may be out of the scope of this thread, but do you have any data on how much each change made with your battery life? For example, how much battery do you save by messing with the WiFi? The battery monitors I've used only claim WiFi to use 2% of my battery per day so they're either lying (which wouldn't surprise me in the least) or shutting off WiFi won't save much power.

Limiting auto sync sounds very promising, though. It seems like that's what apps like BatteryGuru do, but they don't always do a good job. How did you end up implementing it in Tasker? I've done a bunch of stuff in it but haven't had much experience with trying to time tasks like that. Do you just have a profile that's active when the screen is off that runs a task that turns synch off, waits 15 minutes and then runs a task that turns synch on and then waits 30 second and then runs the first task starting the cycle over? (Of course you'll need an exit task that stops all of that, too) Or is there a better way to accomplish that?

One thing that I found useful in Tasker was keeping a running count of how many times the Google API was used to get my location. It then saves that data in a log for each day and resets the number so I can see what changes actually affect how often my location is polled.
 

LeoRex

Retired Moderator
Nov 21, 2012
6,223
0
0
Visit site
Yeah, I know, throwing it on the charger when I go to bed isn't a big deal.... but it is the principle of the thing. :) Plus, the less the phone uses when it sleeps, the more screen time I can get. I don't want my phone eating through a 1/3 or 1/2 of a full charge just sitting there at my desk while I am at work. It is an inefficiancy that I don't like. The only one that should be draining that battery is me basically.

Yeah... I should go through and step through to see which function saves the most battery. But I can tell you, from what I've seen in the past, by FAR... it is the background sync. Leaving that on is like an open invitation for any app to waddle up to the battery buffet and start feasting. There is a long line of ETs in that phone needing to phone home ALL THE TIME. I would like to know the battery drain from just leaving WiFi on even though it isn't connected... passively looking for a known AP....might not be all that much in the long run.

I've tried several methods in Tasker to toggle sync in the background... I assume that periodic tasks were one of the big sources of those alarms triggering so often. But the one I settled on was this:

A Profile called "Screen On" It fires when the display is unlocked. I like tihs better than firing when the screen is on since I often use my phone to check the time. This way, I have to unlock the screen before it'll start dealing with syncing. In that Screen On task, I turn on Auto-Sync.

Profile "Screen Off". This triggers on the screen off state. That disables Auto-Sync. I would love to be able to handle it in one task with an enter and exit... but Tasker has the "Screen Unlocked" as an event, so it won't accept an exit task. They could be combined into one... with turning on Auto-Sync in the enter and turning it off on the exit.

I also used these two tasks to fiddle with the CPU governor for a little bit... but my phone kibbied out when I started messing around with that (got laggy as all hell and rebooted from time to time).

While this is going on, I have a third profile... we'll call it 'Sync'. That has two contexts; a repeating time context of every 15 minutes and state context of the display being off. I know I could use a timer in the Screen Off profile, but I read that for periodic tasks, it is better to use a repeating context rather than a timer as part of task, that is why I broke it out of the Screen Off profile. The task that is assigned turns on Auto-Sync, waits 30 seconds and turns it off. It should, for the most part, let Gmail sync up... and that is mostly what I care about. Now, I have some other profiles that muck with settings... like turning down the volume a little when the kids go to bed then turn it down even more when I sleep... My 'wake up' task that runs at 6am also turns the Sync profile on.... Which is cool since I knew that my gmail would update at every quarter of the hour... 00/15/30/45.

It just seemed like a lot of work and coordination. The Llama task I use now are a lot simpler, do the exact same thing and do it without as much overhead.

About Google's Location services... Man, do I wish you could configure how often that thing fires. As useful as the GLS/Google Now integration is, It is colossus of battery waste. I installed Secure Settings, which can actually toggle GLS, but it still has that damn verification screen that you need to dismiss when you enable it... if that didn't happen, I would probably toggle GLS wherever I toggle background sync.
 

garublador

Well-known member
May 20, 2013
1,135
0
0
Visit site
Yeah, I know, throwing it on the charger when I go to bed isn't a big deal.... but it is the principle of the thing. :) Plus, the less the phone uses when it sleeps, the more screen time I can get. I don't want my phone eating through a 1/3 or 1/2 of a full charge just sitting there at my desk while I am at work. It is an inefficiancy that I don't like. The only one that should be draining that battery is me basically.
One thing that's nice about charging while you're sleeping is if you use Tasker you can control profiles based on whether you're asleep or not. If I'm awake at 10pm I want full volume on my phone but if I'm asleep I want it to be quiet. I agree it's a good way to test your phone's battery performance while not being used, though. I just like pointing out that battery drain while you're sleeping is not in itself a problem.

Yeah... I should go through and step through to see which function saves the most battery. But I can tell you, from what I've seen in the past, by FAR... it is the background sync. Leaving that on is like an open invitation for any app to waddle up to the battery buffet and start feasting. There is a long line of ETs in that phone needing to phone home ALL THE TIME. I would like to know the battery drain from just leaving WiFi on even though it isn't connected... passively looking for a known AP....might not be all that much in the long run.
That's what I expected. I stopped messing with the WiFi when I realized I couldn't tell whether or not I was "optimizing" battery life by turning it on an off just by checking my battery at the end of the day. I leave it on now because I use some location based services (AutoLocation, it uses a lot less battery than Google Now), but in 4.3 there's an option to have it off except for when checking location.

That has two contexts; a repeating time context of every 15 minutes and state context of the display being off. I know I could use a timer in the Screen Off profile, but I read that for periodic tasks, it is better to use a repeating context rather than a timer as part of task, that is why I broke it out of the Screen Off profile.
The repeating time context is the puzzle piece I've been missing. I haven't used that before. Do you just have it set up to run from midnight to midnight or something along those lines with it repeating every 15 minutes?

About Google's Location services... Man, do I wish you could configure how often that thing fires. As useful as the GLS/Google Now integration is, It is colossus of battery waste. I installed Secure Settings, which can actually toggle GLS, but it still has that damn verification screen that you need to dismiss when you enable it... if that didn't happen, I would probably toggle GLS wherever I toggle background sync.
Yeah, it's a huge pain. It seems as if some things that use it can't be configured (Google Now being one of them) and then other things that use it will use locations that they get that come faster than their default. So if you have something that checks every 42 seconds (which is about how often I found Google Now checked my location) then everything that uses it will use those locations rather than polling themselves. It's an efficient way to do it in some respects becasue you can stack on a bunch of location functions with minimal impact on battery, but it also makes it super difficult to figure out how to make it check your location less often. You have to check everything individually and in every combination for a day or two each to see if it affects how many times your phone checks your location. I found that my AutoLocation geofences use almost no battery with Google Now on, but noticeably battery with Google Now off (but less than Google Now). They're also a bit less accurate with Google Now off. I have no idea how much battery location history takes because I turned it off before I turned off Google Now and it didn't make a difference. I haven't cared enough to turn it back on.

The ability to control how often each feature checks for location would be awesome, especially if it can be done in Tasker. According to what I've found, even checking every 2-5 minutes would give a significant savings over what Google Now does on it's own and you'd still get most of the functionality. I think this would be a much larger battery saver than toggling WiFi.
 

LeoRex

Retired Moderator
Nov 21, 2012
6,223
0
0
Visit site
The repeating time context is the puzzle piece I've been missing. I haven't used that before. Do you just have it set up to run from midnight to midnight or something along those lines with it repeating every 15 minutes?

Yep... that context is nice since the profile starts counting when enabled.... I used a 'time of day' profile to toggle the sync profile and I have it on from 6am to 10pm... so every 15 minutes, if the screen is off, it'll do a quick 30 second background sync then go back to sleep until the next window. Though, I've since set it so I only get audible notifications when my wife emails me.... but that's really the only emails that matter. ;)

So if you have something that checks every 42 seconds (which is about how often I found Google Now checked my location) then everything that uses it will use those locations rather than polling themselves.

I turned GLS on again 3 hours ago just to see how it did.. the nlpwakelock fired over 200 times! Didn't hit the battery too hard though. (1.0%/hr total over the last three hours WITH GLS on) Hmm... you know, they did announce that they GLS got some tweaks, even for those not on 4.3 (my stellar runs 4.1.2), intended to help ease some of the overhead... I haven't bothered with GLS since well before then. Maybe I can leave it on without it slaughtering my phone. Earlier in the year, the description next to the GLS check box might as well have been "Click here to chop your battery in half".

Google... security... whatever... take away that stupid opt-in pop-up on

I hope it works.... Google Now is such a killer app, I never liked giving it a location-based limp like I did. When I did give it a whirl, it impressed both me and my wife as we were driving down the HW with the runts.... She wondered if there was anything good going on and on a whim, I opened Now... scrolled down to look at the main cards and turned to her saying "Take the next exit, there's a children's festival a mile down the road..." That's a slick app.

You might want to give Llama a look though, I found that it would do most all of what I was trying to do in Tasker.
 

garublador

Well-known member
May 20, 2013
1,135
0
0
Visit site
You might want to give Llama a look though, I found that it would do most all of what I was trying to do in Tasker.
I haven't looked into it too much because nearly everything I've read suggests that it's way less powerful. I don't think I'd get any of my voice commands or inter-device communication like I get with Tasker. Right now I have a widget (three on top of one another, actually) that tells me the status of the battery in my tablet. It also gives me a persistent notification reminding me to charge the tablet if it gets too low that will only go away if the tablet is charging or above a certain level. I have a profile set up to remind me to text my wife (and gives me three boilerplate texts) if I'm at work late and the notification only goes away when I leave work. I'm working on a project to allow me to save my own locations and navigate to them by voice since that doesn't seem to be implemented in the latest version of Maps. I'm not sure how much of that can really be done in Llama. I'll take the battery performance hit if it means I get to keep all of this other stuff I've come up with.

Or are you suggesting running both? Have you found that if you let Llama run the WiFi and sync management you can still get the better performance even with Tasker running other profiles?
 

garublador

Well-known member
May 20, 2013
1,135
0
0
Visit site
For those interested, I also found an app called Synker:

https://forums.androidcentral.com/e...evelopers.android.synker&hl=en&token=Dog4iTLL

I haven't used it yet but it looks like it allows you to have a lot more control over what's syncing and when.
I set up a profile using this and it seems to work super well. Rather than trrning autosync on for 30 seconds every 15 minutes I can make it just sync my Gmail every 15 minutes and then do the less time critical synchs every hour or two. I can keep autosync off all the time that way.
 

LeoRex

Retired Moderator
Nov 21, 2012
6,223
0
0
Visit site
I set up a profile using this and it seems to work super well. Rather than trrning autosync on for 30 seconds every 15 minutes I can make it just sync my Gmail every 15 minutes and then do the less time critical synchs every hour or two. I can keep autosync off all the time that way.

Good find... the plugin works with Llama as well. That is exactly what I've wanted to do
 

kikorras

New member
Aug 29, 2012
1
0
0
Visit site
hi really interesting post. I am particularly interested aout the "formula" you have used in Llama to be able to configure how long the sync is on and the time between syncs when the screen is off. I would really appreciate if you could give me more detail on this as I cannot find how to do that.

I figured out how to turn off the auto-sync completely and also how to turn it on every x minutes (not sure how they interact betweenn each other)... but I cannot find how to keep the sync open for a number of seconds and then turn it back again. Help appreciated.
 

LeoRex

Retired Moderator
Nov 21, 2012
6,223
0
0
Visit site
)but I cannot find how to keep the sync open for a number of seconds and then turn it back again. Help appreciated.

It was all queued tasks with delays. Have the parent trigger when the screen goes off... Maybe a delay to start... Enable sync and force sync... Then queue a sub task to run 30s or so later to disable sync. Then have the main task set to repeat every 15 or so minutes until the user is present (I found that works better than triggering when the screen is turned on)

This will enable sync for 30s every 15 minutes.