-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Turning android location services on and off breaks tracking on e-mission #128
Comments
Need to handle the case in which the app had a perfectly good geofence when the trip ended, location services has been fine all along, then the app gets woken up for the sync and wants to create a new one, but now the phone in a basement so it doesn't get a good location fix... |
We can use Maybe call it from the hourly sync run? |
I thought there was also an API to receive a broadcast intent if location services were turned on/off, but I can't find it now. Should have written it down when I had the chance... |
Testing this now. In From the logs.
From the documentation
I am not sure why the ASSERT didn't trigger, but it didn't. Android studio gives me a warning about how assertions are unreliable and I should use build flags instead, so there's that. We didn't do anything further because of the if check. It seems like a fairly simple fix would be to check for that and the appropriate status code, and move into the start state. Then, we would try to turn on the geofence every hour which is when we can see whether the location services is enabled and notify otherwise. |
Checked for the status code during geofence exit and moved to the start state (#130). Note that this doesn't cover the case in which location services is turned off during a trip. It turns out that there is a similar flag on location points in android ( But long experience with varied error conditions in location tracking made me want to check first. Is the location really unavailable only when location services is turned off? or it is unavailable even when I am underground on BART, for example? So I added this alert in #130 but didn't do anything else about it.
|
Unfortunately, as I saw, and as reported by @immesys from a much more recent version phone, it turns out that the location is unavailable a lot. Reliably when I am underground, but also at random other times during the day. I now know to abandon that nice theory, and will comment out the alert. |
Looks like we have handled the geofence case. It looks like the only case left here is the ongoing trip case, and for it, there's basically nothing to do but to move out of ongoing state if we haven't got any good points for a while. That will also fix #112, but we would need to ensure that we move to the start state at the end when getting points for creating the geofence fails. Then we will periodically try to create the geofence again and all will be good. |
Couple of people have reported that tracking turns off when
First, here's what I see from the logs:
We detected that you stopped moving
2016-06-22 03:27:42.813000-07:00,LocationChangeIntentService : stoppedMoving = true
We tried to create a geofence at the location
2016-06-22 03:27:43.508000-07:00,"CreateGeofenceAction : creating geofence at location Location[fused acc=73 et=+6d12h53m19s775ms alt=640.0]"
Creation was successful, so we went dormant and waited a geofence exit event to signal the start of a new trip
2016-06-22 03:27:43.553000-07:00,TripDiaryStateMachineService : newState after handling action is local.state.waiting_for_trip_start
And we never got it. So my current theory is that you turned off location tracking at around that time (can you confirm?) and turning off location tracking deletes all registered geofences.
I am not sure whether manually turning on tracking from the app when location tracking was turned off would have prompted you to turn it on, but we didn't have a chance to do that because we were never invoked to start tracking.
And it is surprisingly hard to make this more robust. The app does get woken up every 1-2 hours for a bi-directional sync, so I can use that to try and recover from a bad state.
Note, however, that simply checking whether location tracking is currently on will not work because it might have been turned off and on between syncs and the geofence deleted.
What we really need to do is to check whether we have a geofence registered and to create one if we don't. Unfortunately, I've looked into this before as part of
#65
and amazingly, android does not have an API to check whether a geofence exists!
At this point, the only thing that I can think of doing is to create a geofence every time we are launched for a sync and there is no ongoing trip.
I'm going to think a bit about whether I really want to do this because it has the potential to backfire, but will probably implement it in next week's release.
The text was updated successfully, but these errors were encountered: