QUESTION: Can gpslogger log all and only "background" location updates provided by Android?
Please excuse the woolly terminology :)
I want to use gpslogger to track the location of my device constantly. This doesn't have to be on a fixed interval, but in the similar interval that say Google Timeline does.
My understanding (via Home Assistant here) is that Android can provide a passive location in the background to apps that require it. It can be made to run with "High Accuracy" on demand, but otherwise is a bit lazy (in the sense that client apps get it "for free"). I think the relevant API is here https://developers.google.com/location-context/fused-location-provider (I'm hoping there's a non-Google "pure" Android alternative for this API).
Is it possible to set gpslogger to listen to these updates? As above, I'm not necessarily interested in an update "every x second", but would like "every new background location update provided by the OS".
What I would like to avoid are duplicate entries (if the background location hasn't changed) or for gpslogger to force Android to run a higher accuracy just by running all the time.
There is a passive location listener in GPSLogger, the way that works is if some other app requests a location update, GPSLogger will get it for free. It should be possible to just have the passive location listener setting and get that to log/send locations. This app doesn't make direct use of the fused location provider, because the library that provides that is closed source, so it's not allowed in F-Droid.
Best would be to try it for a few hours with just passive, but network/GPS disabled, and see what you get.
I'm not sure you'll be able to avoid duplicate entries though, that's very circumstantial. By that I mean, sometimes you'll have noticed you open a map and it shows your cached location from minutes or hours ago, and after a moment it shows the real location. So that cached location could show up as a passive location.
That's great to hear. My confusion then lies in the logging interval. How does that relate to passive updates? Say it's set to 60s:
- If other apps update faster than 60s, will gpslogger ignore those?
- If other apps update slower than 60s, will gps logger log the last value again?
- Or will gpslogger ignore that 60s and just log as fast or as slow as the updates come?
For greater context, I'm trying to rolly own google timeline, so want to emulate the resolution found there as closely as possible, which seems to be at the right point. I also have home assistant logging values, and have set that up to increase more frequently (say while driving).
I just want gps logger to "watch" those events.
I did some testing and it seems that the answer is indeed 3, and so the logging interval is ignored (or rather not relevant) for passive logging.
Fwiw I turned on the network logging and the timer kicked in. It might be worth documenting this - or even moving the time interval config up closer to the two sources that use it?
Yeah currently in passive logging the interval is ignored.
There's a change coming up in v134 (no ETA) which will introduce an interval for passive logging.
Yeah I think I could move the passing logging time closer to passive logging.
That's interesting - I didn't think a time interval for passive logging actually made sense. I'd be interested in seeing what it did.
I had the passive logging running for most of the day alongside the Home Assistant app (which also logs location of a sort). It seems that HA was getting a fair few more updates than gpslogger. I'm not sure if that's a bug in the passive listening, or that something else had broken - the logs are a little strange in that I few of:
T1: Filename: xxx
T1: Started
T2: Filename: xxx
T3: Started
Stopping and starting it seems to have made it better.
Some further observations:
- There definitely seems to be a power/app management issue. With the phone plugged in, all passive events are detected, with it not, some are missed and I often see a spinning circle in the top right hand corner (of the log screen).
- On a 3 minute interval (ie with GPS), I do not see the same issue, and an update is sent at least once per interval (although even then the log isn't "regular" with a few "Filename" lines per interval).
- The "passive" updates that HA receives are independent to the updates that gps logger receives. In that sense it seems that the Fused API is a bit of a black box.
Given the above, I'll probably stick to low frequency updates, and use Tasker or some such to bump up the interval as needed (eg when driving), and eventually disable the HA location tracking and have GPS logger push them directly.
Yeah that could work. If you're looking for a way to switch settings you can also have a look at the 'profiles' feature - https://gpslogger.app/#whatareprofiles - you basically give it a name and it will save values under that name. You can also use stuff like Llama/Tasker to switch profiles.
The UI is bit unintuitive, not much I could do there.
That's interesting - I didn't think a time interval for passive logging actually made sense. I'd be interested in seeing what it did.
This PR adds a passive locations update interval to address WorkManager's restrictive execution intervals on some devices, which causes task pile-up and OOM crashes. Example: When passive data emits every 1s but WorkManager's minimum interval is 3s, navigation startup creates a task backlog. This also delays data submission (newest data waits at the queue's tail). WorkManager offers no working configurations to fix this—tested as ineffective on my device. Refs: #1201, #1213. By adding this configuration and properly adjusting it according to your system constraints, you can resolve both issues simultaneously while alleviating backend pressure for less data-intensive operations. Ideally, setting it to 0 would be optimal if your system permits without causing aforementioned problems.😀 Note: A default value of 0 for "Passive locations update interval" indicates unlimited updates.
The passive location interval was a performance fix, so I tagged it as such. Technically we could move the timestamp closer to passive data and add context notes – but that might bloat things. Maybe just link the original issue if someone asks. 🤷♂️
I see so in the context of Passive Logging, the time interval is a "max to take" rather than a "min" or schedule. Makes sense, although I'd probably call it a rate limiter (max number of updates per minute or something) rather than an interval (which to me implies a schedule - which I still don't think makes sense in a context when something else is deciding the rate).
Since my OEM device upgraded to Android 15. The OOM issue persisted for two months despite multiple attempted fixes. The owner couldn't reproduce it due to more lenient WorkManager restrictions on their device. Ultimately, implementing a passive locations update interval (minimum 3-second threshold) completely resolved both the OOM and data latency issues - 2-second intervals delayed but didn't prevent OOMs.🤷♂️