NlpWakeLock and NlpCollectorWakeLock Discussion

Search This thread

DoesntPostAThing

Senior Member
Nov 18, 2012
2,080
1,516
Vancouver
Firstly, this is not another thread to complain about your horrible battery life due to Google Play Services. I'm tired of those (mostly on Reddit, but some here too. Either way, none of that here :) ). This is instead to try and find a root cause for it. "It's Google's fault" is not good enough for me, and if you truly care about your battery life it shouldn't be for you either. If all you're after is an easy way out to get your battery life back, then this thread is not for you. We're here to reach a solution where you can get location services and good battery life. I've done if before, on my Galaxy Nexus on 4.3, but it seems that something is wrong in KitKat. Let this be a place where we all dig deeper into this issue, perform tests, gather results, and then share and discuss them. Here's what I've got so far:

The wakelocks that cause this battery drain are NlpWakeLock and NlpCollectorWakeLock. Nlp stands for network location provider. As you may know, Android provides developers with two ways of gathering location information. One is through the GPS_PROVIDER, which uses the GPS, and the other is through NETWORK_PROVIDER, which uses cell towers and WiFi APs to get your position. According to their developer website[1] , NETWORK_PROVIDER uses less battery, is faster, but is less accurate. GPS uses more battery, takes longer, but is good if you want an accurate location. I'm assuming this particular wakelock uses NETWORK_PROVIDER.

I also did some digging using ROM Toolbox Pro's autostart manager. My guess was that Google Play Services must be triggered every time a certain intent is broadcasted, since nothing obvious is telling it to run. Turns out there are quite a few. 30, to be exact. However, many of them have to do with GCM and we don't really care about those. One of particular interest is one called com.google.android.location.internal.NlpNetworkProviderSettingsUpdateReceiver. It listens for the intent android.location.PROVIDERS_CHANGED. The LocationManager API's documentation[2] tells us this:

Broadcast intent action when the configured location providers change. For use with isProviderEnabled(String). If you're interacting with the LOCATION_MODE API, use MODE_CHANGED_ACTION instead.

I'd assume that this means when you change your location providers, such as enabling/disabling data, WiFi, GPS, etc.

However, location reporting only seems to use network location. If you're on KitKat, go to the location settings and choose device only. Then choose battery saving. It asks you to accept location reporting. Same thing when you choose high accuracy. What do both of those have in common? Network location. You can switch between those two as much as you want and it won't ask you to accept again. However, once you switch to device only and back it will ask you. This shows that it only uses network location.

I find that Google (Play) Services has 5% (+/- 1%) keep awake. Tested on both Nexus 5 running KRT16M and Galaxy Nexus running JWR66V. Both use a certain time of GPS, although that number is never increasing. I assume this is some sort of initial one-time lock. It can be disregarded.

One more thing I noticed is that this Google Play Services issue is much more prominent on KitKat. While they have happened before, often times a simple Play Store update would fix it. This time it seems to be location based. Guess what changed in KitKat? The way you deal with location settings. It may be that the way location settings are grouped in KitKat cause that intent to keep firing, and that in turn triggers something that eventually ends up being what you see as NlpWakeLock.

What I'm going to try next is disabling that intent receiver and then monitor that wakelock as well as if location reporting still works. Feel free to play around, and be sure to share your results.

To those who are suffering from these wakelocks, could you please share your settings? Such as what type of location mode you have (high accuracy, battery saving, device only), WiFi on or off, data on or off, signal strength, WiFi always scanning, Play Store and Play Services version, what device you have, Android build number, and what ROM/kernel you're using if you are using one? Any other info such as screenshots of battery screen, betterbatterystats, wakelock detectors, etc. will all be welcomed.

Here is the Reddit thread I created discussing the same issue: http://www.reddit.com/r/Android/comments/1rvmlr/nlpwakelock_and_nlpcollectorwakelock_discussion/
 
Last edited:

a senile fungus

Senior Member
May 25, 2010
1,402
606
I don't have this device, nor do I know if I'll be getting it, but I must say that I applaud your method.

Bravo!
 

stumpy352

