Home > Android, Mobile > Pinpointing Android LocationManagerService Battery Drain

Pinpointing Android LocationManagerService Battery Drain

September 10th, 2012

Recently, I was seeing severe battery drain on my Samsung Galaxy SII. Using the most awesome BetterBatteryStats application I was able to see that my phone was not being able to go into deep sleep due to WakeLocks from the LocationManagerService. Android’s LocationManagerService, is responsible for managing LocationProviders and issues location updates and alerts. If applications are requesting location updates too frequently, the LocationManagerService may be forced to keep the phone awake to provide those updates.

It is possible using the dumpsys command via the adb shell to find out which applications are currently requesting location updates. For instance:

adb shell dumpsys > /path/to/dumpsys.txt

will collect the output of the dumpsys command run on the connected device into the specified file. Looking in the output from dumpsys the LocationManagerService dumps into a section


Within that section, there are a number of LocationListeners that look something like

Receiver{419e7ad0 Listener android.os.BinderProxy@41b8abd0}mUpdateRecords: {passive=UpdateRecord{421e75a0 mProvider: passive mUid: 10084}}:
UpdateRecord{421e75a0 mProvider: passive mUid: 10084}
mProvider=passive mReceiver=Receiver{419e7ad0 Listener android.os.BinderProxy@41b8abd0}mUpdateRecords: {passive=UpdateRecord{421e75a0 mProvider: passive mUid: 10084}}
mMinTime=0 mMinDistance=0.0
mProvider=network mTime=1346849822124
mLatitude=44.0836108 mLongitude=-92.5067299
mHasAltitude=false mAltitude=0.0
mHasSpeed=false mSpeed=0.0
mHasBearing=false mBearing=0.0
mHasAccuracy=true mAccuracy=20.0

This UpdateRecord is particularly bad because it is requesting constant updates:

mMinTime=0 mMinDistance=0.0

The mUid specifies the process identifier requesting the updates. The processes are dumped within the same output and can be found in the section beginning:

ACTIVITY MANAGER RUNNING PROCESSES (dumpsys activity processes)

Each application is listed separately by process identifier:

*APP* UID 10084 ProcessRecord{41af23e8 13037:com.google.android.apps.maps:LocationFriendService/10084}
dir=/data/app/com.google.android.apps.maps-1.apk publicDir=/data/app/com.google.android.apps.maps-1.apk data=/data/data/com.google.android.apps.maps
compat={240dpi always-compat}
thread=android.app.ApplicationThreadProxy@42457df0 curReceiver=null
pid=13037 starting=false lastPss=0
lastActivityTime=-6m23s226ms lruWeight=-50901 serviceb=false keeping=false hidden=true empty=true
oom: max=15 hidden=12 curRaw=12 setRaw=12 cur=12 set=12
curSchedGroup=1 setSchedGroup=1 systemNoUi=false trimMemoryLevel=0
hasShownUi=false pendingUiClean=false hasAboveClient=false
setIsForeground=false foregroundServices=false forcingToForeground=null
persistent=false removed=false
adjSeq=3891 lruSeq=535
lastWakeTime=0 time used=0
lastCpuTime=20 time used=+20ms
lastRequestedGc=-6m28s504ms lastLowMemory=-6m28s504ms reportLowMemory=false
conProviders={ContentProviderRecord{418add48 com.android.providers.settings.SettingsProvider}=1}
receivers=[ReceiverList{41a84148 13037 com.google.android.apps.maps:LocationFriendService/10084 remote:41a83f70}]

With this information we have our culprit. Process identifier 10084 is Google’s LocationFriendService (Latitude). This process is requesting constant location updates and causing severe battery drain. In this particular case, I was able to go through the Latitude settings and disable everything related to location updates. With those settings disabled and a quick restart, my battery drain went back to normal again. Hopefully this information may be helpful to others having battery drain issues related to location updated.

Categories: Android, Mobile Tags:
Comments are closed.