How does Doze/Standby feature affect location updates?
Asked Answered
C

3

22

Does anyone know if a whitelisted app that is holding a partial wake-lock can receive location updates while the device is in Doze or the app is in Standby?

The Android docs (http://developer.android.com/training/monitoring-device-state/doze-standby.html) only state that CPU and network are deferred and do not mention any affect on location updates (i.e. from the LocationManager). Based on this, it would seem that location updates are not affected by Doze/Standby, so if an app is holding a partial wake-lock (to keep the CPU running) then the app should be able to receive location updates.

I've implemented this and tested it and found that an app does not appear to receive location updates in Doze even though it has a partial wake-lock and is whitelisted. Interestingly, when I left the device on my desk overnight running the app with the wake-lock, the battery was nearly empty in the morning, but when repeating with the app without the wake-lock, the battery was nearly full in the morning. So it does appear that the app was running the whole time, but was not receiving location updates.

A little extra background: The app is used for fleet tracking, so we're trying to figure out if there is anyway for an app to have a background service running that reliably receives location updates when running on battery power.

Thanks! -Tom B.

Creighton answered 24/10, 2015 at 16:45 Comment(3)
Please check this answer.Pyrimidine
How did you request whitelisting?Allseed
having the same problem, service definetely running, location (even lastknown) not workingDipody
S
4

Yes, this seems to be another undocumented restriction in Doze mode, as my test logs also show. My guess was that some hardware features like GPS are generally turned off in Doze, but maybe it's the LocationManager being disabled altogether.

As this might just be a severe lack of documentation, the battery drain you mention should definitely not happen in Doze, as that's exactly what Doze is meaning to prevent in the first place.

You may want to file a bug report about all this at https://code.google.com/p/android/issues/list

Samara answered 28/10, 2015 at 21:25 Comment(0)
L
2

For getting location updates when phone is in idle mode, app should be whitelisted, had partial wake-lock and also should not be on the same locatoin (if you are in the same location you don't need updates). I tested this with Mock Locations, which was giving fake location while phone was on my desk.

Luzon answered 3/1, 2017 at 18:43 Comment(2)
Does "Mock Locations" app work in Doze mode? I mean, as you said, device should be in a different location such that the location updates fire. So with mock locations, you need an app like "Mock Locations" which changes device location, but the app has to work in Doze mode tooSummertree
No it's not working in Doze mode. For working in Doze mode app should show you dialog in which ask you to put it on whiteliste and "Mock Locations" doesn't ask you for that.Boating
A
1

In my experience location updates are still received when in Doze but only when you use a foreground notification together with the methods you described. Network calls don't work.

Be aware of some stackoverflow posts indicating to just use the permission REQUEST_IGNORE_BATTERY_OPTIMIZATIONS. Your app will be rejected from the play store when you define this permission in your manifest due to "device & network abuse" https://play.google.com/about/privacy-security/device-network-abuse/.

There's also a way to manually request this permission with an intent. I don't know if it's also prohibited that way. The whole whitelisting principle is a little vague to me.

Allseed answered 21/6, 2016 at 19:43 Comment(1)
I dont get any location updates in DOZE Mode with Android 8 Samsung Devices. a Foreground Services doesnt helps i used this example github.com/xamarin/monodroid-samples/tree/master/android-o/…Peerless

© 2022 - 2024 — McMap. All rights reserved.