Senior Member
Sep 20, 2011
2,000
1,267
I just turn location reporting off then select 'battery saving' setting & accept the request for reporting when it pops up. This allows you to use network location without logging. Google now & maps work fine although not quite as accurate. I just turn on gps if i need navigation. Never get more than 2% usage from play services & it's giving me a total kept awake time of about 28mins out of 12hrs of use with 3hrs screen on time.

Sent from my Nexus 5 using Tapatalk
 

tylerdurden83

Senior Member
May 28, 2011
1,196
227
If I disable the wifi and 3g, leave my phone on battery saving location, google location set to on, it is using wifi always scanning only and it didnt consume 1% battery in a whole night
 

HB_Mosh

Senior Member
Jun 8, 2012
133
9
Bogota
I just turn location reporting off then select 'battery saving' setting & accept the request for reporting when it pops up. This allows you to use network location without logging. Google now & maps work fine although not quite as accurate. I just turn on gps if i need navigation. Never get more than 2% usage from play services & it's giving me a total kept awake time of about 28mins out of 12hrs of use with 3hrs screen on time.

Sent from my Nexus 5 using Tapatalk

That is working for me right now.

Sent from my Nexus 5 using Tapatalk 2
 

iammuze

Senior Member
Jul 10, 2008
136
178
To those who are suffering from these wakelocks, could you please share your settings? Such as what type of location mode you have (high accuracy, battery saving, device only), WiFi on or off, data on or off, signal strength, WiFi always scanning, Play Store and Play Services version, what device you have, Android build number, and what ROM/kernel you're using if you are using one? Any other info such as screenshots of battery screen, betterbatterystats, wakelock detectors, etc. will all be welcomed.

I am experiencing this issue on my Nexus 5, as confirmed by betterbatterystats (NlpCollectorWakelock 5.5% awake time)

ROM: CyanogenMod 11 alpha

Build Number: KRT16S

Location Mode: High accuracy

Location Reporting: Off

WiFi On: Sometimes

Play Store Version: 4.4.22

Play Services Version: 4.0.34


This issue first appeared for me the other day. I noticed that my device was not appearing in the online Android Device Manager, nor the desktop version of the Play Store. To fix the ADM issue, I disabled remote wipe, cleared data for Play Services, reenabled remote wipe, and rebooted. To fix my device not appearing in the Play Store, I cleared data for the Play Store app. Both issues were thereafter resolved, but now I am experiencing the Network Location battery drain.

Is it possible the problem is related to requests from Android Device Manager? I was under the impression that location for that purpose was 'on demand' instead of logged, but what do I know.

Thanks for doing this! Others, please feel free to use my comment as a template, and post your own data.
 

DoesntPostAThing

Senior Member
Nov 18, 2012
2,080
1,516
Vancouver
So I was playing around with autostart, and I accidentally caused a bunch of FCs for Play Services. Ended up freezing/defrosting and then uninstalling updates then let it update itself, and I noticed this (may or may not have anything to do with what I did): Even though it wakelocks, it barely uses up any batter. I was in an area of 2-3 bar HSPA+, with sync on, location reporting on at high accuracy, etc. and it drained 1% per hour. Still kept phone awake ~5% of the time, but battery usage was significantly better over what I recorded to be 4.8%/hour from last Friday.

EDIT: The only other change I can think of making is temporarily freezing Cerberus. I'll have to look more into that. However, check which apps are requesting your location. The new location settings in KitKat make this simple enough. For me it's only Google Now and Google Play Services, and whatever app that happens to require GPS such as camera (geotagging) and maps.
 
Last edited:

natezire71

Senior Member
Mar 24, 2010
1,489
339
So I was playing around with autostart, and I accidentally caused a bunch of FCs for Play Services. Ended up freezing/defrosting and then uninstalling updates then let it update itself, and I noticed this (may or may not have anything to do with what I did): Even though it wakelocks, it barely uses up any batter. I was in an area of 2-3 bar HSPA+, with sync on, location reporting on at high accuracy, etc. and it drained 1% per hour. Still kept phone awake ~5% of the time, but battery usage was significantly better over what I recorded to be 4.8%/hour from last Friday.

