“Android OS” draining battery

Just recently I’ve been having incredibly poor battery performance from my Galaxy S2. For the last few weeks I’ve attributed it to lots of data traffic, all of which was rolling up under the OS. It was only after spending a week abroad on a business trip, turning off the Data Network and not using the phone, still only to get less than 7 hours life that I thought to look into it more.

The first thing to do is check the stock Android “battery” statistics, this will help you identify and specific applications that are eating power. If there’s anything obvious that has a high percentage of drain, think about the application’s settings or whether you need/want the app.

If this doesn’t help and your issues are anything like mine, “Android OS” was taking up about 70% of the consumption (always the biggest). Before I explain how I fixed mine, here’s a little explanation on the 3 “main” power states on Android: –

  • Screen On: Pretty obvious – the screen is active and on; you’re using the phone.
  • Awake: The screen is off. You’re not actively using the phone but an app has “partially” woken the phone to perform a background task.
  • Deep Sleep: The state you’re striving for; the screen is off and the phone isn’t doing anything in the background.

The method an application uses to wake up the phone is called an Alarm. Applications can use the Android’s “AlarmManager” to register when the phone should be woken and a task should be performed in the background. As the AlarmManager is actually running the background process of the application, and the AlarmManager is part of the Android OS, it’s the OS that registers as consuming the battery.

I actually used this the BetterBatteryStats app to get this far, it identified that the AlarmManager was the process that was keeping the phone “Awake” for about 4 hours a day.

The next step isn’t as easy unless you have a rooted phone. The app needs root permissions to list the actual processes that are registered with the AlarmManager; it’s these we need to get at, identify and resolve. If you do have a rooted phone, visit the “Alarms” area of BetterBatteryStats to find them.

If you don’t have a rooted phone, you’ll need to install the Android SDK on a PC and a USB cable. I used this blog post to help me get it configured on Linux

Once it’s installed and configured, you can issue the following command from a DOS/Shell prompt after the phone’s plugged in to create a text file in the current working directory.

adb shell dumpsys alarm > Alarm.txt

Open up the newly generated file and jump straight to the bottom. You’ll see something like this (I’ve removed most of my trace).

Alarm Stats:
 com.levelup.beautifulwidgets
 5356460ms running, 2 wakeups
 2 alarms: act=com.levelup.beautifulwidgets.ACTION_UPDATEWEATHER flg=0x14
 1819 alarms: act=com.levelup.beautifulwidgets.ACTION_REFRESHTIME flg=0x14
 com.zegoggles.smssync
 11ms running, 2 wakeups
 2 alarms: flg=0x4 cmp=com.zegoggles.smssync/.SmsBackupService
 com.google.android.apps.plus
 705917ms running, 733 wakeups
 59 alarms: act=com.google.android.apps.plus.content.cleanup flg=0x4 cmp=com.google.android.apps.plus/.service.EsService
 69 alarms: act=com.google.android.apps.plus.content.sync flg=0x4 cmp=com.google.android.apps.plus/.service.EsService
 605 alarms: act=com.google.android.apps.plus.NEW_PICTURE flg=0x14
 com.android.vending
 140ms running, 7 wakeups
 4 alarms: flg=0x4 cmp=com.android.vending/com.google.android.finsky.services.DailyHygiene
 3 alarms: flg=0x4 cmp=com.android.vending/com.google.android.finsky.services.ContentSyncService
 com.rememberthemilk.MobileRTM
 10290ms running, 3 wakeups
 1 alarms: act=com.rememberthemilk.MobileRTM.DATE_CHANGED flg=0x14
 1 alarms: act=com.rememberthemilk.MobileRTM.SCAN_PROXIMITY flg=0x14
 1 alarms: act=com.rememberthemilk.MobileRTM.TASK_ALERT dat=content:261021728 typ=com.rememberthemilk.alert/task flg=0x14

I’ve highlighted four packages to give you an example of what to look for: –

  • com.android.vending: An example of no problem. The process has only been run 7 times (wakeup) and in total has only run for 140ms. This isn’t going to be causing any battery issues
  • com.rememberthemilk.MobileRTM: 3 wakeup events and spent just over 10 seconds processing, no problems here, 10 minuets won’t be draining much battery!
  • com.google.android.apps.plus: 733 wakeups which have cause the phone to be “Awake” for 705 seconds. 10 minutes of the phone being active and (most likely) using network connections is going to contribute to battery drain. If you have several applications that look like this, it can quickly total up to a few hours of processing time. This is what you’re looking for. High number of wakeups and running time.
  • com.levelup.beautifulwidgets: The last thing to look out for is “stuck” events. This widget only has 2 wakeup events but has been running for 5356 seconds (155 minuets). This might be nothing, but it could be an app that’s stuck somehow; keeping the phone awake.

When you’ve identified applications that are causing the phone to be awake for large period of time, try checking their settings, see if you can reduce any “refreshing” or scheduling they have. For a few of mine, I couldn’t resolve them. I just had to remove the app, wait a day, rinse-and-repeat the analysis.

After a few days or doing this, my battery life has gone from 7 hours to a good 15 with normal usage. The culprets I identified were: –

  • The official Facebook app – it was causing hours of Awake time just in itself. I couldn’t stop it with any settings so I removed it and replaced with FriendCaster.
  • GroupOn – never used it so just removed
  • GO SMS Pro – This had hours of processing with hundreds of wakeup events, I couldn’t improve with any settings so just removed.
  • Google Shopper – Never used it so just removed.
  • FancyWidgets – The weather refreshing was activating location aware processes – lots of battery drain so just removed.
  • Remember the Milk – turned off the auto syncing and replaced with a manual schedule

2 comments on ““Android OS” draining battery

Leave a Reply