gpslogger icon indicating copy to clipboard operation
gpslogger copied to clipboard

Failed to acquire GPS satellite count.

Open LOVE2CMOL opened this issue 9 months ago • 3 comments

The satellite count flashes briefly on the screen, but the data appears to be incorrect and isn't logged to the CSV file.

The screen recording demonstrates this behavior. https://github.com/user-attachments/assets/5c91a7ea-f502-4175-a457-0c275a5185e7

Image

debuglog.txt

20250325.csv

After checking my server logs, I found only sporadic records from a few months ago, with no recent data.

LOVE2CMOL avatar Mar 25 '25 13:03 LOVE2CMOL

I think this could be a bug.

Assuming you are on more than Android N (Android 7), the code should be using GnssStatusListener as here:

https://github.com/mendhak/gpslogger/blob/f25e942e8a1fc457162885eb1b4248629e5b376f/gpslogger/src/main/java/com/mendhak/gpslogger/GpsLoggingService.java#L643-L647

But the method is simply looking at the number of satellites, which is simply the number of satellites in the list: https://developer.android.com/reference/android/location/GnssStatus#getSatelliteCount()

I wonder if that list is being reset to 0 for some reason, and the 0 is being logged, even though there was briefly a number before.

But in any case, it should be iterating through the satellites list to see if it was used in the fix, using this method: https://developer.android.com/reference/android/location/GnssStatus#usedInFix(int), then counting that number.

mendhak avatar Mar 25 '25 18:03 mendhak

I think this could be a bug.

Assuming you are on more than Android N (Android 7), the code should be using GnssStatusListener as here:

gpslogger/gpslogger/src/main/java/com/mendhak/gpslogger/GpsLoggingService.java

Lines 643 to 647 in f25e942

public void onSatelliteStatusChanged(@NonNull GnssStatus status) { super.onSatelliteStatusChanged(status); setSatelliteInfo(status.getSatelliteCount()); gpsLocationListener.satellitesUsedInFix = status.getSatelliteCount(); } But the method is simply looking at the number of satellites, which is simply the number of satellites in the list: https://developer.android.com/reference/android/location/GnssStatus#getSatelliteCount()

I wonder if that list is being reset to 0 for some reason, and the 0 is being logged, even though there was briefly a number before.

But in any case, it should be iterating through the satellites list to see if it was used in the fix, using this method: https://developer.android.com/reference/android/location/GnssStatus#usedInFix(int), then counting that number.

A brief code review suggests that the passiveLocationListener could have abruptly replaced the data. During my tests with toggling passive data, I observed that activating it triggers an immediate burst of 2-3 data records. Despite passiveLocationManager.requestLocationUpdates having a 1-second interval, each trigger actually produces several location entries.

passiveLocationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, 1000, 0, passiveLocationListener);

LOVE2CMOL avatar Apr 07 '25 18:04 LOVE2CMOL

I think this could be a bug.

Assuming you are on more than Android N (Android 7), the code should be using GnssStatusListener as here:

gpslogger/gpslogger/src/main/java/com/mendhak/gpslogger/GpsLoggingService.java

Lines 643 to 647 in f25e942

public void onSatelliteStatusChanged(@NonNull GnssStatus status) { super.onSatelliteStatusChanged(status); setSatelliteInfo(status.getSatelliteCount()); gpsLocationListener.satellitesUsedInFix = status.getSatelliteCount(); } But the method is simply looking at the number of satellites, which is simply the number of satellites in the list: https://developer.android.com/reference/android/location/GnssStatus#getSatelliteCount()

I wonder if that list is being reset to 0 for some reason, and the 0 is being logged, even though there was briefly a number before.

But in any case, it should be iterating through the satellites list to see if it was used in the fix, using this method: https://developer.android.com/reference/android/location/GnssStatus#usedInFix(int), then counting that number.

I tested the modified code, and it works—the retrieved quantity is correct.

                public void onSatelliteStatusChanged(@NonNull GnssStatus status) {
                    super.onSatelliteStatusChanged(status);
                    int usedInFixCount = 0;
                    for (int i = 0; i < status.getSatelliteCount(); i++) {
                        if (status.usedInFix(i)) {
                            usedInFixCount++;
                        }
                    }

                    setSatelliteInfo(usedInFixCount);
                    gpsLocationListener.satellitesUsedInFix = usedInFixCount;
                }

However, since passive data always has a higher priority, it ends up overwriting the retrieved satellite data. I tried registering a GNSS listener for the passive data, which allowed normal uploads—but this approach doesn’t seem to align well with the actual data source.

LOVE2CMOL avatar Apr 10 '25 14:04 LOVE2CMOL

v134 is now in FDroid and the releases.

mendhak avatar Jul 05 '25 08:07 mendhak