Colota - Android GPS Location tracker
Remove passive location listener. Caused zigzag lines/points in tracks due to inaccurate network fixes
Max Dietrich4999b1d26856
diff --git a/apps/docs/docs/configuration/gps-settings.md b/apps/docs/docs/configuration/gps-settings.mdindex 48e3e516..fb4e7d45 100644--- a/apps/docs/docs/configuration/gps-settings.md+++ b/apps/docs/docs/configuration/gps-settings.md@@ -15,7 +15,7 @@ sidebar_position: 2## Tracking Interval-How often the app requests a GPS fix. Shorter intervals give denser track points but drain more battery. The actual recording frequency may be higher due to the passive location listener picking up free fixes from other apps.+How often the app requests a GPS fix. Shorter intervals give denser track points but drain more battery.- **1-5 seconds**: High detail, suitable for driving or cycling- **15-30 seconds**: Good balance for walking or commuting@@ -33,9 +33,3 @@ Only records a new location if you've moved at least this many meters since theWhen enabled, GPS fixes with accuracy worse than the threshold are discarded. This prevents recording poor-quality positions from indoor or urban environments.The Google Play variant uses Android's `HIGH_ACCURACY` positioning mode via FusedLocationProvider, which combines GPS, Wi-Fi, and cellular data. The FOSS variant uses Android's native `LocationManager` with `GPS_PROVIDER` directly.--## Passive Location Listener--In addition to the configured tracking interval, Colota listens for location fixes already requested by other apps on your device (such as maps or navigation apps). These passive fixes are recorded at no extra battery cost and may result in additional data points between your configured interval.--This is intentional behavior - it improves track density when other apps happen to request a location. If you see more points than expected, this is why. The accuracy filter still applies, so poor-quality passive fixes are discarded.diff --git a/apps/docs/docs/guides/battery-optimization.md b/apps/docs/docs/guides/battery-optimization.mdindex b4a8c486..ec9849c0 100644--- a/apps/docs/docs/guides/battery-optimization.md+++ b/apps/docs/docs/guides/battery-optimization.md@@ -12,7 +12,6 @@ Settings and tips to reduce battery usage without losing GPS fixes.- **Batch processing**: 50 items per batch, 10 concurrent network requests- **Smart sync**: Only syncs when queue has items and network is available- **Battery critical shutdown**: Stops tracking below 5% (when unplugged)-- **Passive location listener**: Records free fixes from other apps at zero battery cost, improving track density without extra GPS usage## Tipsdiff --git a/apps/mobile/android/app/src/main/java/com/colota/service/LocationForegroundService.kt b/apps/mobile/android/app/src/main/java/com/colota/service/LocationForegroundService.ktindex 74bf2fb7..eb5d5fee 100644--- a/apps/mobile/android/app/src/main/java/com/colota/service/LocationForegroundService.kt+++ b/apps/mobile/android/app/src/main/java/com/colota/service/LocationForegroundService.kt@@ -18,8 +18,6 @@ import com.Colota.util.DeviceInfoHelperimport com.Colota.util.SecureStorageHelperimport android.content.Intentimport android.content.pm.ServiceInfo-import android.location.LocationListener-import android.location.LocationManagerimport android.os.*import androidx.core.app.ServiceCompatimport com.Colota.location.LocationProvider@@ -47,7 +45,6 @@ class LocationForegroundService : Service() {@Volatile private var serviceScope: CoroutineScope? = null@Volatile private var locationUpdateCallback: LocationUpdateCallback? = null- @Volatile private var passiveLocationListener: LocationListener? = null@Volatile private var locationRestartJob: Job? = null@Volatile private var insidePauseZone = false@Volatile private var currentZoneName: String? = null@@ -280,7 +277,6 @@ class LocationForegroundService : Service() {},onFailure = { /* initial location unavailable, updates will arrive */ })- startPassiveListener()} catch (e: SecurityException) {AppLogger.e(TAG, "Location permission missing", e)stopForegroundServiceWithReason("Location permission missing")@@ -293,34 +289,8 @@ class LocationForegroundService : Service() {private fun stopLocationUpdates() {locationUpdateCallback?.let { locationProvider.removeLocationUpdates(it) }locationUpdateCallback = null- stopPassiveListener()}- private fun startPassiveListener() {- try {- val locationManager = getSystemService(LOCATION_SERVICE) as LocationManager- val listener = LocationListener { location -> handleLocationUpdate(location) }- locationManager.requestLocationUpdates(- LocationManager.PASSIVE_PROVIDER, 1000L, 0f, listener, Looper.getMainLooper()- )- passiveLocationListener = listener- AppLogger.d(TAG, "Passive location listener started")- } catch (e: Exception) {- AppLogger.w(TAG, "Failed to start passive listener: ${e.message}")- }- }-- private fun stopPassiveListener() {- passiveLocationListener?.let {- try {- val locationManager = getSystemService(LOCATION_SERVICE) as LocationManager- locationManager.removeUpdates(it)- } catch (e: Exception) {- AppLogger.w(TAG, "Failed to remove passive listener: ${e.message}")- }- }- passiveLocationListener = null- }private fun handleZoneRecheckAction() {geofenceHelper.invalidateCache()@@ -417,7 +387,8 @@ class LocationForegroundService : Service() {return}- // Software-side distance filter (passive fixes bypass the OS-level distance filter)++ // Software-side distance filter (FLP bypasses the OS-level distance filter for some fixes)if (config.minUpdateDistance > 0f && prev != null) {val distance = prev.distanceTo(location)if (distance < config.minUpdateDistance) {