[Nexus 5 General] PhilipL:
Hi

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