Opened 8 years ago

Closed 5 years ago

#963 closed defect/bug (fixed)

GPS-Infos not shown on Android

Reported by: elhennig Owned by: kamikaaze
Priority: major Milestone: version 0.5.1
Component: port/android Version: git master
Severity: normal Keywords: osd, gps, quality, patches
Cc: elhennig@…, http://wiki.navit-project.org/index.php/user:mvglasow, (2)

Description

The infos from gps_status vehicle.position_sats_used and vehicle.position_qual are not displayed in osd items on android (latest svn revision). On the PC the items are correctly shown.

Attachments (4)

satellite-status.diff (7.9 KB) - added by kamikaaze 6 years ago.
This patch adds support for the osd item gps_status
satellite-status-v2.diff (8.2 KB) - added by kamikaaze 6 years ago.
Same as Version 1 but only calls VehicleStatusCallback? when the status really changed
satellite-status-v3.2.diff (9.0 KB) - added by kamikaaze 6 years ago.
If loosing gps signal the correct fixtype will now be send
satellite-status-v3.diff (9.0 KB) - added by kamikaaze 6 years ago.
If loosing gps signal the correct fixtype will now be send

Download all attachments as: .zip

Change History (17)

comment:1 Changed 8 years ago by elhennig

It seems that the POI on/off menu item does not work as well Can some one else confirm this?

comment:2 Changed 7 years ago by lars hennig

  • Cc elhennig@… added

comment:3 Changed 7 years ago by usul

  • Keywords quality added
  • Milestone set to version 0.5.1

We need to check this is still a bug on the current SVN android build.

Changed 6 years ago by kamikaaze

This patch adds support for the osd item gps_status

comment:4 Changed 6 years ago by kamikaaze

  • Owner changed from cp15 to kamikaaze
  • Severity set to normal
  • Status changed from new to assigned

comment:5 Changed 6 years ago by kamikaaze

  • Keywords patches added

comment:6 Changed 6 years ago by kamikaaze

  • Keywords changed from osd gps quality patches to osd, gps, quality, patches

comment:7 follow-up: Changed 6 years ago by tryagain

I think we should not call our native callback on each onGpsStatusChanged call, if it happens twice a second. Navit internal processing of this event consumes quite many cpu cycles. At least we should check if fixType or usedSattelites value has changed since last call. Still under normal signal conditions we may have one extra callback per change of satellites number compared with current situation.

Another idea would be to get usedSatellites inside onLocationChanged using https://developer.android.com/reference/android/location/Location.html#getExtras%28%29 . But then we'll probably miss the event of total satellite signal loss: there will most probably no onLocationChanged call in this case.

To combine both, I would suggest to store current satellites count inside onGpsStatusChanged to a variable, but postpone VehicleStatusCallback? for, say, 1 or 2 seconds. In timer procedure we call VehicleStatusCallback? only if stored satellites count isn't already sent to the native layer by onLocationChanged code.

Changed 6 years ago by kamikaaze

Same as Version 1 but only calls VehicleStatusCallback? when the status really changed

comment:8 Changed 6 years ago by kamikaaze

With Version 2 the callback will only get executed when the actual used satellite count changed or when the gps fix is lost. ( Happens irregular, but no longer twice a second, like in Version 1 )

comment:9 Changed 6 years ago by kamikaaze

As it turned out the fixtype was not set to 0 if the signal got lost due to bad gps signals. Now a status of 0 is passed if the gps is switched off, or if the last location was received more than 10 seconds ago. Apparently a timeout seems to be the only way to more or less reliably tell if the gps signal is lost. If a Fix is available, a value of 2 is passed. (FIX3D)

Changed 6 years ago by kamikaaze

If loosing gps signal the correct fixtype will now be send

Changed 6 years ago by kamikaaze

If loosing gps signal the correct fixtype will now be send

comment:10 Changed 6 years ago by tryagain

Looks better.

But a few questions:

Are you sure the onGPSStatusChange will be fired in tunnel, when you already have no sattelites for 9 seconds? If it will not be fired up, we're going to lose our signal loss event.