So, how should I replicate this? I'm using the Xposed Module that dev posted in your Reddit post.
 

the7thson

Senior Member
Sep 20, 2008
556
69
Denver, CO
I just turn location reporting off then select 'battery saving' setting & accept the request for reporting when it pops up. This allows you to use network location without logging. Google now & maps work fine although not quite as accurate. I just turn on gps if i need navigation. Never get more than 2% usage from play services & it's giving me a total kept awake time of about 28mins out of 12hrs of use with 3hrs screen on time.

Sent from my Nexus 5 using Tapatalk

How do you do this exactly? If I turn location reporting off, then I can't select the battery saving method because it's greyed out. This also causes location based cards to stop working on Google Now and Maps can't locate me either.

---------- Post added at 11:24 PM ---------- Previous post was at 11:19 PM ----------

So, how should I replicate this? I'm using the Xposed Module that dev posted in your Reddit post.

Use Titanium Backup to FIRST backup Google Play Services. Then use it to uninstall GooglePlay Services. Then open Google Now or Maps, they will ask you install Google Play Services and take you to the app store.

If anything goes wrong, use Titanium to restore.
 
  • Like
Reactions: DoesntPostAThing

stumpy352

Senior Member
Sep 20, 2011
2,000
1,267
You need location toggled on. Go down to location services & click on Google Location Reporting. Select off for both settings. Then go back out & select battery saving mode & accept the terms.

Sent from my Nexus 5 using Tapatalk
 
  • Like
Reactions: the7thson

the7thson

Senior Member
Sep 20, 2008
556
69
Denver, CO
You need location toggled on. Go down to location services & click on Google Location Reporting. Select off for both settings. Then go back out & select battery saving mode & accept the terms.

Sent from my Nexus 5 using Tapatalk

Turns out that's exactly how I had set up after all, doh! Thank you.
I have actually been getting really decent battery life, noticeably better than my HTC One, with exactly similar usage patterns and same apps installed etc.
 

stumpy352

Senior Member
Sep 20, 2011
2,000
1,267
Also, Play Services is not the only app that uses this NlpWakeLock. Facebook also uses it & in my case has the highest time kept awake. I turned off location in chat & noticed that it is much better.

Sent from my Nexus 5 using Tapatalk
 
  • Like
Reactions: DoesntPostAThing

DoesntPostAThing

Senior Member
Nov 18, 2012
2,080
1,516
Vancouver
No, not using xposed. I understand that wake locks must occur for accurate location services (otherwise what is doing the reporting). What shouldn't be there is the incredible battery drain. Wake locks don't necessarily mean battery drain. You could have a 1h wake lock and drain 1% battery, or a 5 min wake lock that keeps CPU on high frequency causing a 10% battery drain. I don't mind wake locks as long as battery isn't affected too much.

Sent from my Nexus 5
 
Last edited:

natezire71

Senior Member
Mar 24, 2010
1,489
339
No, not using xposed. I understand that wake locks must occur for accurate location services (otherwise what is doing the reporting). What shouldn't be there is the incredible battery drain. Wake locks don't necessarily mean battery drain. You could have a 1h wake lock and drain 1% battery, or a 5 min wake lock that keeps CPU on high frequency causing a 10% battery drain. I don't mind wake locks as long as battery isn't affected too much.

Sent from my Nexus 5

That was the point of this module. https://play.google.com/store/apps/details?id=in.andro.wlt. Take a look and read the description. From my understanding, the location stuff still works--which for me has been the case. However, it stops the unnecessary wakelocks. I would like to believe my battery has improved.
 

sacapo

Senior Member
Apr 5, 2006
114
6
Nice thread!!

I've changed my location settings and I'll report if it works!!!

Thanks!!!
 

the7thson

Senior Member
Sep 20, 2008
556
69
Denver, CO

