diff --git a/cardinal-android/app/src/main/java/earth/maps/cardinal/data/LocationRepository.kt b/cardinal-android/app/src/main/java/earth/maps/cardinal/data/LocationRepository.kt index c82b5776c86d1caea00abf6fcd17b40fa85eec70..16d4dd7258daa8f8e329be8559d190d5397295bf 100644 --- a/cardinal-android/app/src/main/java/earth/maps/cardinal/data/LocationRepository.kt +++ b/cardinal-android/app/src/main/java/earth/maps/cardinal/data/LocationRepository.kt @@ -53,7 +53,7 @@ class LocationRepository @Inject constructor( private companion object { private const val LOCATION_REQUEST_INTERVAL_MS = 15000L // 15 seconds - private const val LOCATION_REQUEST_TIMEOUT_MS = 10000L // 10 seconds + private const val LOCATION_REQUEST_TIMEOUT_MS = 5000L // 5 seconds private const val CONTINUOUS_LOCATION_UPDATE_INTERVAL_MS = 5000L // 5 seconds private const val CONTINUOUS_LOCATION_UPDATE_DISTANCE_M = 5f // 5 meters private const val FUSED_PROVIDER_TIMEOUT_MS = @@ -458,13 +458,14 @@ class LocationRepository @Inject constructor( ) { kotlinx.coroutines.MainScope().launch { kotlinx.coroutines.delay(LOCATION_REQUEST_TIMEOUT_MS) + val lastKnownLocation = getLastKnownLocation(locationManager) if (locationDeferred.isActive) { try { locationManager.removeUpdates(locationListener) } catch (_: Exception) { // Ignore exceptions during cleanup } - locationDeferred.complete(null) + locationDeferred.complete(lastKnownLocation) } } }