Have you investigated, how navit track logging and tracking code will accept attr_position_coord_geo callbacks with the same location and time but different satellite count? I'm afraid we'll have duplicate points in gpx file.

I suggest to emit attr_position_coord_geo callback from onGPSStatusChange only if there's a transition from fixtype==2 to fixtype==0. Otherwise, satellite count and fixtype should be sent together with current location in onLocationChange.

We probably can decide that there's no fix as soon as we get onGPSStatusChange and there are no satellites flagged with usedInFix()==true.

tryagain

comment:11 Changed 6 years ago by kamikaaze

Hi tryagain,

onGpsStatusChange gets called on my Phone about twice a second with the GPS_EVENT_SATELLITE_STATUS event. Even if i have no gps connection. Tested this in our basement. :-)

I have not looked further into navits internals about how it does logging etc.

If you want i can call the status update together with every location update, but i don't see the benefits of that. Because right now while standing still it only gets called like every 10 seconds.

Even if i have no valid fix (GPS Icon in the top bar blinking) i get some satellites for usedInFix() == true. For example (2 Satellites used). This was my first try btw. :-)

comment:12 in reply to: ↑ 7 Changed 6 years ago by mvglasow (2)

  • Cc http://wiki.navit-project.org/index.php/user:mvglasow (2) added

Just came across this ticket.

Replying to http://wiki.navit-project.org/index.php/user:tryagain:

Another idea would be to get usedSatellites inside onLocationChanged using https://developer.android.com/reference/android/location/Location.html#getExtras%28%29 . But then we'll probably miss the event of total satellite signal loss: there will most probably no onLocationChanged call in this case.

Also, Location.getExtras() is not supported on all devices. On my Nexus S running Cyanogenmod it always returns zero satellites.

Probably a better option is to listen to the android.location.GPS_FIX_CHANGE broadcast. It is sent whenever the GPS gets or loses a fix, and the enabled extra will tell you which event triggered it (true for fix obtained, false for fix lost).

This broadcast, along with android.location.GPS_ENABLED_CHANGE, controls the GPS icon in the notification bar. android.location.GPS_FIX_CHANGE changes the icon from flashing to solid on Android 4.0 to 4.3.x. On Android 4.4 the icon no longer flashes, but the broadcast is sent anyway.

You can find a usage example at: https://github.com/mvglasow/satstat/blob/master/src/com/vonglasow/michael/satstat/PasvLocListenerService.java

One caveat: anyone can send this broadcast (and reportedly even switch the GPS icon on and off by doing so). There may be apps out there that abuse this feature, thus this broadcast is not 100% reliable.

comment:13 Changed 5 years ago by mvglasow (2)

  • Resolution set to fixed
  • Status changed from assigned to closed

Update: as of KitKat?, only the system can send this broadcast. While this is unlikely to be abused, the potenial reliability risk is mitigated from KitKat? onwards.

Also, counting satellites used may give erroneous results: my OnePlus? One frequently reports as many as 4 or 5 sats used in the fix, sometimes even on the same system, but I don't have a fix and don't get any location updates.

Anyways – I've implemented the above with my tried-and-true SatStat? code. Apologies to kamikaaze – I didn't read the ticket properly and saw your patches only after committing my code. However, the first two versions do the same things I did in my code, so you were essentially right :-)

As of r5957, the position_fix_type, position_qual and position_sats_used attributes are available for the Android vehicle; position_valid was introduced a few commits earlier.

The gps_status OSD now works on Android and will react immediately if the fix is lost. Note: on Android versions prior to 4.4 (KitKat?) you may see that the notification icon still shows a valid location while gps_status is down to one bar. This is because Android reports loss of GPS with a ~3-second delay while the OSD reacts instantly.

One limitation is currently that the Android vehicle will report its position as "valid" forever, even when we've been without a fix for ages. I'll tackle that once I get a good explanation of how the different states of position validity are meant to be interpreted. However, this is beyond the scope of this ticket, hence I'm closing it.

Note: See TracTickets for help on using tickets.