Skip to content

Colota - Android GPS Location tracker

fix: update map position while inside geofence pause zone

Max Dietrich3ba059994ccf
diff --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.kt
index fbc82b45..b3b7d455 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
@@ -482,7 +482,12 @@ class LocationForegroundService : Service() {
lastKnownLocation = location
val zone = geofenceHelper.getPauseZone(location)
- if (zone != null && insidePauseZone && zone.name == currentZoneName) return
+ if (zone != null && insidePauseZone && zone.name == currentZoneName) {
+ // Send position to UI so the map stays current while paused
+ val (bat, batStatus) = deviceInfoHelper.getCachedBatteryStatus()
+ LocationServiceModule.sendLocationEvent(location, bat, batStatus)
+ return
+ }
val anchorJob = applyZoneTransition(zone)
val (battery, batteryStatus) = deviceInfoHelper.getCachedBatteryStatus()
diff --git a/apps/mobile/android/app/src/test/java/com/Colota/service/LocationForegroundServiceTest.kt b/apps/mobile/android/app/src/test/java/com/Colota/service/LocationForegroundServiceTest.kt
index d912822a..f4f3ab4c 100644
--- a/apps/mobile/android/app/src/test/java/com/Colota/service/LocationForegroundServiceTest.kt
+++ b/apps/mobile/android/app/src/test/java/com/Colota/service/LocationForegroundServiceTest.kt
@@ -448,7 +448,7 @@ class LocationForegroundServiceTest {
}
@Test
- fun `handleLocationUpdate skips saving when already inside pause zone`() = testScope.runTest {
+ fun `handleLocationUpdate skips saving but sends UI event when already inside pause zone`() = testScope.runTest {
setField("insidePauseZone", true)
setField("currentZoneName", "Home")
setField("currentZoneGeofence", homeGeofence)
@@ -458,6 +458,7 @@ class LocationForegroundServiceTest {
invokeHandleLocationUpdate(location)
verify(exactly = 0) { dbHelper.saveLocation(any(), any(), any(), any(), any(), any(), any(), any(), any(), any()) }
+ verify { LocationServiceModule.sendLocationEvent(location, any(), any()) }
}
@Test