Top Liked Posts

  • There are no posts matching your filters.
  • 31
    Firstly, this is not another thread to complain about your horrible battery life due to Google Play Services. I'm tired of those (mostly on Reddit, but some here too. Either way, none of that here :) ). This is instead to try and find a root cause for it. "It's Google's fault" is not good enough for me, and if you truly care about your battery life it shouldn't be for you either. If all you're after is an easy way out to get your battery life back, then this thread is not for you. We're here to reach a solution where you can get location services and good battery life. I've done if before, on my Galaxy Nexus on 4.3, but it seems that something is wrong in KitKat. Let this be a place where we all dig deeper into this issue, perform tests, gather results, and then share and discuss them. Here's what I've got so far:

    The wakelocks that cause this battery drain are NlpWakeLock and NlpCollectorWakeLock. Nlp stands for network location provider. As you may know, Android provides developers with two ways of gathering location information. One is through the GPS_PROVIDER, which uses the GPS, and the other is through NETWORK_PROVIDER, which uses cell towers and WiFi APs to get your position. According to their developer website[1] , NETWORK_PROVIDER uses less battery, is faster, but is less accurate. GPS uses more battery, takes longer, but is good if you want an accurate location. I'm assuming this particular wakelock uses NETWORK_PROVIDER.

    I also did some digging using ROM Toolbox Pro's autostart manager. My guess was that Google Play Services must be triggered every time a certain intent is broadcasted, since nothing obvious is telling it to run. Turns out there are quite a few. 30, to be exact. However, many of them have to do with GCM and we don't really care about those. One of particular interest is one called com.google.android.location.internal.NlpNetworkProviderSettingsUpdateReceiver. It listens for the intent android.location.PROVIDERS_CHANGED. The LocationManager API's documentation[2] tells us this:

    Broadcast intent action when the configured location providers change. For use with isProviderEnabled(String). If you're interacting with the LOCATION_MODE API, use MODE_CHANGED_ACTION instead.

    I'd assume that this means when you change your location providers, such as enabling/disabling data, WiFi, GPS, etc.

    However, location reporting only seems to use network location. If you're on KitKat, go to the location settings and choose device only. Then choose battery saving. It asks you to accept location reporting. Same thing when you choose high accuracy. What do both of those have in common? Network location. You can switch between those two as much as you want and it won't ask you to accept again. However, once you switch to device only and back it will ask you. This shows that it only uses network location.

    I find that Google (Play) Services has 5% (+/- 1%) keep awake. Tested on both Nexus 5 running KRT16M and Galaxy Nexus running JWR66V. Both use a certain time of GPS, although that number is never increasing. I assume this is some sort of initial one-time lock. It can be disregarded.

    One more thing I noticed is that this Google Play Services issue is much more prominent on KitKat. While they have happened before, often times a simple Play Store update would fix it. This time it seems to be location based. Guess what changed in KitKat? The way you deal with location settings. It may be that the way location settings are grouped in KitKat cause that intent to keep firing, and that in turn triggers something that eventually ends up being what you see as NlpWakeLock.

    What I'm going to try next is disabling that intent receiver and then monitor that wakelock as well as if location reporting still works. Feel free to play around, and be sure to share your results.

    To those who are suffering from these wakelocks, could you please share your settings? Such as what type of location mode you have (high accuracy, battery saving, device only), WiFi on or off, data on or off, signal strength, WiFi always scanning, Play Store and Play Services version, what device you have, Android build number, and what ROM/kernel you're using if you are using one? Any other info such as screenshots of battery screen, betterbatterystats, wakelock detectors, etc. will all be welcomed.

    Here is the Reddit thread I created discussing the same issue: http://www.reddit.com/r/Android/comments/1rvmlr/nlpwakelock_and_nlpcollectorwakelock_discussion/
    17
    Hi

    The battery drain caused by these wake-ups and wake-locks are all to do with Google Location services. Specifically when Wi-Fi location services are enabled, in Kit-Kat terms this is High Accuracy and (ironically) Battery Saving modes. GPS is considered a high battery user, but it may not be the worse offender.

    When we agree to use Googles Wi-Fi database we agree to send data to Google. This enables the following back ground tasks:

    1) Building and updating Googles Wi-Fi database when High Accuracy is selected. Background services will wake the phone, look for Wi-Fi access points nearby, then fire up the GPS to get a precise location, and send that data back to Google, Google uses this to identify Wi-Fi access points and their locations to continually update it's database. They don't drive around in cars any more to collect this data. I'm not sure anyone knows the schedule for this, and it seems sometimes this happens a lot, other times this activity dies away. Perhaps the more we use the Wi-Fi database lookup for locations, the more Google will use our phone later for keeping that database up to date. No such thing as a free lunch.

    2) Google doesn't just collect data as to where we are, but it also collects data about how we get to where we are. Some of us will have seen cards in Google Now telling us how much we cycled, ran or walked. In order to work this out, our phones must wake regularly (every n seconds) to do a location lookup to work out the distance we travelled and so the speed we are travelling at. From our location and average speed Google decides if we are walking, jogging, or in a car or train. No doubt there is some attempt at backing off these wake-ups to save battery power, for example if the phone hasn't moved in several hours it will sample less often. Note it doesn't seem to matter if you consume this data, e.g. someone doesn't use Google Now, Google are still gathering and recording this data for their marketing purposes and data mining.

    3) Traffic. When Google works out we are travelling by road Google will ramp up sampling rates. Google will gather location data from us, again whether we use that data ourselves or not, to work out congestion and hold-ups on the road and then offer those using Google navigate new routes to avoid problems and hold ups. All of us with an Android device are GPS trackers for Google traffic services.

    It has not always been like this, it is only recently Google has ramped up the collection of location data. Google suggest their location framework will use on average no more than 1% of battery power an hour, over 24 hours that is almost a quarter, it adds up. If reception is not good then the constant chatter of data back to Google services could see the phone using a lot more.

    The problem with all 3 above is the usage isn't always predictable. So messing around with a few settings might see an improvement for a while, but generally these wake-locks just come back.

    The only way to stop these wake-locks is to turn off location services, either completely or just use GPS mode.

    This is why using GPS only can now save battery. Modern GPS chips use less power and lock-on quicker, often working in some buildings as well, and avoids having Google use our phones as location trackers.

    Regards

    Phil
    11
    Hi

    found this and it's about wakelocks so yeah http://xdaforums.com/showthread.php?t=1827676 thought it might help us understand and have a unified answer on how to maximize our battery lives

    Wake-locks are misunderstood unfortunately which can lead to a dead end.

    Many apps can show tens or hundreds of wake locks but they haven't caused any battery drain. An app can only have a wake-lock if the phone is already awake. A wake-lock just says, "Hey phone, I'm busy doing something which if you went to sleep now it might cause a problem". For example saving something to a file or downloading/uploading some data which would become corrupt if the phone just went into deep sleep. Many times these wake-locks are taken then released in milliseconds and we were using the phone anyway. Many wake-locks are taken and released because we have turned on the phone to do something with it.

    Wake-locks may cause battery drain when an app is badly programmed, for example an app takes a wake-lock but fails to release it. The phone then stays awake, although the screen will go blank and look off, the phone is on and not in sleep mode. The phone then runs down much more quickly over the course of a day or hours because it is actually constantly on. Typically apps are well behaved these days and release the wake lock correctly.

    The NlpWakeLock and NlpCollectorWakeLocks are a symptom but not the cause. The cause is location code that runs in Google Play Services that uses the AlarmManager in Android to constantly turn the phone on every few seconds to get a location update. The AlarmManager uses a real-time clock separate from the main CPU and can be told to wake the phone up from deep sleep at X time or every X seconds. Essentially this wake-up is the same as us pressing the power button, except the wake-up keeps the screen off as Android knows it wasn't a user initiated wake-up.

    When this alarm runs, the phone wakes up (but screen stays off so we are unaware this is happening), Google Play Services location code gets a message to say "Hey, this is your wake-up call", at that point Google code knows it is time to do a location check. In order to keep the phone awake while this check takes place and data is exchanged with Google services, the NlpWakeLock and NlpCollectorWakeLocks are taken, a location fix is obtained, Google Play Services then sets another alarm for a some seconds later and releases the wake locks. The phone immediately sleeps again, maybe after only a second or so, but is then woken not many seconds later for another location check, and so it goes on.

    The problem is the frequency of wake-ups, ideally our phones should sleep and never wake up unless we receive a phone call or text message or turn the phone on to use it. Each time the phone wakes up power is drawn for the CPU to run, and power is also used in the action of transmitting data back to the Google mother-ship and reading from other sensors, and when this happens every few seconds it soon depletes the battery.

    There is no bug here. It is all by design. Google needs to get frequent location updates to find out if we are moving and how fast, it can then offer us things related to that, for example how far we might have cycled or walked, or gather info regarding traffic congestion. The end goal is marketing to us based on our activity and location. To do this needs a high sampling rate. Prior to Google working out our current activity which is a fairly new thing, they were just concerned with our location, and typically just fired the phone up every 10 minutes or so to get a location and we didn't notice the power drain as it didn't amount to much.

    Google are collecting this activity data whether we use it or not, and that collection is enabled when we Agree to the terms and conditions seen when turning on location services.

    I guess the other plan with always collecting this data is to make us accustomed to poorer battery life and it becomes the norm for us. This way Google can come out with some new nifty marketing thing based on our activity and location to raise their profits and tell us it will use no more battery power. Apps like Tasker can sell on the basis of being battery friendly because they use the Google location data for things like Geofencing, and as for most people Google location code is already on and draining the battery will see no extra usage.

    The answer is simple, we either all boycott Google until they give us better control over this so we can opt not to share this activity data, but still get the benefit of Wi-Fi location services (unlikely to happen), or we just turn location services off or use GPS only.

    Google have nothing to fix, this is all by design.

    Regards

    Phil
    9
    Okay boys and girls, here's the solution to these freaking wakelocks that keep raping our N5s battery. I've tried different approaches but nothing seemed to do the trick. I got as frustrated as you guys when turning of location reporting and history didn't help anything.

    So what I did was:
    1. Download Xposed Framework.
    2. Download Wakelock Terminator (https://play.google.com/store/apps/details?id=in.andro.wlt).
    3. Install both, reboot the required times and activate the module.
    4. Open Wakelock Terminator and scroll down to Google Play Services, hit it and select "Prevent Wake Lock"
    5. Hit "Filter Wake Lock" and enter the lines in this image (sorry for the large size):
    FkFtS1V.jpg

    Hit "OK"

    Think you're done? So did I, but guess again, this does not prevent the wakelock.. yet.
    6. Go into Location in settings in Android.
    7. Disable Location Reporting and Location History.

    There this takes care of the NlpWakeLock and other associated wakelocks.

    As @msgfromside3 said another wakelock is triggered by this "EntriesRefresh_wakelock". The good news is that the same trick can be used to suppress this wakelock. The only hickup is that in order to supress more than one app in Wakelock Terminator you have to pay for it (around $4). On the other hand: Why not support a developer that has greatly enhanced your battery (or made it like Google should have done) ;)

    1. When you have made the in-app purchase go to Google Search in Wakelock Terminator.
    2. Same as above only this time type in the following:
    EntriesRefresh_wakelock
    AudioIn
    NlpWakeLock

    Yeah I know NlpWakeLock again, but trust me, just do it ;)

    There you go, now enjoy the Deep Sleep and much cooler phone :D

    As a side note: This does not prevent the wakelocks from ever happening they will still be present, but instead of taking up hours a day we're down to a couple of minutes.

    Sorry for the long post, here's a potato:
    baked-potato.jpg
    6
    I've tried solution which @sherdog16 gave us and I figured out that just denying wake up and keep awake in App Ops for Google Play Services(not Google now) helps with wakelocks!
    Here is how it looks like:
    uploadfromtaptalk1401796566658.jpg

    I'm using Mahdi ROM which has App Ops build in to the ROM. This method doesn't affect acquiring location by any other app. Google Now shows weather for my location etc.

    Here is also screenshot how it looks like in BBS:
    uploadfromtaptalk1401796907568.jpg

    Hope it will help!

    BTW. Any one tried 4.4.3 update? Is the issue also there?