Skip to content

Colota - Android GPS Location tracker

feat(location): add a High/Balanced positioning accuracy setting (#965)

Adrian Grohd1d20a893096
diff --git a/apps/docs/docs/configuration/tracking-settings.md b/apps/docs/docs/configuration/tracking-settings.md
index 41e623a5..c632f254 100644
--- a/apps/docs/docs/configuration/tracking-settings.md
+++ b/apps/docs/docs/configuration/tracking-settings.md
@@ -4,7 +4,7 @@ sidebar_position: 2
# Tracking Settings
-Found under **Settings → Tracking & sync → Recording**. The accuracy filter has its own group, **Accuracy filter**, at the bottom of the same screen.
+Found under **Settings → Tracking & sync → Recording**. **Positioning accuracy** and **Accuracy filter** have their own groups further down the same screen.
import ScreenshotGallery from '@site/src/components/ScreenshotGallery'
@@ -12,12 +12,13 @@ import ScreenshotGallery from '@site/src/components/ScreenshotGallery'
## Available Settings
-| Setting | Description | Default | Minimum |
-| --------------------------- | --------------------------------- | --------- | ------- |
-| Interval | Time between GPS fixes | 5 seconds | 1 s |
-| Movement threshold | Minimum movement to keep a fix | 0 | 0 |
-| Filter inaccurate locations | Enable/disable accuracy filtering | Off | On/Off |
-| Accuracy threshold | Drop fixes rated worse than this | 50 | 1 |
+| Setting | Description | Default | Accepted values |
+| --- | --- | --- | --- |
+| Interval | Time between GPS fixes | 5 seconds | ≥ 1 s |
+| Movement threshold | Minimum movement to keep a fix | 0 | ≥ 0 |
+| Positioning accuracy | High-precision or battery-saving fixes | High accuracy | High accuracy / Lower accuracy |
+| Filter inaccurate locations | Enable/disable accuracy filtering | Off | On/Off |
+| Accuracy threshold | Drop fixes rated worse than this | 50 | ≥ 1 |
The interval and movement threshold sit under **Custom** in the Recording group; picking a preset sets both. The two distance settings use whichever unit you picked in **Settings → Appearance**, so they read as meters or feet. Every number field takes whole numbers only and states its minimum under its label; a value below it is set to the minimum when you leave the field. There is no upper limit on any of the three numbers.
@@ -42,6 +43,19 @@ Only records a new location if you've moved at least this far since the last rec
- **0**: Record every GPS fix (default)
- **10-50 m**: Skip stationary updates, good for daily use
+## Positioning Accuracy
+
+How precise the continuous location stream is. The exact effect depends on the phone and its ROM.
+
+- **High accuracy** (default): the most accurate fixes, using more battery. This is what Colota has always used.
+- **Lower accuracy**: coarser fixes that use less battery and can arrive without bearing or altitude.
+
+Only the continuous stream follows this setting: the one-shot fresh fixes behind geofence exit, the pause watchdog and the stationary heartbeat stay on High accuracy, so a network fix can't falsely end a pause. Changing the setting restarts tracking, so it applies at once.
+
+Without Google Play services the effect depends on the ROM. GrapheneOS and Android 15 and older keep GPS on, so Lower accuracy changes nothing there. On Android 16 and newer, and with microG, it can mean network fixes only or none at all. If points stop arriving, switch back to High accuracy.
+
+With the **Accuracy filter** on, a strict threshold can drop Lower accuracy fixes. They often carry no speed, so a [stationary profile](/docs/guides/tracking-profiles#condition-types) can resolve late - or not at all with intervals over a minute or network-only fixes - and the [position-jump filter](#position-jump-filter) can't compare speed on them.
+
## Accuracy Filter
When on, fixes the chip rates worse than the threshold are dropped. A stricter threshold leaves gaps indoors and in dense streets, where every fix is rated poorly. The switch's own caption carries the threshold in both states, so turning the filter off hides the field without losing the number.
diff --git a/apps/docs/docs/development/architecture.md b/apps/docs/docs/development/architecture.md
index d6a47a71..1864ea07 100644
--- a/apps/docs/docs/development/architecture.md
+++ b/apps/docs/docs/development/architecture.md
@@ -48,7 +48,7 @@ The mobile app has a **React Native** UI layer and **native Kotlin** modules for
All native code lives in `apps/mobile/android/app/src/`, organized by build flavor:
-- `src/main/java/com/colota/` - Shared code: `bridge/`, `service/`, `data/`, `sync/`, `util/`, `location/` (interface), `backup/`, `export/`
+- `src/main/java/com/colota/` - Shared code: `bridge/`, `service/`, `data/`, `sync/`, `util/`, `location/` (interface + `LocationAccuracy`), `backup/`, `export/`
- `src/gms/java/com/colota/location/` - Google Play Services location provider
- `src/foss/java/com/colota/location/` - Native Android location provider
@@ -144,6 +144,10 @@ Location services are abstracted behind a `LocationProvider` interface (`locatio
Each flavor provides a `LocationProviderFactory` that instantiates and returns the correct implementation at runtime. The service and bridge code in `src/main/` depends only on the `LocationProvider` interface, never on a concrete class.
+`requestLocationUpdates(...)` takes a `LocationAccuracy` (`high` / `balanced`, from the global **Positioning accuracy** setting) and each provider maps it to its own request: GMS to `Priority.PRIORITY_HIGH_ACCURACY` / `PRIORITY_BALANCED_POWER_ACCURACY` (100 / 102) and FOSS to `LocationRequestCompat.QUALITY_HIGH_ACCURACY` / `QUALITY_BALANCED_POWER_ACCURACY` (100 / 102), both behind a pure, unit-tested function. The API defines these as trade-offs, not distances; `QUALITY_BALANCED_POWER_ACCURACY` is also the builder's default.
+
+`getCurrentLocation(...)` is deliberately requested at High accuracy (best-effort on the FOSS raw-GPS path below Android 12, where the compat API takes no quality hint) - it drives pause-zone exit, the pause watchdog and the stationary heartbeat, where a network-only fix could falsely end a geofence pause. `LocationAccuracy.fromWire()` falls back to `HIGH` for unknown or absent values.
+
### LocationForegroundService
An Android foreground service that runs continuously for GPS tracking. Manages:
@@ -153,7 +157,7 @@ An Android foreground service that runs continuously for GPS tracking. Manages:
- Geofence entry delay - keeps recording for 3.5× the configured tracking interval before pausing on zone entry, logging real arrival points for backends like GeoPulse
- Anchor points - a synthetic location saved on zone exit as a clean start point for the departing trip, timestamped 1s before the first real GPS fix
- Battery critical shutdown (below 5% while unplugged), detected via a battery-broadcast receiver so it fires even while GPS is paused in a zone
-- Location accuracy filtering
+- Location accuracy filtering and the global positioning accuracy mode
- Stationary detection - slows GPS to the profile's interval after 60s of fixes without movement; resume is driven by the shared `MotionStateDetector` (accelerometer variance, with SIG_MOTION as a fast-path for sharp wake events). It keeps working inside a pause zone and during an entry delay, since fixes reach `ProfileManager` before the in-zone drop; only a hold that stops the stream can prevent a verdict.
- Queuing data for server sync
diff --git a/apps/docs/docs/faq.md b/apps/docs/docs/faq.md
index cb591a6c..b51ec1d3 100644
--- a/apps/docs/docs/faq.md
+++ b/apps/docs/docs/faq.md
@@ -42,6 +42,8 @@ To ensure modifications stay open source, especially server-side components.
3-10 meters in open sky, 10-50 meters in urban areas. The [accuracy filter](/docs/configuration/tracking-settings#accuracy-filter) helps remove poor fixes.
+Set [Positioning accuracy](/docs/configuration/tracking-settings#positioning-accuracy) to **Lower accuracy** to trade fix precision for battery.
+
### Can I use maps without internet?
Yes. Go to **Settings → Offline maps** to download map areas to your device. Pan and zoom the map to frame the area you want, give it a name, and tap **Download area**. Downloaded tiles persist across app restarts and work without any network connection. See [Offline maps](/docs/guides/offline-maps) for details.
@@ -76,7 +78,7 @@ Android is suspending the app to save power. Exempt Colota from battery optimiza
### How much battery does it use?
-Depends on your settings. With the **Balanced** preset (30s interval, batch sync), typical usage is moderate. See [Battery Optimization](/docs/guides/battery-optimization) for tips.
+Depends on your settings. With the **Balanced** sync preset (30s interval, batch sync), typical usage is moderate. See [Battery Optimization](/docs/guides/battery-optimization) for tips.
### How do I update the app?
diff --git a/apps/docs/docs/guides/battery-optimization.md b/apps/docs/docs/guides/battery-optimization.md
index edb9f6fa..050a3706 100644
--- a/apps/docs/docs/guides/battery-optimization.md
+++ b/apps/docs/docs/guides/battery-optimization.md
@@ -17,11 +17,12 @@ Settings and tips to reduce battery usage without losing GPS fixes.
## Tips
1. **Increase GPS interval** - 5s to 30s saves significant battery
-2. **Enable accuracy filtering** - Reject poor GPS fixes to avoid unnecessary processing
-3. **Use batch sync** instead of instant - Reduces network usage and wake-ups
-4. **Create geofences** for home/work - Stops recording locations in known zones. Enable **Pause when on WiFi** to also stop GPS entirely when connected to your home network, or **Pause when motionless** to stop GPS after sitting still for a set time
-5. **Enable movement threshold** - 10-50m, skip stationary updates
-6. **Disable battery optimization** for Colota in Android settings to prevent the OS from killing the service
+2. **Lower the positioning accuracy** - switch **Positioning accuracy** (Tracking & sync) to **Lower accuracy** to trade fix precision for battery; leave it on **High accuracy** when accuracy matters
+3. **Enable accuracy filtering** - Reject poor GPS fixes to avoid unnecessary processing
+4. **Use batch sync** instead of instant - Reduces network usage and wake-ups
+5. **Create geofences** for home/work - Stops recording locations in known zones. Enable **Pause when on WiFi** to also stop GPS entirely when connected to your home network, or **Pause when motionless** to stop GPS after sitting still for a set time
+6. **Enable movement threshold** - 10-50m, skip stationary updates
+7. **Disable battery optimization** for Colota in Android settings to prevent the OS from killing the service
## Android Battery Settings
diff --git a/apps/docs/docs/guides/deep-link-setup.md b/apps/docs/docs/guides/deep-link-setup.md
index 2df9ce48..06462001 100644
--- a/apps/docs/docs/guides/deep-link-setup.md
+++ b/apps/docs/docs/guides/deep-link-setup.md
@@ -54,6 +54,7 @@ The `config` parameter is a base64-encoded JSON object. Only include the setting
| `syncInterval` | number | Batch sync interval in seconds (0 = instant) |
| `accuracyThreshold` | number | Discard locations less accurate than this (meters) |
| `filterInaccurateLocations` | boolean | Enable accuracy filtering |
+| `accuracyMode` | string | Positioning accuracy: `high` (High accuracy, default) or `balanced` (Lower accuracy) |
| `isOfflineMode` | boolean | Store locally only, never sync |
| `syncCondition` | string | `any`, `wifi_any`, `wifi_ssid`, or `vpn` |
| `syncSsid` | string | Wi-Fi SSID to sync on (only used with `wifi_ssid`) |
diff --git a/apps/docs/docs/introduction.md b/apps/docs/docs/introduction.md
index 4fb9755c..c1fe4b5e 100644
--- a/apps/docs/docs/introduction.md
+++ b/apps/docs/docs/introduction.md
@@ -37,7 +37,7 @@ Colota has twenty-seven screens, each focused on a specific task:
| **Dashboard** | Live map with current coordinates, today's track overlay, tracking controls, database stats, and geofence status |
| **Settings** | The hub: Tracking, Display, Data, Help and About, each row showing the value it holds |
| **Connection** | Server endpoint URL, offline mode toggle and connection test |
-| **Tracking & sync** | GPS polling interval, distance filter, accuracy threshold and sync strategy preset |
+| **Tracking & sync** | GPS polling interval, distance filter, positioning accuracy, accuracy threshold and sync strategy preset |
| **Appearance** | Light/dark theme, wallpaper colors, unit system, time format and custom map tile URLs |
| **Request format** | How the request is shaped: the backend template, the HTTP method, the field names and any custom fields |
| **Backend template** | Pick the backend Colota formats its payload for, each option describing what it sends |
diff --git a/apps/docs/src/components/DeepLinkGenerator.tsx b/apps/docs/src/components/DeepLinkGenerator.tsx
index 9ffe8da0..af8a29f3 100644
--- a/apps/docs/src/components/DeepLinkGenerator.tsx
+++ b/apps/docs/src/components/DeepLinkGenerator.tsx
@@ -78,6 +78,7 @@ export default function DeepLinkGenerator() {
const [distance, setDistance] = useState("")
const [accuracyThreshold, setAccuracyThreshold] = useState("")
const [filterInaccurateLocations, setFilterInaccurateLocations] = useState("")
+ const [accuracyMode, setAccuracyMode] = useState("")
// Sync
const [syncInterval, setSyncInterval] = useState("")
@@ -119,6 +120,7 @@ export default function DeepLinkGenerator() {
if (distance) obj.distance = Number(distance)
if (accuracyThreshold) obj.accuracyThreshold = Number(accuracyThreshold)
if (filterInaccurateLocations) obj.filterInaccurateLocations = filterInaccurateLocations === "true"
+ if (accuracyMode) obj.accuracyMode = accuracyMode
if (syncInterval) obj.syncInterval = Number(syncInterval)
if (isOfflineMode) obj.isOfflineMode = isOfflineMode === "true"
@@ -228,6 +230,7 @@ export default function DeepLinkGenerator() {
distance,
accuracyThreshold,
filterInaccurateLocations,
+ accuracyMode,
syncInterval,
isOfflineMode,
syncCondition,
@@ -480,6 +483,16 @@ export default function DeepLinkGenerator() {
</select>
</div>
</div>
+ <div className={styles.row}>
+ <div className={styles.field}>
+ <label className={styles.label}>Positioning accuracy</label>
+ <select className={styles.select} value={accuracyMode} onChange={(e) => setAccuracyMode(e.target.value)}>
+ <option value="">-- not set --</option>
+ <option value="high">High accuracy</option>
+ <option value="balanced">Lower accuracy</option>
+ </select>
+ </div>
+ </div>
</div>
{/* Sync */}
diff --git a/apps/mobile/android/app/src/foss/java/com/Colota/location/NativeLocationProvider.kt b/apps/mobile/android/app/src/foss/java/com/Colota/location/NativeLocationProvider.kt
index 0c65f306..7cd65054 100644
--- a/apps/mobile/android/app/src/foss/java/com/Colota/location/NativeLocationProvider.kt
+++ b/apps/mobile/android/app/src/foss/java/com/Colota/location/NativeLocationProvider.kt
@@ -33,6 +33,12 @@ class NativeLocationProvider(context: Context) : LocationProvider {
companion object {
private const val TAG = "NativeLocationProvider"
+ /** Pure mode → LocationRequestCompat quality mapping, kept free of side effects so it is unit-testable. */
+ internal fun qualityFor(accuracy: LocationAccuracy): Int = when (accuracy) {
+ LocationAccuracy.HIGH -> LocationRequestCompat.QUALITY_HIGH_ACCURACY
+ LocationAccuracy.BALANCED -> LocationRequestCompat.QUALITY_BALANCED_POWER_ACCURACY
+ }
+
internal fun selectProvider(locationManager: LocationManager): String =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
&& LocationManagerCompat.hasProvider(locationManager, LocationManager.FUSED_PROVIDER)
@@ -54,6 +60,7 @@ class NativeLocationProvider(context: Context) : LocationProvider {
override fun requestLocationUpdates(
intervalMs: Long,
minDistanceMeters: Float,
+ accuracy: LocationAccuracy,
looper: Looper,
callback: LocationUpdateCallback
) {
@@ -66,13 +73,13 @@ class NativeLocationProvider(context: Context) : LocationProvider {
// The legacy requestLocationUpdates overload runs at balanced power on API 31+,
// which can keep the fused provider from ever engaging GNSS.
val request = LocationRequestCompat.Builder(intervalMs)
- .setQuality(LocationRequestCompat.QUALITY_HIGH_ACCURACY)
+ .setQuality(qualityFor(accuracy))
.setMinUpdateDistanceMeters(minDistanceMeters)
.build()
try {
LocationManagerCompat.requestLocationUpdates(locationManager, provider, request, listener, looper)
- AppLogger.d(TAG, "Started $provider updates: interval=${intervalMs}ms, distance=${minDistanceMeters}m")
+ AppLogger.d(TAG, "Started $provider updates: interval=${intervalMs}ms, distance=${minDistanceMeters}m, accuracy=${accuracy.wireName}")
} catch (e: SecurityException) {
locationManager.removeUpdates(listener)
throw e
diff --git a/apps/mobile/android/app/src/gms/java/com/Colota/location/GmsLocationProvider.kt b/apps/mobile/android/app/src/gms/java/com/Colota/location/GmsLocationProvider.kt
index a4be31c9..43a21ebe 100644
--- a/apps/mobile/android/app/src/gms/java/com/Colota/location/GmsLocationProvider.kt
+++ b/apps/mobile/android/app/src/gms/java/com/Colota/location/GmsLocationProvider.kt
@@ -16,6 +16,12 @@ class GmsLocationProvider(context: Context) : LocationProvider {
companion object {
private const val TAG = "GmsLocationProvider"
+
+ /** Pure mode → GMS priority mapping, kept free of side effects so it is unit-testable. */
+ internal fun priorityFor(accuracy: LocationAccuracy): Int = when (accuracy) {
+ LocationAccuracy.HIGH -> Priority.PRIORITY_HIGH_ACCURACY
+ LocationAccuracy.BALANCED -> Priority.PRIORITY_BALANCED_POWER_ACCURACY
+ }
}
private val fusedClient: FusedLocationProviderClient =
@@ -26,6 +32,7 @@ class GmsLocationProvider(context: Context) : LocationProvider {
override fun requestLocationUpdates(
intervalMs: Long,
minDistanceMeters: Float,
+ accuracy: LocationAccuracy,
looper: Looper,
callback: LocationUpdateCallback
) {
@@ -36,14 +43,14 @@ class GmsLocationProvider(context: Context) : LocationProvider {
}
callbackMap[callback] = gmsCallback
- val request = LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, intervalMs)
+ val request = LocationRequest.Builder(priorityFor(accuracy), intervalMs)
.setMinUpdateIntervalMillis(intervalMs)
.setMinUpdateDistanceMeters(minDistanceMeters)
.build()
try {
fusedClient.requestLocationUpdates(request, gmsCallback, looper)
- AppLogger.d(TAG, "Started FusedLocationProvider updates: interval=${intervalMs}ms, distance=${minDistanceMeters}m")
+ AppLogger.d(TAG, "Started FusedLocationProvider updates: interval=${intervalMs}ms, distance=${minDistanceMeters}m, accuracy=${accuracy.wireName}")
} catch (e: SecurityException) {
callbackMap.remove(callback)
throw e
@@ -71,6 +78,8 @@ class GmsLocationProvider(context: Context) : LocationProvider {
}
override fun getCurrentLocation(timeoutMs: Long, onResult: (Location?) -> Unit) {
+ // Intentionally always High accuracy (#951), regardless of the configured stream mode: this
+ // one-shot probe decides pause-zone exit, the watchdog and the stationary heartbeat.
// setMaxUpdateAgeMillis(0) forbids the cached fix, forcing a real GNSS acquisition.
val request = CurrentLocationRequest.Builder()
.setPriority(Priority.PRIORITY_HIGH_ACCURACY)
diff --git a/apps/mobile/android/app/src/main/java/com/colota/data/DatabaseHelper.kt b/apps/mobile/android/app/src/main/java/com/colota/data/DatabaseHelper.kt
index 50900ccd..ce03a8cd 100644
--- a/apps/mobile/android/app/src/main/java/com/colota/data/DatabaseHelper.kt
+++ b/apps/mobile/android/app/src/main/java/com/colota/data/DatabaseHelper.kt
@@ -356,6 +356,7 @@ class DatabaseHelper private constructor(context: Context) :
"syncInterval" to "0",
"accuracyThreshold" to "50.0",
"filterInaccurateLocations" to "false",
+ "accuracyMode" to "high",
"retryInterval" to "30",
"isOfflineMode" to "false",
"syncCondition" to "any",
diff --git a/apps/mobile/android/app/src/main/java/com/colota/location/LocationAccuracy.kt b/apps/mobile/android/app/src/main/java/com/colota/location/LocationAccuracy.kt
new file mode 100644
index 00000000..482262b1
--- /dev/null
+++ b/apps/mobile/android/app/src/main/java/com/colota/location/LocationAccuracy.kt
@@ -0,0 +1,28 @@
+/**
+ * Copyright (C) 2026 Max Dietrich
+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.
+ */
+
+package com.Colota.location
+
+/**
+ * Positioning accuracy of the continuous location stream (#951).
+ *
+ * [HIGH] preserves the historical behaviour (the provider may keep GNSS engaged). [BALANCED]
+ * trades precision for battery by letting the provider prefer network / lower-power fixes.
+ *
+ * There is deliberately no `LOW_POWER` mode: it is cell-tower, city-level (~10 km) and would
+ * reproduce the zigzag failure the maintainer reverted (#215).
+ */
+enum class LocationAccuracy(val wireName: String) {
+ HIGH("high"),
+ BALANCED("balanced");
+
+ companion object {
+ /** Parses the stored/wire value, falling back to [HIGH] for anything unknown or absent. */
+ fun fromWire(value: String?): LocationAccuracy {
+ val name = value?.trim()
+ return entries.firstOrNull { it.wireName.equals(name, ignoreCase = true) } ?: HIGH
+ }
+ }
+}
diff --git a/apps/mobile/android/app/src/main/java/com/colota/location/LocationProvider.kt b/apps/mobile/android/app/src/main/java/com/colota/location/LocationProvider.kt
index 3617e15e..ec68937f 100644
--- a/apps/mobile/android/app/src/main/java/com/colota/location/LocationProvider.kt
+++ b/apps/mobile/android/app/src/main/java/com/colota/location/LocationProvider.kt
@@ -19,12 +19,14 @@ interface LocationProvider {
*
* @param intervalMs Desired update interval in milliseconds.
* @param minDistanceMeters Minimum distance between updates in meters.
+ * @param accuracy Positioning accuracy (High / Balanced) for the stream.
* @param looper Looper on which callbacks are dispatched.
* @param callback Receives each location update.
*/
fun requestLocationUpdates(
intervalMs: Long,
minDistanceMeters: Float,
+ accuracy: LocationAccuracy,
looper: Looper,
callback: LocationUpdateCallback
)
@@ -48,6 +50,11 @@ interface LocationProvider {
/**
* Actively acquire one fresh fix, forbidding cached locations.
*
+ * Always requested at High accuracy, independent of the configured stream mode (#951): this one-shot
+ * probe drives pause-zone exit, the pause watchdog and the stationary heartbeat, and a network-only
+ * fix could falsely exit a geofence. Best-effort on the FOSS raw-GPS path below Android 12, where the
+ * compat API takes no quality hint.
+ *
* @param timeoutMs Max time to wait for the fix.
* @param onResult Called once with the fix, or null on timeout/failure.
*/
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 c782a3d0..25313daf 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
@@ -536,12 +536,13 @@ class LocationForegroundService : Service() {
val bypassOsFilter = needsLocationStreamForProfiles()
val osMinDistance = if (bypassOsFilter) 0f else config.minUpdateDistance
- AppLogger.d(TAG, "Requesting location updates: interval=${config.interval}ms, distance=${config.minUpdateDistance}m, osFilter=${osMinDistance}m")
+ AppLogger.d(TAG, "Requesting location updates: interval=${config.interval}ms, distance=${config.minUpdateDistance}m, osFilter=${osMinDistance}m, accuracyMode=${config.accuracyMode.wireName}")
try {
locationProvider.requestLocationUpdates(
intervalMs = config.interval,
minDistanceMeters = osMinDistance,
+ accuracy = config.accuracyMode,
looper = Looper.getMainLooper(),
callback = callback
)
@@ -1680,6 +1681,7 @@ class LocationForegroundService : Service() {
profileManager.defaultInterval = config.interval
profileManager.defaultDistance = config.minUpdateDistance
profileManager.defaultSyncInterval = config.syncIntervalSeconds
+ profileManager.defaultAccuracyMode = config.accuracyMode
val parsedFieldMap = PayloadBuilder.parseFieldMap(config.fieldMap) ?: emptyMap()
val parsedCustomFields = PayloadBuilder.parseCustomFields(config.customFields) ?: emptyMap()
@@ -1687,7 +1689,7 @@ class LocationForegroundService : Service() {
payloadCustomFields = parsedCustomFields
AppLogger.d(TAG, buildString {
- append("Config loaded: interval=${config.interval}ms, distance=${config.minUpdateDistance}m, accuracy=${config.accuracyThreshold}m")
+ append("Config loaded: interval=${config.interval}ms, distance=${config.minUpdateDistance}m, accuracy=${config.accuracyThreshold}m, accuracyMode=${config.accuracyMode.wireName}")
append(", endpoint=${if (config.endpoint.isBlank()) "NOT CONFIGURED" else AppLogger.maskSensitiveUrlValues(config.endpoint)}")
append(", offline=${config.isOfflineMode}, sync=${if (config.syncIntervalSeconds == 0) "instant" else "${config.syncIntervalSeconds}s"}")
if (parsedFieldMap.isNotEmpty()) append(", fieldMap=${parsedFieldMap.size} mappings")
diff --git a/apps/mobile/android/app/src/main/java/com/colota/service/ProfileManager.kt b/apps/mobile/android/app/src/main/java/com/colota/service/ProfileManager.kt
index da55ce6d..b484eda7 100644
--- a/apps/mobile/android/app/src/main/java/com/colota/service/ProfileManager.kt
+++ b/apps/mobile/android/app/src/main/java/com/colota/service/ProfileManager.kt
@@ -8,6 +8,7 @@ package com.Colota.service
import com.Colota.util.AppLogger
import com.Colota.bridge.LocationServiceModule
import com.Colota.data.ProfileHelper
+import com.Colota.location.LocationAccuracy
import kotlinx.coroutines.*
/**
@@ -46,6 +47,10 @@ class ProfileManager(
@Volatile var defaultDistance: Float = 0f
@Volatile var defaultSyncInterval: Int = 0
+ // Global positioning accuracy, written by the service on config load; read by
+ // evaluateStationaryState() so a non-High stream does not treat a speed-less fix as stillness (#951).
+ @Volatile var defaultAccuracyMode: LocationAccuracy = LocationAccuracy.HIGH
+
// @Volatile: getActiveProfileName() reads it without the lock.
@Volatile private var activeProfile: ProfileHelper.CachedProfile? = null
// Guarded by the @Synchronized methods.
@@ -375,7 +380,17 @@ class ProfileManager(
lastSampleAtMs = sampleAtMs
if (gapMs >= 0) lastSampleGapMs = gapMs
- val speed = if (location.hasSpeed()) location.speed else 0f
+ val speed = if (location.hasSpeed()) {
+ location.speed
+ } else if (defaultAccuracyMode == LocationAccuracy.HIGH) {
+ // High mode has always read an absent speed as stillness: on this path GNSS fixes carry it.
+ 0f
+ } else {
+ // Balanced hands us speed-less network fixes, and a missing speed is not proof of stillness
+ // (#951). A derived speed from `applySpeedFallback()` sets `hasSpeed()` first, so only a
+ // genuinely speed-less fix reaches this branch.
+ return
+ }
if (speed >= ProfileConstants.STATIONARY_SPEED_THRESHOLD) {
runStartedAtMs = 0L
diff --git a/apps/mobile/android/app/src/main/java/com/colota/service/ServiceConfig.kt b/apps/mobile/android/app/src/main/java/com/colota/service/ServiceConfig.kt
index 2b2eadda..3da8c7ab 100644
--- a/apps/mobile/android/app/src/main/java/com/colota/service/ServiceConfig.kt
+++ b/apps/mobile/android/app/src/main/java/com/colota/service/ServiceConfig.kt
@@ -8,6 +8,7 @@ package com.Colota.service
import android.content.Intent
import android.os.Bundle
import com.Colota.data.DatabaseHelper
+import com.Colota.location.LocationAccuracy
import com.Colota.sync.ApiFormat
import com.facebook.react.bridge.ReadableMap
import org.json.JSONObject
@@ -22,6 +23,7 @@ data class ServiceConfig(
val syncIntervalSeconds: Int = 0,
val accuracyThreshold: Float = 50.0f,
val filterInaccurateLocations: Boolean = false,
+ val accuracyMode: LocationAccuracy = LocationAccuracy.HIGH,
val retryIntervalSeconds: Int = 30,
val isOfflineMode: Boolean = false,
val syncCondition: String = "any",
@@ -54,6 +56,7 @@ data class ServiceConfig(
syncIntervalSeconds = saved["syncInterval"]?.toIntOrNull() ?: 0,
accuracyThreshold = saved["accuracyThreshold"]?.toFloatOrNull() ?: 50.0f,
filterInaccurateLocations = saved["filterInaccurateLocations"]?.toBoolean() ?: false,
+ accuracyMode = LocationAccuracy.fromWire(saved["accuracyMode"]),
retryIntervalSeconds = saved["retryInterval"]?.toIntOrNull() ?: 30,
isOfflineMode = saved["isOfflineMode"]?.toBoolean() ?: false,
syncCondition = saved["syncCondition"] ?: if (saved["isWifiOnlySync"]?.toBoolean() == true) "wifi_any" else "any",
@@ -101,6 +104,7 @@ data class ServiceConfig(
syncIntervalSeconds = config.getIntOrNull("syncInterval") ?: dbConfig.syncIntervalSeconds,
accuracyThreshold = config.getDoubleOrNull("accuracyThreshold")?.toFloat() ?: dbConfig.accuracyThreshold,
filterInaccurateLocations = config.getBooleanOrNull("filterInaccurateLocations") ?: dbConfig.filterInaccurateLocations,
+ accuracyMode = config.getStringOrNull("accuracyMode")?.let { LocationAccuracy.fromWire(it) } ?: dbConfig.accuracyMode,
retryIntervalSeconds = config.getIntOrNull("retryInterval") ?: dbConfig.retryIntervalSeconds,
isOfflineMode = config.getBooleanOrNull("isOfflineMode") ?: dbConfig.isOfflineMode,
syncCondition = config.getStringOrNull("syncCondition") ?: dbConfig.syncCondition,
@@ -124,6 +128,9 @@ data class ServiceConfig(
syncIntervalSeconds = extras.getIntOrDefault("syncInterval", dbConfig.syncIntervalSeconds),
accuracyThreshold = extras.getFloatOrDefault("accuracyThreshold", dbConfig.accuracyThreshold),
filterInaccurateLocations = extras.getBooleanOrDefault("filterInaccurateLocations", dbConfig.filterInaccurateLocations),
+ accuracyMode = if (extras.containsKey("accuracyMode"))
+ LocationAccuracy.fromWire(extras.getString("accuracyMode"))
+ else dbConfig.accuracyMode,
retryIntervalSeconds = extras.getIntOrDefault("retryInterval", dbConfig.retryIntervalSeconds),
isOfflineMode = extras.getBooleanOrDefault("isOfflineMode", dbConfig.isOfflineMode),
syncCondition = extras.getStringOrDefault("syncCondition", dbConfig.syncCondition) ?: "any",
@@ -147,6 +154,7 @@ data class ServiceConfig(
putExtra("syncInterval", syncIntervalSeconds)
putExtra("accuracyThreshold", accuracyThreshold)
putExtra("filterInaccurateLocations", filterInaccurateLocations)
+ putExtra("accuracyMode", accuracyMode.wireName)
putExtra("retryInterval", retryIntervalSeconds)
putExtra("isOfflineMode", isOfflineMode)
putExtra("syncCondition", syncCondition)
diff --git a/apps/mobile/android/app/src/test/java/com/Colota/data/DatabaseHelperSQLiteTest.kt b/apps/mobile/android/app/src/test/java/com/Colota/data/DatabaseHelperSQLiteTest.kt
index 412cdd05..4e48ede0 100644
--- a/apps/mobile/android/app/src/test/java/com/Colota/data/DatabaseHelperSQLiteTest.kt
+++ b/apps/mobile/android/app/src/test/java/com/Colota/data/DatabaseHelperSQLiteTest.kt
@@ -94,6 +94,7 @@ class DatabaseHelperSQLiteTest {
assertEquals("false", settings["tracking_enabled"])
assertEquals("POST", settings["httpMethod"])
assertEquals("custom", settings["apiTemplate"])
+ assertEquals("high", settings["accuracyMode"])
}
@Test
diff --git a/apps/mobile/android/app/src/test/java/com/Colota/location/LocationAccuracyTest.kt b/apps/mobile/android/app/src/test/java/com/Colota/location/LocationAccuracyTest.kt
new file mode 100644
index 00000000..aa635e57
--- /dev/null
+++ b/apps/mobile/android/app/src/test/java/com/Colota/location/LocationAccuracyTest.kt
@@ -0,0 +1,32 @@
+/**
+ * Copyright (C) 2026 Max Dietrich
+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.
+ */
+
+package com.Colota.location
+
+import org.junit.Assert.assertEquals
+import org.junit.Test
+
+class LocationAccuracyTest {
+
+ @Test
+ fun `parses both wire names`() {
+ assertEquals(LocationAccuracy.HIGH, LocationAccuracy.fromWire("high"))
+ assertEquals(LocationAccuracy.BALANCED, LocationAccuracy.fromWire("balanced"))
+ }
+
+ @Test
+ fun `parses case-insensitively and tolerates surrounding whitespace`() {
+ assertEquals(LocationAccuracy.HIGH, LocationAccuracy.fromWire("HIGH"))
+ assertEquals(LocationAccuracy.BALANCED, LocationAccuracy.fromWire("Balanced"))
+ assertEquals(LocationAccuracy.BALANCED, LocationAccuracy.fromWire(" balanced "))
+ }
+
+ @Test
+ fun `falls back to high for unknown, empty or missing values`() {
+ assertEquals(LocationAccuracy.HIGH, LocationAccuracy.fromWire(null))
+ assertEquals(LocationAccuracy.HIGH, LocationAccuracy.fromWire(""))
+ assertEquals(LocationAccuracy.HIGH, LocationAccuracy.fromWire("low_power"))
+ }
+}
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 1c5dae65..92a72652 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
@@ -8,6 +8,7 @@ import com.Colota.bridge.LocationServiceModule
import com.Colota.data.DatabaseHelper
import com.Colota.data.GeofenceHelper
import com.Colota.data.SettingsKeys
+import com.Colota.location.LocationAccuracy
import com.Colota.location.LocationProvider
import com.Colota.location.LocationUpdateCallback
import com.Colota.sync.PayloadBuilder
@@ -680,7 +681,7 @@ class LocationForegroundServiceTest {
@Test
fun `setupLocationUpdates stops service on SecurityException`() {
- every { locationProvider.requestLocationUpdates(any(), any(), any(), any()) } throws SecurityException("no permission")
+ every { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) } throws SecurityException("no permission")
invokeSetupLocationUpdates()
@@ -689,7 +690,7 @@ class LocationForegroundServiceTest {
@Test
fun `setupLocationUpdates stops service on generic Exception`() {
- every { locationProvider.requestLocationUpdates(any(), any(), any(), any()) } throws RuntimeException("provider crashed")
+ every { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) } throws RuntimeException("provider crashed")
invokeSetupLocationUpdates()
@@ -1134,7 +1135,7 @@ class LocationForegroundServiceTest {
invokeRecoverStalledStream()
verify { locationProvider.removeLocationUpdates(any()) }
- verify { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -1146,7 +1147,7 @@ class LocationForegroundServiceTest {
invokeRecoverStalledStream()
- verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -1159,7 +1160,7 @@ class LocationForegroundServiceTest {
invokeRecoverStalledStream()
- verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -1171,7 +1172,7 @@ class LocationForegroundServiceTest {
invokeRecoverStalledStream()
- verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -1185,7 +1186,7 @@ class LocationForegroundServiceTest {
advanceTimeBy(5 * 60_000L + 1)
runCurrent()
- verify { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
assertTrue("and it has to keep ticking afterwards", getField<Job?>("trackingHeartbeatJob")?.isActive == true)
}
@@ -1236,7 +1237,7 @@ class LocationForegroundServiceTest {
invokeRecoverStalledStream()
- verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -1248,7 +1249,7 @@ class LocationForegroundServiceTest {
invokeRecoverStalledStream()
- verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -1266,7 +1267,7 @@ class LocationForegroundServiceTest {
invokeRecoverStalledStream()
- verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -1897,7 +1898,7 @@ class LocationForegroundServiceTest {
invokeApplyProfileConfig(interval = 2000L, distance = 5f, syncInterval = 30)
verify { locationProvider.removeLocationUpdates(oldCallback) }
- verify { locationProvider.requestLocationUpdates(2000L, 5f, any(), any()) }
+ verify { locationProvider.requestLocationUpdates(2000L, 5f, any(), any(), any()) }
}
@Test
@@ -1982,10 +1983,25 @@ class LocationForegroundServiceTest {
invokeSetupLocationUpdates()
- verify { locationProvider.requestLocationUpdates(5000L, 50f, any(), any()) }
+ verify { locationProvider.requestLocationUpdates(5000L, 50f, any(), any(), any()) }
assertFalse(getField("lastRequestedBypassOsFilter"))
}
+ @Test
+ fun `setupLocationUpdates passes the configured accuracy mode`() {
+ setField("config", ServiceConfig(
+ endpoint = "https://example.com",
+ interval = 5000L,
+ minUpdateDistance = 0f,
+ accuracyMode = LocationAccuracy.BALANCED
+ ))
+ every { profileManager.getNeededConditionTypes() } returns setOf(ProfileConstants.CONDITION_CHARGING)
+
+ invokeSetupLocationUpdates()
+
+ verify { locationProvider.requestLocationUpdates(5000L, 0f, LocationAccuracy.BALANCED, any(), any()) }
+ }
+
@Test
fun `setupLocationUpdates passes zero when a speed_above profile is enabled`() {
setField("config", ServiceConfig(
@@ -1998,7 +2014,7 @@ class LocationForegroundServiceTest {
invokeSetupLocationUpdates()
- verify { locationProvider.requestLocationUpdates(5000L, 0f, any(), any()) }
+ verify { locationProvider.requestLocationUpdates(5000L, 0f, any(), any(), any()) }
assertTrue(getField("lastRequestedBypassOsFilter"))
}
@@ -2014,7 +2030,7 @@ class LocationForegroundServiceTest {
invokeSetupLocationUpdates()
- verify { locationProvider.requestLocationUpdates(5000L, 0f, any(), any()) }
+ verify { locationProvider.requestLocationUpdates(5000L, 0f, any(), any(), any()) }
}
@Test
@@ -2029,7 +2045,7 @@ class LocationForegroundServiceTest {
invokeSetupLocationUpdates()
- verify { locationProvider.requestLocationUpdates(5000L, 0f, any(), any()) }
+ verify { locationProvider.requestLocationUpdates(5000L, 0f, any(), any(), any()) }
}
@Test
@@ -2048,7 +2064,7 @@ class LocationForegroundServiceTest {
invokeHandleRecheckProfiles()
verify { locationProvider.removeLocationUpdates(existingCallback) }
- verify { locationProvider.requestLocationUpdates(5000L, 0f, any(), any()) }
+ verify { locationProvider.requestLocationUpdates(5000L, 0f, any(), any(), any()) }
}
@Test
@@ -2067,7 +2083,7 @@ class LocationForegroundServiceTest {
invokeHandleRecheckProfiles()
verify(exactly = 0) { locationProvider.removeLocationUpdates(any()) }
- verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -2078,7 +2094,7 @@ class LocationForegroundServiceTest {
invokeHandleRecheckProfiles()
- verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
// =========================================================================
@@ -2191,7 +2207,7 @@ class LocationForegroundServiceTest {
@Test
fun `location callback sheds its registration once the service scope is gone`() {
val registered = slot<LocationUpdateCallback>()
- every { locationProvider.requestLocationUpdates(any(), any(), any(), capture(registered)) } just Runs
+ every { locationProvider.requestLocationUpdates(any(), any(), any(), any(), capture(registered)) } just Runs
invokeSetupLocationUpdates()
setField("serviceScope", null)
@@ -2461,7 +2477,7 @@ class LocationForegroundServiceTest {
invokeExitPauseZone()
- verify { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -2472,7 +2488,7 @@ class LocationForegroundServiceTest {
invokeExitPauseZone()
- verify { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -2484,7 +2500,7 @@ class LocationForegroundServiceTest {
invokeExitPauseZone()
- verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
// =========================================================================
@@ -2557,7 +2573,7 @@ class LocationForegroundServiceTest {
assertFalse(getField<Boolean>("isMotionlessPaused"))
verify { dbHelper.saveSetting("pause_zone_motionless_active", "false") }
- verify { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -2573,7 +2589,7 @@ class LocationForegroundServiceTest {
invokeOnMotionStateChange(MotionState.MOVING)
assertFalse(getField<Boolean>("isMotionlessPaused"))
- verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -2663,7 +2679,7 @@ class LocationForegroundServiceTest {
invokeMaybeResumeGps()
- verify { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -2674,7 +2690,7 @@ class LocationForegroundServiceTest {
invokeMaybeResumeGps()
- verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -2685,7 +2701,7 @@ class LocationForegroundServiceTest {
invokeMaybeResumeGps()
- verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -2694,7 +2710,7 @@ class LocationForegroundServiceTest {
invokeMaybeResumeGps()
- verify { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
// =========================================================================
@@ -2721,7 +2737,7 @@ class LocationForegroundServiceTest {
invokeApplyZoneSettingsIfChanged(homeGeofence) // pauseOnWifi=false
assertFalse(getField<Boolean>("isWifiPaused"))
- verify { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -2736,7 +2752,7 @@ class LocationForegroundServiceTest {
assertFalse(getField<Boolean>("isMotionlessPaused"))
verify { dbHelper.saveSetting("pause_zone_motionless_active", "false") }
- verify { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -2751,7 +2767,7 @@ class LocationForegroundServiceTest {
invokeApplyZoneSettingsIfChanged(homeGeofence)
- verify { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -2766,7 +2782,7 @@ class LocationForegroundServiceTest {
invokeApplyZoneSettingsIfChanged(motionlessGeofence)
- verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -2991,7 +3007,7 @@ class LocationForegroundServiceTest {
invokeSetupLocationUpdates()
- verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -3002,7 +3018,7 @@ class LocationForegroundServiceTest {
invokeSetupLocationUpdates()
- verify { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
// =========================================================================
@@ -3050,7 +3066,7 @@ class LocationForegroundServiceTest {
invokeRestoreMotionlessHold(null, savedActive = true)
invokeSetupLocationUpdates()
- verify { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
// =========================================================================
@@ -3082,7 +3098,7 @@ class LocationForegroundServiceTest {
assertFalse(getField<Boolean>("isWifiPaused"))
assertFalse(getField<Boolean>("isMotionlessPaused"))
- verify { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
// =========================================================================
@@ -3097,7 +3113,7 @@ class LocationForegroundServiceTest {
invokeMaybeResumeGps()
- verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify(exactly = 0) { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
// =========================================================================
@@ -3299,7 +3315,7 @@ class LocationForegroundServiceTest {
invokeGeofenceHeartbeatFired()
- verify { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -3367,7 +3383,7 @@ class LocationForegroundServiceTest {
invokeGeofenceHeartbeatFired(shouldBeTracking = true)
verify(exactly = 0) { service.stopSelf() }
- verify { locationProvider.requestLocationUpdates(any(), any(), any(), any()) }
+ verify { locationProvider.requestLocationUpdates(any(), any(), any(), any(), any()) }
}
@Test
@@ -3530,6 +3546,35 @@ class LocationForegroundServiceTest {
}
}
+ @Test
+ fun `loadConfigFromIntent hands the accuracy mode to the ProfileManager`() {
+ mockkObject(ServiceConfig.Companion)
+ try {
+ every { ServiceConfig.fromDatabase(any()) } returns
+ ServiceConfig(accuracyMode = LocationAccuracy.BALANCED)
+
+ invokeLoadConfigFromIntent(null)
+
+ verify { profileManager.defaultAccuracyMode = LocationAccuracy.BALANCED }
+ } finally {
+ unmockkObject(ServiceConfig.Companion)
+ }
+ }
+
+ @Test
+ fun `loadConfigFromIntent keeps High as the ProfileManager accuracy default`() {
+ mockkObject(ServiceConfig.Companion)
+ try {
+ every { ServiceConfig.fromDatabase(any()) } returns ServiceConfig(accuracyMode = LocationAccuracy.HIGH)
+
+ invokeLoadConfigFromIntent(null)
+
+ verify { profileManager.defaultAccuracyMode = LocationAccuracy.HIGH }
+ } finally {
+ unmockkObject(ServiceConfig.Companion)
+ }
+ }
+
private val homeGeofence = geofence("Home", 52.50, 13.40, 150.0)
private val officeGeofence = geofence("Office", 48.14, 11.58, 200.0)
private val parkGeofence = geofence("Park", 52.51, 13.35, 100.0)
diff --git a/apps/mobile/android/app/src/test/java/com/Colota/service/ProfileManagerTest.kt b/apps/mobile/android/app/src/test/java/com/Colota/service/ProfileManagerTest.kt
index 3ac20a34..bdf77e2b 100644
--- a/apps/mobile/android/app/src/test/java/com/Colota/service/ProfileManagerTest.kt
+++ b/apps/mobile/android/app/src/test/java/com/Colota/service/ProfileManagerTest.kt
@@ -7,6 +7,7 @@ package com.Colota.service
import android.location.Location
import com.Colota.data.ProfileHelper
+import com.Colota.location.LocationAccuracy
import com.Colota.util.AppLogger
import io.mockk.*
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -1301,6 +1302,37 @@ class ProfileManagerTest {
assertEquals("Stationary", switchedProfileName)
}
+ @Test
+ fun `under balanced accuracy a speed-less fix does not count as stillness`() = testScope.runTest {
+ // Balanced hands the stream speed-less network fixes; a missing speed is not proof of stillness
+ val profile = stationaryProfile(activationDelay = 0)
+ every { profileHelper.getEnabledProfiles() } returns listOf(profile)
+
+ val manager = createManager()
+ manager.defaultAccuracyMode = LocationAccuracy.BALANCED
+
+ manager.onLocationUpdate(mockLocation(0f, hasSpeed = false, timeMs = t0))
+ assertNull(switchedProfileName)
+ assertFalse(manager.isStationary)
+
+ // A fix that carries a (real or fallback-derived) speed still decides
+ manager.onLocationUpdate(mockLocation(0.1f, hasSpeed = true, timeMs = t0 + 6_000))
+ assertEquals("Stationary", switchedProfileName)
+ assertTrue(manager.isStationary)
+ }
+
+ @Test
+ fun `high accuracy keeps treating a speed-less fix as stillness`() = testScope.runTest {
+ val profile = stationaryProfile(activationDelay = 0)
+ every { profileHelper.getEnabledProfiles() } returns listOf(profile)
+
+ val manager = createManager()
+ manager.defaultAccuracyMode = LocationAccuracy.HIGH
+
+ manager.onLocationUpdate(mockLocation(0f, hasSpeed = false, timeMs = t0))
+ assertEquals("Stationary", switchedProfileName)
+ }
+
@Test
fun `isStationary reflects current state`() = testScope.runTest {
val profile = stationaryProfile()
diff --git a/apps/mobile/android/app/src/test/java/com/Colota/service/ServiceConfigTest.kt b/apps/mobile/android/app/src/test/java/com/Colota/service/ServiceConfigTest.kt
index 718a21b6..16e329e1 100644
--- a/apps/mobile/android/app/src/test/java/com/Colota/service/ServiceConfigTest.kt
+++ b/apps/mobile/android/app/src/test/java/com/Colota/service/ServiceConfigTest.kt
@@ -8,6 +8,7 @@ package com.Colota.service
import android.content.Intent
import android.os.Bundle
import com.Colota.data.DatabaseHelper
+import com.Colota.location.LocationAccuracy
import com.Colota.sync.ApiFormat
import com.facebook.react.bridge.JavaOnlyMap
import io.mockk.every
@@ -200,6 +201,66 @@ class ServiceConfigTest {
assertEquals(500, ServiceConfig.fromDatabase(tooHigh).overlandBatchSize)
}
+ // --- accuracyMode ---
+
+ @Test
+ fun `fromDatabase reads accuracyMode balanced`() {
+ val db = mockDbHelper(baseSettings + ("accuracyMode" to "balanced"))
+ assertEquals(LocationAccuracy.BALANCED, ServiceConfig.fromDatabase(db).accuracyMode)
+ }
+
+ @Test
+ fun `fromDatabase defaults accuracyMode to high for missing or unknown values`() {
+ assertEquals(LocationAccuracy.HIGH, ServiceConfig.fromDatabase(mockDbHelper(baseSettings)).accuracyMode)
+ assertEquals(
+ LocationAccuracy.HIGH,
+ ServiceConfig.fromDatabase(mockDbHelper(baseSettings + ("accuracyMode" to "low_power"))).accuracyMode
+ )
+ }
+
+ @Test
+ fun `fromReadableMap reads accuracyMode`() {
+ val db = mockDbHelper(baseSettings)
+ val map = JavaOnlyMap().apply { putString("accuracyMode", "balanced") }
+ assertEquals(LocationAccuracy.BALANCED, ServiceConfig.fromReadableMap(map, db).accuracyMode)
+ }
+
+ @Test
+ fun `fromReadableMap falls back to db accuracyMode when the key is absent`() {
+ val db = mockDbHelper(baseSettings + ("accuracyMode" to "balanced"))
+ assertEquals(LocationAccuracy.BALANCED, ServiceConfig.fromReadableMap(JavaOnlyMap(), db).accuracyMode)
+ }
+
+ @Test
+ fun `fromIntent reads accuracyMode from extras`() {
+ val bundle = mockk<Bundle> {
+ every { getString("endpoint") } returns null
+ every { getString("accuracyMode") } returns "balanced"
+ every { containsKey(any()) } returns false
+ every { containsKey("accuracyMode") } returns true
+ }
+ val intent = mockk<Intent> {
+ every { extras } returns bundle
+ }
+ val db = mockDbHelper(baseSettings + ("accuracyMode" to "high"))
+
+ assertEquals(LocationAccuracy.BALANCED, ServiceConfig.fromIntent(intent, db).accuracyMode)
+ }
+
+ @Test
+ fun `fromIntent falls back to db accuracyMode when the extra is absent`() {
+ val bundle = mockk<Bundle> {
+ every { getString("endpoint") } returns null
+ every { containsKey(any()) } returns false
+ }
+ val intent = mockk<Intent> {
+ every { extras } returns bundle
+ }
+ val db = mockDbHelper(baseSettings + ("accuracyMode" to "balanced"))
+
+ assertEquals(LocationAccuracy.BALANCED, ServiceConfig.fromIntent(intent, db).accuracyMode)
+ }
+
// --- data class defaults ---
@Test
@@ -226,6 +287,7 @@ class ServiceConfigTest {
assertEquals(0, config.syncIntervalSeconds)
assertEquals(50.0f, config.accuracyThreshold, 0.001f)
assertFalse(config.filterInaccurateLocations)
+ assertEquals(LocationAccuracy.HIGH, config.accuracyMode)
assertEquals(30, config.retryIntervalSeconds)
assertFalse(config.isOfflineMode)
assertEquals("any", config.syncCondition)
@@ -289,6 +351,7 @@ class ServiceConfigTest {
every { getInt("syncInterval") } returns 300
every { getFloat("accuracyThreshold") } returns 25.0f
every { getBoolean("filterInaccurateLocations") } returns true
+ every { getString("accuracyMode") } returns "balanced"
every { getInt("retryInterval") } returns 60
every { getBoolean("isOfflineMode") } returns true
every { getString("syncCondition") } returns "wifi_any"
@@ -311,6 +374,7 @@ class ServiceConfigTest {
assertEquals(300, config.syncIntervalSeconds)
assertEquals(25.0f, config.accuracyThreshold, 0.001f)
assertTrue(config.filterInaccurateLocations)
+ assertEquals(LocationAccuracy.BALANCED, config.accuracyMode)
assertEquals(60, config.retryIntervalSeconds)
assertTrue(config.isOfflineMode)
assertEquals("wifi_any", config.syncCondition)
@@ -336,6 +400,7 @@ class ServiceConfigTest {
verify { intent.putExtra("interval", 10000L) }
verify { intent.putExtra("syncInterval", 300) }
verify { intent.putExtra("httpMethod", "GET") }
+ verify { intent.putExtra("accuracyMode", "high") }
}
// --- fromReadableMap ---
diff --git a/apps/mobile/android/app/src/testFoss/java/com/Colota/location/NativeLocationProviderTest.kt b/apps/mobile/android/app/src/testFoss/java/com/Colota/location/NativeLocationProviderTest.kt
index 2ba5f827..030e2f2b 100644
--- a/apps/mobile/android/app/src/testFoss/java/com/Colota/location/NativeLocationProviderTest.kt
+++ b/apps/mobile/android/app/src/testFoss/java/com/Colota/location/NativeLocationProviderTest.kt
@@ -7,6 +7,7 @@ package com.Colota.location
import android.content.Context
import android.location.LocationManager
+import androidx.core.location.LocationRequestCompat
import androidx.test.core.app.ApplicationProvider
import org.junit.Assert.assertEquals
import org.junit.Test
@@ -43,4 +44,22 @@ class NativeLocationProviderTest {
assertEquals(LocationManager.GPS_PROVIDER, NativeLocationProvider.selectProvider(locationManager))
}
+
+ @Test
+ fun `maps high accuracy to the high quality request`() {
+ assertEquals(
+ LocationRequestCompat.QUALITY_HIGH_ACCURACY,
+ NativeLocationProvider.qualityFor(LocationAccuracy.HIGH)
+ )
+ assertEquals(100, NativeLocationProvider.qualityFor(LocationAccuracy.HIGH))
+ }
+
+ @Test
+ fun `maps balanced accuracy to the balanced power request`() {
+ assertEquals(
+ LocationRequestCompat.QUALITY_BALANCED_POWER_ACCURACY,
+ NativeLocationProvider.qualityFor(LocationAccuracy.BALANCED)
+ )
+ assertEquals(102, NativeLocationProvider.qualityFor(LocationAccuracy.BALANCED))
+ }
}
diff --git a/apps/mobile/android/app/src/testGms/java/com/Colota/location/GmsLocationProviderTest.kt b/apps/mobile/android/app/src/testGms/java/com/Colota/location/GmsLocationProviderTest.kt
new file mode 100644
index 00000000..14a68de0
--- /dev/null
+++ b/apps/mobile/android/app/src/testGms/java/com/Colota/location/GmsLocationProviderTest.kt
@@ -0,0 +1,28 @@
+/**
+ * Copyright (C) 2026 Max Dietrich
+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.
+ */
+
+package com.Colota.location
+
+import com.google.android.gms.location.Priority
+import org.junit.Assert.assertEquals
+import org.junit.Test
+
+class GmsLocationProviderTest {
+
+ @Test
+ fun `maps high accuracy to the high accuracy priority`() {
+ assertEquals(Priority.PRIORITY_HIGH_ACCURACY, GmsLocationProvider.priorityFor(LocationAccuracy.HIGH))
+ assertEquals(100, GmsLocationProvider.priorityFor(LocationAccuracy.HIGH))
+ }
+
+ @Test
+ fun `maps balanced accuracy to the balanced power priority`() {
+ assertEquals(
+ Priority.PRIORITY_BALANCED_POWER_ACCURACY,
+ GmsLocationProvider.priorityFor(LocationAccuracy.BALANCED)
+ )
+ assertEquals(102, GmsLocationProvider.priorityFor(LocationAccuracy.BALANCED))
+ }
+}
diff --git a/apps/mobile/src/components/features/settings/SyncStrategySettings.tsx b/apps/mobile/src/components/features/settings/SyncStrategySettings.tsx
index 18027ce3..a7c93c70 100644
--- a/apps/mobile/src/components/features/settings/SyncStrategySettings.tsx
+++ b/apps/mobile/src/components/features/settings/SyncStrategySettings.tsx
@@ -11,6 +11,7 @@ import {
TRACKING_PRESETS,
SelectablePreset,
SyncCondition,
+ AccuracyMode,
SavedTrackingProfile
} from "../../../types/global"
import { fonts, fontSizes, lineHeights } from "../../../styles/typography"
@@ -19,6 +20,7 @@ import {
Button,
Card,
Divider,
+ FieldMessage,
NumericInput,
RadioRow,
SectionTitle,
@@ -52,6 +54,11 @@ type NumericKey = "interval" | "distance" | "accuracyThreshold"
const NUMERIC_MIN: Record<NumericKey, number> = { interval: 1, distance: 0, accuracyThreshold: 1 }
+const ACCURACY_MODE_OPTIONS: { value: AccuracyMode; labelKey: TranslationKey; subKey: TranslationKey }[] = [
+ { value: "high", labelKey: "trackingSync.accuracy.high", subKey: "trackingSync.accuracy.high.sub" },
+ { value: "balanced", labelKey: "trackingSync.accuracy.balanced", subKey: "trackingSync.accuracy.balanced.sub" }
+]
+
const SYNC_CONDITION_OPTIONS: { value: SyncCondition; labelKey: TranslationKey; subKey: TranslationKey }[] = [
{ value: "any", labelKey: "trackingSync.condition.any", subKey: "trackingSync.condition.any.sub" },
{ value: "wifi_any", labelKey: "trackingSync.condition.wifiAny", subKey: "trackingSync.condition.wifiAny.sub" },
@@ -388,6 +395,27 @@ export function SyncStrategySettings({
</>
)}
+ <SectionTitle style={styles.groupTop}>{t("trackingSync.accuracy.title")}</SectionTitle>
+ <Card rows>
+ <View accessibilityRole="radiogroup" accessibilityLabel={t("trackingSync.accuracy.title")} style={styles.group}>
+ {ACCURACY_MODE_OPTIONS.map(({ value, labelKey, subKey }) => (
+ <RadioRow
+ key={value}
+ testID={`accuracy-mode-${value}`}
+ label={t(labelKey)}
+ sub={t(subKey)}
+ selected={settings.accuracyMode === value}
+ onPress={() => {
+ const next = { ...settings, accuracyMode: value }
+ onSettingsChange(next)
+ onImmediateSave(next)
+ }}
+ />
+ ))}
+ </View>
+ <FieldMessage style={styles.hintTail}>{t("trackingSync.accuracy.hint")}</FieldMessage>
+ </Card>
+
<SectionTitle style={styles.groupTop}>{t("trackingSync.section.accuracy")}</SectionTitle>
<Card rows>
<SettingRow label={t("trackingSync.filter")} hint={filterHint}>
@@ -447,6 +475,10 @@ const styles = StyleSheet.create({
revealButtonTail: {
paddingBottom: space.sm
},
+ // A rows Card strips its own vertical padding, so the trailing hint has to carry the card's inset.
+ hintTail: {
+ marginBottom: space.lg
+ },
batch: {
paddingTop: space.lg
},
diff --git a/apps/mobile/src/components/features/settings/__tests__/SyncStrategySettings.test.tsx b/apps/mobile/src/components/features/settings/__tests__/SyncStrategySettings.test.tsx
index 3673191b..ccc1d2c1 100644
--- a/apps/mobile/src/components/features/settings/__tests__/SyncStrategySettings.test.tsx
+++ b/apps/mobile/src/components/features/settings/__tests__/SyncStrategySettings.test.tsx
@@ -34,6 +34,7 @@ jest.mock("../../../index", () => {
sub ? R.createElement(Text, null, sub) : null
),
SectionTitle: ({ children }: any) => R.createElement(Text, null, children),
+ FieldMessage: ({ children }: any) => R.createElement(Text, null, children),
Card: ({ children, style }: any) => R.createElement(View, { testID: "card", style }, children),
Divider: () => R.createElement(View, { testID: "divider" }),
StateLine: ({ label, caption, testID }: any) =>
@@ -165,6 +166,7 @@ describe("SyncStrategySettings", () => {
expect(getByText("Recording")).toBeTruthy()
expect(getByText("Sync interval")).toBeTruthy()
expect(getByText("Sync only on")).toBeTruthy()
+ expect(getByText("Positioning accuracy")).toBeTruthy()
expect(getByText("Accuracy filter")).toBeTruthy()
expect(queryByText("Network settings")).toBeNull()
})
@@ -516,6 +518,30 @@ describe("SyncStrategySettings", () => {
})
})
+ describe("positioning accuracy", () => {
+ it("offers High accuracy and Lower accuracy, defaulting to High accuracy", () => {
+ const { getByTestId, getByText } = renderComponent()
+
+ expect(getByText("Positioning accuracy")).toBeTruthy()
+ expect(getByTestId("accuracy-mode-high").props.accessibilityState).toMatchObject({ checked: true })
+ expect(getByTestId("accuracy-mode-balanced").props.accessibilityState).toMatchObject({ checked: false })
+ expect(
+ getByText(
+ "Both options affect the continuous stream only. Fresh checks for geofences and the stationary heartbeat stay high accuracy."
+ )
+ ).toBeTruthy()
+ })
+
+ it("saves Lower accuracy immediately, like the other recording controls", () => {
+ const { getByTestId } = renderComponent({ accuracyMode: "high" })
+
+ fireEvent.press(getByTestId("accuracy-mode-balanced"))
+
+ expect(mockOnSettingsChange).toHaveBeenCalledWith(expect.objectContaining({ accuracyMode: "balanced" }))
+ expect(mockOnImmediateSave).toHaveBeenCalledWith(expect.objectContaining({ accuracyMode: "balanced" }))
+ })
+ })
+
describe("batch size", () => {
const overland = { apiTemplate: "overland" as const }
diff --git a/apps/mobile/src/contexts/TrackingProvider.tsx b/apps/mobile/src/contexts/TrackingProvider.tsx
index 65b6cbbe..73fbde85 100644
--- a/apps/mobile/src/contexts/TrackingProvider.tsx
+++ b/apps/mobile/src/contexts/TrackingProvider.tsx
@@ -63,6 +63,10 @@ export function parseRawSettings(allRaw: Record<string, string>): Settings {
? parseFloat(allRaw.accuracyThreshold)
: DEFAULT_SETTINGS.accuracyThreshold,
+ // Older installs have no stored key; anything unrecognised falls back to High. Match the native
+ // LocationAccuracy.fromWire: trim + case-insensitive, so the two never disagree on a hand-edited value.
+ accuracyMode: allRaw.accuracyMode?.trim().toLowerCase() === "balanced" ? "balanced" : DEFAULT_SETTINGS.accuracyMode,
+
isOfflineMode: allRaw.isOfflineMode === "true",
syncCondition:
(allRaw.syncCondition as any) ?? (allRaw.isWifiOnlySync === "true" ? "wifi_any" : DEFAULT_SETTINGS.syncCondition),
diff --git a/apps/mobile/src/contexts/__tests__/TrackingProvider.test.tsx b/apps/mobile/src/contexts/__tests__/TrackingProvider.test.tsx
index 22e0cf70..7145a778 100644
--- a/apps/mobile/src/contexts/__tests__/TrackingProvider.test.tsx
+++ b/apps/mobile/src/contexts/__tests__/TrackingProvider.test.tsx
@@ -508,4 +508,17 @@ describe("parseRawSettings", () => {
// parseInt("not-a-number", 10) returns NaN, but we should not propagate NaN
expect(Number.isFinite(settings.overlandBatchSize)).toBe(true)
})
+
+ it("round-trips accuracyMode from raw SQLite", () => {
+ expect(parseRawSettings({ accuracyMode: "balanced" }).accuracyMode).toBe("balanced")
+ expect(parseRawSettings({ accuracyMode: "high" }).accuracyMode).toBe("high")
+ // Native fromWire trims and is case-insensitive; the JS fallback matches it exactly
+ expect(parseRawSettings({ accuracyMode: "Balanced" }).accuracyMode).toBe("balanced")
+ expect(parseRawSettings({ accuracyMode: " BALANCED " }).accuracyMode).toBe("balanced")
+ })
+
+ it("defaults accuracyMode to high for installs without the key or with an unknown value", () => {
+ expect(parseRawSettings({}).accuracyMode).toBe("high")
+ expect(parseRawSettings({ accuracyMode: "warp" }).accuracyMode).toBe("high")
+ })
})
diff --git a/apps/mobile/src/i18n/locales/en.json b/apps/mobile/src/i18n/locales/en.json
index ebd47fa6..56f1d1d6 100644
--- a/apps/mobile/src/i18n/locales/en.json
+++ b/apps/mobile/src/i18n/locales/en.json
@@ -902,6 +902,7 @@
"setup.err.none": "No valid settings found in configuration",
"setup.err.publicHttp": "HTTP not allowed for public hosts",
"setup.err.rejected": "{{reason}}. Nothing from this link will be applied.",
+ "setup.field.accuracyMode": "Positioning accuracy",
"setup.field.accuracyThreshold": "Accuracy threshold",
"setup.field.apiTemplate": "API template",
"setup.field.authType": "Auth type",
@@ -964,7 +965,7 @@
"share.sync": "Sync",
"share.sync.sub": "Sync interval, conditions and offline mode",
"share.tracking": "Tracking",
- "share.tracking.sub": "GPS interval, distance and accuracy filter",
+ "share.tracking.sub": "GPS interval, distance, positioning accuracy and accuracy filter",
"share.warning": "This link will contain your {{fields}} in plain text. Anyone who sees the link can read them - only share it over a trusted channel.",
"share.zones_one": "{{n}} zone",
"share.zones_other": "{{n}} zones",
@@ -1075,6 +1076,12 @@
"tracking.sync.every": "syncs every {{duration}}",
"tracking.syncVerb.eachFix": "sync each fix",
"tracking.syncVerb.every": "sync every {{duration}}",
+ "trackingSync.accuracy.balanced": "Lower accuracy",
+ "trackingSync.accuracy.balanced.sub": "Coarser fixes · uses less battery",
+ "trackingSync.accuracy.high": "High accuracy",
+ "trackingSync.accuracy.high.sub": "Most precise fixes · uses more battery",
+ "trackingSync.accuracy.hint": "Both options affect the continuous stream only. Fresh checks for geofences and the stationary heartbeat stay high accuracy.",
+ "trackingSync.accuracy.title": "Positioning accuracy",
"trackingSync.batch": "Batch size",
"trackingSync.batch.hint": "{{min}} to {{max}} points per request. Larger means fewer requests and bigger payloads.",
"trackingSync.batch.range": "{{min}} to {{max}}",
diff --git a/apps/mobile/src/i18n/locales/es.json b/apps/mobile/src/i18n/locales/es.json
index 9fcc7c19..befbc090 100644
--- a/apps/mobile/src/i18n/locales/es.json
+++ b/apps/mobile/src/i18n/locales/es.json
@@ -902,6 +902,7 @@
"setup.err.none": "No se encontró ninguna configuración válida",
"setup.err.publicHttp": "No se permite HTTP para hosts públicos",
"setup.err.rejected": "{{reason}}. No se aplicará nada de este enlace.",
+ "setup.field.accuracyMode": "Precisión de posicionamiento",
"setup.field.accuracyThreshold": "Umbral de precisión",
"setup.field.apiTemplate": "Plantilla de API",
"setup.field.authType": "Tipo de autenticación",
@@ -964,7 +965,7 @@
"share.sync": "Sincronización",
"share.sync.sub": "Intervalo de sincronización, condiciones y modo sin conexión",
"share.tracking": "Seguimiento",
- "share.tracking.sub": "Intervalo de GPS, distancia y filtro de precisión",
+ "share.tracking.sub": "Intervalo de GPS, distancia, precisión de posicionamiento y filtro de precisión",
"share.warning": "Este enlace contendrá tus {{fields}} en texto plano. Cualquiera que vea el enlace puede leerlos - compártelo solo por un canal de confianza.",
"share.zones_one": "{{n}} zona",
"share.zones_other": "{{n}} zonas",
@@ -1075,6 +1076,12 @@
"tracking.sync.every": "sincroniza cada {{duration}}",
"tracking.syncVerb.eachFix": "sincronizar cada posición",
"tracking.syncVerb.every": "sincronizar cada {{duration}}",
+ "trackingSync.accuracy.balanced": "Menor precisión",
+ "trackingSync.accuracy.balanced.sub": "Posiciones más imprecisas · usa menos batería",
+ "trackingSync.accuracy.high": "Alta precisión",
+ "trackingSync.accuracy.high.sub": "Posiciones más precisas · usa más batería",
+ "trackingSync.accuracy.hint": "Ambas opciones afectan solo al flujo continuo. Las comprobaciones puntuales para geocercas y el latido estacionario siguen siendo de alta precisión.",
+ "trackingSync.accuracy.title": "Precisión de posicionamiento",
"trackingSync.batch": "Tamaño de lote",
"trackingSync.batch.hint": "{{min}} a {{max}} puntos por solicitud. Más grande significa menos solicitudes y envíos más grandes.",
"trackingSync.batch.range": "{{min}} a {{max}}",
diff --git a/apps/mobile/src/i18n/locales/zh.json b/apps/mobile/src/i18n/locales/zh.json
index be1b16a3..a7cfe62c 100644
--- a/apps/mobile/src/i18n/locales/zh.json
+++ b/apps/mobile/src/i18n/locales/zh.json
@@ -891,6 +891,7 @@
"setup.err.none": "配置中没有找到有效设置",
"setup.err.publicHttp": "公共主机不允许使用 HTTP",
"setup.err.rejected": "{{reason}},此链接中的任何内容都不会应用。",
+ "setup.field.accuracyMode": "定位精度",
"setup.field.accuracyThreshold": "精度阈值",
"setup.field.apiTemplate": "API 模板",
"setup.field.authType": "身份验证类型",
@@ -953,7 +954,7 @@
"share.sync": "同步",
"share.sync.sub": "同步间隔、条件和离线模式",
"share.tracking": "跟踪",
- "share.tracking.sub": "GPS 间隔、距离和精度筛选",
+ "share.tracking.sub": "GPS 间隔、距离、定位精度和精度筛选",
"share.warning": "此链接将以纯文本包含你的 {{fields}},任何看到链接的人都能读取它们 - 请仅通过可信渠道分享。",
"share.zones_one": "{{n}} 个区域",
"share.zones_other": "{{n}} 个区域",
@@ -1064,6 +1065,12 @@
"tracking.sync.every": "每 {{duration}} 同步",
"tracking.syncVerb.eachFix": "同步每次定位",
"tracking.syncVerb.every": "每 {{duration}} 同步",
+ "trackingSync.accuracy.balanced": "较低精确度",
+ "trackingSync.accuracy.balanced.sub": "更粗糙的定位 · 更省电",
+ "trackingSync.accuracy.high": "高精确度",
+ "trackingSync.accuracy.high.sub": "最精确的定位 · 更耗电",
+ "trackingSync.accuracy.hint": "两个选项都只影响连续定位流。用于地理围栏和静止心跳的单次检查仍使用高精度。",
+ "trackingSync.accuracy.title": "定位精度",
"trackingSync.batch": "批量大小",
"trackingSync.batch.hint": "每个请求 {{min}} 到 {{max}} 个点。数量越大,请求越少,载荷越大。",
"trackingSync.batch.range": "{{min}} 到 {{max}}",
diff --git a/apps/mobile/src/screens/__tests__/ShareSetupScreen.test.tsx b/apps/mobile/src/screens/__tests__/ShareSetupScreen.test.tsx
index ed2017fb..5ea5a751 100644
--- a/apps/mobile/src/screens/__tests__/ShareSetupScreen.test.tsx
+++ b/apps/mobile/src/screens/__tests__/ShareSetupScreen.test.tsx
@@ -60,6 +60,7 @@ jest.mock("../../contexts/TrackingProvider", () => ({
distance: 5,
accuracyThreshold: 50,
filterInaccurateLocations: true,
+ accuracyMode: "balanced",
syncInterval: 0,
retryInterval: 30,
isOfflineMode: false,
@@ -141,6 +142,7 @@ describe("ShareSetupScreen", () => {
const config = decode(shareSpy.mock.calls[0][0].message)
expect(config.interval).toBe(10)
+ expect(config.accuracyMode).toBe("balanced") // the tracking category carries the accuracy mode too
expect(config.endpoint).toBeUndefined() // API not toggled on
expect(config.auth).toBeUndefined() // credentials not toggled on
})
diff --git a/apps/mobile/src/services/NativeLocationService.ts b/apps/mobile/src/services/NativeLocationService.ts
index edff23a3..14a2544d 100644
--- a/apps/mobile/src/services/NativeLocationService.ts
+++ b/apps/mobile/src/services/NativeLocationService.ts
@@ -77,6 +77,7 @@ class NativeLocationService {
retryInterval: settings.retryInterval,
filterInaccurateLocations: settings.filterInaccurateLocations,
accuracyThreshold: settings.accuracyThreshold,
+ accuracyMode: settings.accuracyMode,
isOfflineMode: settings.isOfflineMode,
syncCondition: settings.syncCondition,
syncSsid: settings.syncSsid,
diff --git a/apps/mobile/src/services/SettingsService.ts b/apps/mobile/src/services/SettingsService.ts
index 6f83d059..7f5996a3 100644
--- a/apps/mobile/src/services/SettingsService.ts
+++ b/apps/mobile/src/services/SettingsService.ts
@@ -54,6 +54,7 @@ export const SettingsService = {
case "syncCondition":
case "syncSsid":
+ case "accuracyMode":
stringValue = String(value)
break
diff --git a/apps/mobile/src/services/__tests__/NativeLocationService.test.ts b/apps/mobile/src/services/__tests__/NativeLocationService.test.ts
index 298c188e..b5eb839a 100644
--- a/apps/mobile/src/services/__tests__/NativeLocationService.test.ts
+++ b/apps/mobile/src/services/__tests__/NativeLocationService.test.ts
@@ -125,6 +125,7 @@ describe("NativeLocationService", () => {
retryInterval: 30,
filterInaccurateLocations: false,
accuracyThreshold: 50,
+ accuracyMode: "high" as const,
isOfflineMode: false,
syncCondition: "any" as const,
syncSsid: "",
@@ -149,6 +150,34 @@ describe("NativeLocationService", () => {
)
})
+ it("forwards the positioning accuracy mode to native", async () => {
+ const settings = {
+ interval: 5,
+ distance: 10,
+ endpoint: "https://example.com",
+ fieldMap: { lat: "lat", lon: "lon", acc: "acc" },
+ syncInterval: 0,
+ retryInterval: 30,
+ filterInaccurateLocations: false,
+ accuracyThreshold: 50,
+ accuracyMode: "balanced" as const,
+ isOfflineMode: false,
+ syncCondition: "any" as const,
+ syncSsid: "",
+ customFields: [],
+ apiTemplate: "custom" as const,
+ syncPreset: "instant" as const,
+ httpMethod: "POST" as const,
+ dawarichMode: "single" as const,
+ overlandBatchSize: 50,
+ hasCompletedSetup: false
+ }
+
+ await NativeLocationService.start(settings)
+
+ expect(nativeMock.startService).toHaveBeenCalledWith(expect.objectContaining({ accuracyMode: "balanced" }))
+ })
+
it("passes apiTemplate and httpMethod GET to native for traccar template", async () => {
const settings = {
interval: 5,
@@ -159,6 +188,7 @@ describe("NativeLocationService", () => {
retryInterval: 30,
filterInaccurateLocations: false,
accuracyThreshold: 50,
+ accuracyMode: "high" as const,
isOfflineMode: false,
syncCondition: "any" as const,
syncSsid: "",
@@ -191,6 +221,7 @@ describe("NativeLocationService", () => {
retryInterval: 30,
filterInaccurateLocations: false,
accuracyThreshold: 50,
+ accuracyMode: "high" as const,
isOfflineMode: false,
syncCondition: "any" as const,
syncSsid: "",
diff --git a/apps/mobile/src/services/__tests__/SettingsService.test.ts b/apps/mobile/src/services/__tests__/SettingsService.test.ts
index efed9638..e0491c3a 100644
--- a/apps/mobile/src/services/__tests__/SettingsService.test.ts
+++ b/apps/mobile/src/services/__tests__/SettingsService.test.ts
@@ -54,6 +54,11 @@ describe("SettingsService", () => {
expect(mockSaveSetting).toHaveBeenCalledWith("filterInaccurateLocations", "true")
})
+ it("saves accuracyMode unchanged under the same key", async () => {
+ await SettingsService.updateSetting("accuracyMode", "balanced")
+ expect(mockSaveSetting).toHaveBeenCalledWith("accuracyMode", "balanced")
+ })
+
it("saves syncInterval as string number", async () => {
await SettingsService.updateSetting("syncInterval", 300)
expect(mockSaveSetting).toHaveBeenCalledWith("syncInterval", "300")
diff --git a/apps/mobile/src/types/__tests__/defaults.test.ts b/apps/mobile/src/types/__tests__/defaults.test.ts
index 78eabd69..9d339ee5 100644
--- a/apps/mobile/src/types/__tests__/defaults.test.ts
+++ b/apps/mobile/src/types/__tests__/defaults.test.ts
@@ -64,6 +64,10 @@ describe("DEFAULT_SETTINGS", () => {
expect(DEFAULT_SETTINGS.overlandBatchSize).toBe(50)
})
+ it("defaults positioning accuracy to high, preserving the historical behaviour", () => {
+ expect(DEFAULT_SETTINGS.accuracyMode).toBe("high")
+ })
+
it("has all required Settings keys", () => {
const requiredKeys: (keyof Settings)[] = [
"interval",
@@ -78,6 +82,7 @@ describe("DEFAULT_SETTINGS", () => {
"syncPreset",
"filterInaccurateLocations",
"accuracyThreshold",
+ "accuracyMode",
"httpMethod",
"dawarichMode",
"overlandBatchSize"
diff --git a/apps/mobile/src/types/global.ts b/apps/mobile/src/types/global.ts
index 84606daa..0c2ea9c2 100644
--- a/apps/mobile/src/types/global.ts
+++ b/apps/mobile/src/types/global.ts
@@ -110,6 +110,9 @@ export type HttpMethod = "POST" | "GET"
export type SyncCondition = "any" | "wifi_any" | "wifi_ssid" | "vpn"
+/** Positioning accuracy of the continuous location stream (#951). */
+export type AccuracyMode = "high" | "balanced"
+
export type ApiTemplateName =
"custom" | "dawarich" | "geopulse" | "overland" | "owntracks" | "phonetrack" | "reitti" | "traccar"
@@ -316,6 +319,7 @@ export interface Settings {
distance: number
filterInaccurateLocations: boolean
accuracyThreshold: number
+ accuracyMode: AccuracyMode
// Endpoint & Mapping
endpoint: string
@@ -348,6 +352,7 @@ export const DEFAULT_SETTINGS: Settings = {
retryInterval: TRACKING_PRESETS.instant.retryInterval,
filterInaccurateLocations: false,
accuracyThreshold: 50,
+ accuracyMode: "high",
syncPreset: "instant",
isOfflineMode: false,
syncCondition: "any",
diff --git a/apps/mobile/src/utils/__tests__/setupLink.test.ts b/apps/mobile/src/utils/__tests__/setupLink.test.ts
index 12a0b916..8c8e8d23 100644
--- a/apps/mobile/src/utils/__tests__/setupLink.test.ts
+++ b/apps/mobile/src/utils/__tests__/setupLink.test.ts
@@ -14,6 +14,7 @@ const settings = {
distance: 5,
filterInaccurateLocations: true,
accuracyThreshold: 50,
+ accuracyMode: "balanced",
endpoint: "https://example.com/api",
fieldMap: { lat: "latitude" },
customFields: [{ key: "device", value: "phone" }],
@@ -101,6 +102,7 @@ describe("setupLink", () => {
// tracking + sync + api
expect(result.config.settings.interval).toBe(10)
expect(result.config.settings.accuracyThreshold).toBe(50)
+ expect(result.config.settings.accuracyMode).toBe("balanced")
expect(result.config.settings.syncInterval).toBe(0)
expect(result.config.settings.endpoint).toBe("https://example.com/api")
// The import screen finds the endpoint by this id to give it its own block; the label translates.
@@ -121,6 +123,25 @@ describe("setupLink", () => {
expect(result.config.profiles[1]).not.toHaveProperty("id")
})
+ it("reads a valid positioning accuracy mode and rejects anything else", () => {
+ expect(validateConfig({ interval: 10, accuracyMode: "balanced" }).config.settings.accuracyMode).toBe("balanced")
+ expect(validateConfig({ interval: 10, accuracyMode: "high" }).config.settings.accuracyMode).toBe("high")
+
+ // Strict, like the sibling enum fields: the value is app-generated, so casing, whitespace and type all lose.
+ expect(validateConfig({ interval: 10, accuracyMode: "turbo" }).config.settings.accuracyMode).toBeUndefined()
+ expect(validateConfig({ interval: 10, accuracyMode: 1 }).config.settings.accuracyMode).toBeUndefined()
+ expect(validateConfig({ interval: 10, accuracyMode: null }).config.settings.accuracyMode).toBeUndefined()
+ expect(validateConfig({ interval: 10, accuracyMode: " Balanced " }).config.settings.accuracyMode).toBeUndefined()
+
+ const entry = validateConfig({ interval: 10, accuracyMode: "balanced" }).entries.find(
+ (e) => e.field === "accuracyMode"
+ )
+ expect(entry).toMatchObject({ field: "accuracyMode", category: "tracking" })
+
+ // An invalid mode alone is not a setting, so the link carries nothing to apply.
+ expect(validateConfig({ accuracyMode: "turbo" }).valid).toBe(false)
+ })
+
it("omits credentials entirely when that category is unchecked", () => {
const config = buildSetupConfig(parts, { ...ALL, credentials: false })
diff --git a/apps/mobile/src/utils/setupConfig.ts b/apps/mobile/src/utils/setupConfig.ts
index 7bb603b7..d8f80871 100644
--- a/apps/mobile/src/utils/setupConfig.ts
+++ b/apps/mobile/src/utils/setupConfig.ts
@@ -186,6 +186,18 @@ export function validateConfig(raw: unknown): ValidationResult {
})
}
+ // Strict exact match, unlike the running app's settings (trimmed/case-insensitive): the value is
+ // machine-generated, and the sibling enum fields (httpMethod, dawarichMode, ...) parse the same way.
+ if ("accuracyMode" in obj && (obj.accuracyMode === "high" || obj.accuracyMode === "balanced")) {
+ settings.accuracyMode = obj.accuracyMode
+ entries.push({
+ field: "accuracyMode",
+ label: t("setup.field.accuracyMode"),
+ value: t(obj.accuracyMode === "balanced" ? "trackingSync.accuracy.balanced" : "trackingSync.accuracy.high"),
+ category: "tracking"
+ })
+ }
+
if ("isOfflineMode" in obj && typeof obj.isOfflineMode === "boolean") {
settings.isOfflineMode = obj.isOfflineMode
entries.push({
diff --git a/apps/mobile/src/utils/setupLink.ts b/apps/mobile/src/utils/setupLink.ts
index b08b7cce..d1f60f3c 100644
--- a/apps/mobile/src/utils/setupLink.ts
+++ b/apps/mobile/src/utils/setupLink.ts
@@ -36,6 +36,7 @@ export function buildSetupConfig(parts: SetupShareParts, sel: SetupShareSelectio
config.distance = settings.distance
config.accuracyThreshold = settings.accuracyThreshold
config.filterInaccurateLocations = settings.filterInaccurateLocations
+ config.accuracyMode = settings.accuracyMode
}
if (sel.sync) {
diff --git a/fastlane/metadata/android/en-US/changelogs/53.txt b/fastlane/metadata/android/en-US/changelogs/53.txt
index 3af31061..0399acc2 100644
--- a/fastlane/metadata/android/en-US/changelogs/53.txt
+++ b/fastlane/metadata/android/en-US/changelogs/53.txt
@@ -1,2 +1,3 @@
- Less memory used when opening a day with many points and when sending a large upload backlog
- Fixed a trip's average speed and its speed and elevation charts being skewed towards stretches recorded with more points
+- Positioning accuracy setting in Tracking & sync: High accuracy (default) or Lower accuracy to save battery