From 933779197b98a55af2bc67646fc8debcb19cf6bd Mon Sep 17 00:00:00 2001 From: Shinovon <> Date: Fri, 5 Jan 2024 01:04:13 +0600 Subject: [PATCH] Add support of modded satellite data params --- src/mahomaps/map/GeoUpdateThread.java | 59 +++++++++++++++++---------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/src/mahomaps/map/GeoUpdateThread.java b/src/mahomaps/map/GeoUpdateThread.java index 6987f44..d489ca0 100644 --- a/src/mahomaps/map/GeoUpdateThread.java +++ b/src/mahomaps/map/GeoUpdateThread.java @@ -191,31 +191,46 @@ class LocationAPIListener implements LocationListener { public void locationUpdated(LocationProvider provider, Location location) { // определение кол-ва спутников - String nmea = location.getExtraInfo("application/X-jsr179-location-nmea"); - if (nmea != null) { - String[] sequence = split(nmea, '$'); - int s1 = -1; - int s2 = -1; - for (int i = sequence.length - 1; i >= 0; i--) { - String[] sentence = split(sequence[i], ','); - if (sentence[0].endsWith("GGA")) { - try { - s1 = Integer.parseInt(sentence[7]); - } catch (Exception e) { - s1 = -1; - } - s2 = Math.max(s2, s1); - } else if (sentence[0].endsWith("GSV")) { - try { - s2 = Math.max(s2, Integer.parseInt(sentence[3])); - } catch (Exception e) { + satellites: { + // парамы из патча для symbian^3 https://github.com/shinovon/Symbian3JSR179Mod + try { + String s1 = location.getExtraInfo("satelliteNumInView"); + String s2 = location.getExtraInfo("satelliteNumUsed"); + if (s1 != null && s2 != null) { + totalSattelitesInView = Integer.parseInt(s1); + sattelites = Integer.parseInt(s2); + break satellites; + } + } catch (Exception e) {} + // парс сырых nmea данных + String nmea = location.getExtraInfo("application/X-jsr179-location-nmea"); + if (nmea != null) { + String[] sequence = split(nmea, '$'); + int s1 = -1; + int s2 = -1; + for (int i = sequence.length - 1; i >= 0; i--) { + String s = sequence[i]; + if (s.indexOf('*') != -1) s = s.substring(0, s.lastIndexOf('*')); + String[] sentence = split(s, ','); + if (sentence[0].endsWith("GGA")) { + try { + s1 = Integer.parseInt(sentence[7]); + } catch (Exception e) { + s1 = -1; + } + s2 = Math.max(s2, s1); + } else if (sentence[0].endsWith("GSV")) { + try { + s2 = Math.max(s2, Integer.parseInt(sentence[3])); + } catch (Exception e) { + } } } + sattelites = s1; + totalSattelitesInView = s2; + } else { + totalSattelitesInView = sattelites = -1; } - sattelites = s1; - totalSattelitesInView = s2; - } else { - totalSattelitesInView = sattelites = -1; } String s = ""; int t = location.getLocationMethod();