Colota - Android GPS Location tracker
feat: replace wifi-only toggle with flexible sync conditions
Max Dietrich7e3aa8d8d833
diff --git a/README.md b/README.mdindex e983b047..6d8dfa06 100644--- a/README.md+++ b/README.md@@ -23,7 +23,7 @@ Colota sends your location to your own server over HTTP(S). It works offline, su- **Reliable Tracking** - Foreground service, auto-start on boot and exponential backoff retry.- **Geofencing** - Pause zones that automatically stop recording locations.- **Tracking Profiles** - Automatically adjust GPS interval, distance filter and sync settings based on conditions like charging, car mode or speed.-- **Flexible Sync** - Instant, batch, Wi-Fi only or offline modes.+- **Flexible Sync** - Instant, batch or offline modes. Restrict sync to Wi-Fi, a specific SSID or VPN.- **Display Settings** - Choose between metric and imperial units, 12h or 24h time format. Auto-detected from device locale on first use.- **App Shortcuts** - Long-press the app icon to start or stop tracking directly from the home screen, compatible with automation apps like Tasker and Samsung Routines.- **Quick Setup** - Configure devices via `colota://setup` deep links or QR codes.diff --git a/apps/docs/docs/configuration/server-settings.md b/apps/docs/docs/configuration/server-settings.mdindex 5d158519..e79ce7ac 100644--- a/apps/docs/docs/configuration/server-settings.md+++ b/apps/docs/docs/configuration/server-settings.md@@ -55,7 +55,7 @@ The UI simplifies to remove sync-related elements that don't apply:- Server Endpoint and Test Connection- Authentication & Headers- API Field Mapping-- Sync Interval, Wi-Fi Only Sync+- Sync Interval, Sync Condition (Any / Wi-Fi / SSID / VPN)- Queue statistics (Queued / Sent counts)- Queue actions (Sync Now, Clear Sent History, Clear Queue)- Queue info in the tracking notificationdiff --git a/apps/docs/docs/configuration/sync-presets.md b/apps/docs/docs/configuration/sync-presets.mdindex b942944d..967ee275 100644--- a/apps/docs/docs/configuration/sync-presets.md+++ b/apps/docs/docs/configuration/sync-presets.md@@ -15,18 +15,25 @@ Colota includes built-in presets that configure tracking interval, movement threSelect a preset in **Settings** or choose **Custom** to configure each parameter individually.-## Wi-Fi Only Sync+## Sync Condition-When enabled, Colota queues locations locally and only uploads when connected to an unmetered network (Wi-Fi, Ethernet). Uploads are skipped on cellular data.+Controls when Colota uploads locations. Locations are always recorded and queued locally regardless of this setting.++| Option | Behavior |+| ----------------- | ------------------------------------------------------ |+| **Any Network** | Upload on any connection (default) |+| **Wi-Fi Only** | Upload only on unmetered networks (Wi-Fi, Ethernet) |+| **Specific SSID** | Upload only when connected to a specific Wi-Fi network |+| **VPN** | Upload only when a VPN connection is active |This is useful for:- **Limited mobile data** - Avoid using cellular bandwidth for location uploads+- **Private backends** - Only sync when on your home network or VPN- **Roaming** - Prevent expensive data charges while traveling abroad-- **Battery savings** - Reduce radio usage on metered connections-Toggle this in **Settings > Advanced Settings > Network Settings > Wi-Fi Only Sync**. Locations continue to be recorded and queued regardless of this setting - they sync automatically once Wi-Fi is available.+Configure this in **Settings > Advanced Settings > Network Settings > Sync Only On**.## Offline Mode-In [offline mode](/docs/configuration/server-settings#offline-mode), network settings (sync interval, retry behavior, Wi-Fi only sync) are hidden since no syncing occurs. Preset descriptions adjust to show only tracking parameters.+In [offline mode](/docs/configuration/server-settings#offline-mode), network settings (sync interval, retry behavior, sync condition) are hidden since no syncing occurs. Preset descriptions adjust to show only tracking parameters.diff --git a/apps/docs/docs/development/architecture.md b/apps/docs/docs/development/architecture.mdindex c620b7be..acba9baf 100644--- a/apps/docs/docs/development/architecture.md+++ b/apps/docs/docs/development/architecture.md@@ -129,7 +129,7 @@ Orchestrates batch location uploads with:### NetworkManager-HTTP client. Validates endpoints, enforces HTTPS for public hosts, injects auth headers, caches connectivity checks, and detects unmetered connections for Wi-Fi only sync.+HTTP client. Validates endpoints, enforces HTTPS for public hosts, injects auth headers, caches connectivity checks, and detects unmetered connections, specific SSIDs and VPN status for sync condition filtering.### GeofenceHelperdiff --git a/apps/docs/docs/development/permissions.md b/apps/docs/docs/development/permissions.mdindex aeb085d9..c4599dff 100644--- a/apps/docs/docs/development/permissions.md+++ b/apps/docs/docs/development/permissions.md@@ -17,6 +17,7 @@ These are the permissions Colota uses and why. None are related to analytics, ad| Foreground Service (Data Sync) | Yes | Auto-export background processing || Internet | Yes | Send locations to your server || Network State | Yes | Check connectivity before syncing |+| Wi-Fi State | Yes | Detect current SSID for sync condition filtering || Boot Completed | Yes | Auto-restart tracking after device reboot || Notifications | Android 13+ | Display the foreground service notification || Local Network Access | Android 17+ | Access local network servers (self-hosted) |@@ -62,9 +63,10 @@ Android requires apps to declare a foreground service with a persistent notifica```android.permission.INTERNETandroid.permission.ACCESS_NETWORK_STATE+android.permission.ACCESS_WIFI_STATE```-**Internet** is needed to POST location data to your configured server endpoint. **Network State** lets the app check for connectivity before attempting to sync, avoiding unnecessary failures.+**Internet** is needed to POST location data to your configured server endpoint. **Network State** lets the app check for connectivity before attempting to sync, avoiding unnecessary failures. **Wi-Fi State** is used to read the current Wi-Fi SSID when the sync condition is set to a specific network.### Boot Completeddiff --git a/apps/docs/docs/guides/deep-link-setup.md b/apps/docs/docs/guides/deep-link-setup.mdindex ae4933ee..006b741e 100644--- a/apps/docs/docs/guides/deep-link-setup.md+++ b/apps/docs/docs/guides/deep-link-setup.md@@ -26,7 +26,8 @@ The `config` parameter is a base64-encoded JSON object. Only include the setting"accuracyThreshold": 50,"filterInaccurateLocations": true,"isOfflineMode": false,- "isWifiOnlySync": false,+ "syncCondition": "any",+ "syncSsid": "","apiTemplate": "owntracks","httpMethod": "POST","fieldMap": {@@ -67,7 +68,8 @@ The `config` parameter is a base64-encoded JSON object. Only include the setting| `accuracyThreshold` | number | Discard locations less accurate than this (meters) || `filterInaccurateLocations` | boolean | Enable accuracy filtering || `isOfflineMode` | boolean | Store locally only, never sync |-| `isWifiOnlySync` | boolean | Only sync on Wi-Fi |+| `syncCondition` | string | `any`, `wifi_any`, `wifi_ssid`, or `vpn` |+| `syncSsid` | string | Wi-Fi SSID to sync on (only used with `wifi_ssid`) || `apiTemplate` | string | `custom`, `dawarich`, `geopulse`, `owntracks`, `phonetrack`, `reitti`, or `traccar` || `httpMethod` | string | `POST` or `GET` || `fieldMap` | object | Custom field name mapping for the JSON payload |diff --git a/apps/docs/docs/guides/troubleshooting.md b/apps/docs/docs/guides/troubleshooting.mdindex a28af18f..f3217534 100644--- a/apps/docs/docs/guides/troubleshooting.md+++ b/apps/docs/docs/guides/troubleshooting.md@@ -32,7 +32,7 @@ sidebar_position: 44. Verify network connectivity5. Check the queue count in **Data Management**-**Common causes**: Wrong URL, HTTPS required for public endpoints, expired SSL certificate, incorrect authentication, mismatched field mapping, self-signed certificate (install your CA via Settings → Security → Encryption & credentials), **Wi-Fi Only Sync** enabled while on cellular data, missing local network permission on Android 16+.+**Common causes**: Wrong URL, HTTPS required for public endpoints, expired SSL certificate, incorrect authentication, mismatched field mapping, self-signed certificate (install your CA via Settings → Security → Encryption & credentials), **Sync Condition** restricting uploads to a specific network (Wi-Fi, SSID or VPN), missing local network permission on Android 16+.## Exporting app logs@@ -81,11 +81,11 @@ If sync to a local server stopped working after an Android update:If you denied the permission and the system no longer shows the dialog, reset it from Android Settings.-## Locations not syncing on mobile data+## Locations not syncing on certain networks-If **Wi-Fi Only Sync** is enabled, uploads are skipped while on cellular data. Locations continue to be recorded and queued locally - they sync automatically when you connect to Wi-Fi.+If **Sync Only On** is set to Wi-Fi, a specific SSID or VPN, uploads are skipped when the condition is not met. Locations continue to be recorded and queued locally - they sync automatically when the condition is satisfied.-To disable: **Settings > Advanced Settings > Network Settings > Wi-Fi Only Sync**.+To change: **Settings > Advanced Settings > Network Settings > Sync Only On**.## Auto-export not workingdiff --git a/apps/docs/src/pages/privacy-policy.md b/apps/docs/src/pages/privacy-policy.mdindex 59c0fb94..8ed86441 100644--- a/apps/docs/src/pages/privacy-policy.md+++ b/apps/docs/src/pages/privacy-policy.md@@ -103,19 +103,20 @@ Since all data is stored locally on your device, you have full control:## Permissions-| Permission | Purpose |-| --------------------------------- | -------------------------------------------------- |-| Location (Precise) | GPS tracking |-| Location (Approximate) | Required alongside precise location on Android |-| Background Location (Android 10+) | Tracking while the app is not in the foreground |-| Foreground Service | Background tracking with notification |-| Foreground Service (Location) | Location access while tracking in the background |-| Foreground Service (Data Sync) | Auto-export background processing |-| Notification (Android 13+) | Foreground service notification |-| Boot Completed | Auto-start tracking after device reboot |-| Internet | Server sync and map tile loading |-| Network State | Wi-Fi only sync and WiFi pause in geofence zones |-| Battery Optimization Exemption | Optional, prevents system from restricting the app |+| Permission | Purpose |+| --------------------------------- | ------------------------------------------------------ |+| Location (Precise) | GPS tracking |+| Location (Approximate) | Required alongside precise location on Android |+| Background Location (Android 10+) | Tracking while the app is not in the foreground |+| Foreground Service | Background tracking with notification |+| Foreground Service (Location) | Location access while tracking in the background |+| Foreground Service (Data Sync) | Auto-export background processing |+| Notification (Android 13+) | Foreground service notification |+| Boot Completed | Auto-start tracking after device reboot |+| Internet | Server sync and map tile loading |+| Network State | Sync condition checks and WiFi pause in geofence zones |+| Wi-Fi State | SSID detection for sync condition filtering |+| Battery Optimization Exemption | Optional, prevents system from restricting the app |## Children's Privacydiff --git a/apps/mobile/android/app/src/main/AndroidManifest.xml b/apps/mobile/android/app/src/main/AndroidManifest.xmlindex 7555d3d2..d6f32959 100644--- a/apps/mobile/android/app/src/main/AndroidManifest.xml+++ b/apps/mobile/android/app/src/main/AndroidManifest.xml@@ -27,6 +27,7 @@<!-- Network permissions --><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><uses-permission android:name="android.permission.ACCESS_LOCAL_NETWORK" /><!-- Boot Receiver -->diff --git a/apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.kt b/apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.ktindex 63832061..6d5488be 100644--- a/apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.kt+++ b/apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.kt@@ -844,6 +844,11 @@ class LocationServiceModule(reactContext: ReactApplicationContext) :promise.resolve(networkManager.isUnmeteredConnection())}+ @ReactMethod+ fun getCurrentSsid(promise: Promise) {+ promise.resolve(networkManager.getCurrentSsid())+ }+@ReactMethodfun getAvailableStorageMB(promise: Promise) {try {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.ktindex bdb73e61..a7f32c53 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@@ -163,7 +163,8 @@ class DatabaseHelper private constructor(context: Context) :"filterInaccurateLocations" to "false","retryInterval" to "30","isOfflineMode" to "false",- "isWifiOnlySync" to "false",+ "syncCondition" to "any",+ "syncSsid" to "","customFields" to "[]","hasCompletedSetup" to "false","tracking_enabled" to "false",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.ktindex 61a74bf2..bb7ecf4d 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@@ -239,7 +239,7 @@ class LocationForegroundService : Service() {}if (!config.isOfflineMode && config.syncIntervalSeconds == 0 && config.endpoint.isNotBlank() &&- !(config.isWifiOnlySync && !networkManager.isUnmeteredConnection())) {+ syncManager.isSyncAllowed()) {syncManager.manualFlush()}}@@ -261,6 +261,7 @@ class LocationForegroundService : Service() {conditionMonitor.stop()stopLocationUpdates()syncManager.stopPeriodicSync()+ networkManager.destroy()serviceScope?.cancel()serviceScope = null@@ -928,7 +929,8 @@ class LocationForegroundService : Service() {syncIntervalSeconds = config.syncIntervalSeconds,retryIntervalSeconds = config.retryIntervalSeconds,isOfflineMode = config.isOfflineMode,- isWifiOnlySync = config.isWifiOnlySync,+ syncCondition = config.syncCondition,+ syncSsid = config.syncSsid,authHeaders = secureStorage.getAuthHeaders(),httpMethod = config.httpMethod,apiFormat = config.apiFormatdiff --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.ktindex 391a000d..4a6f804a 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@@ -24,7 +24,8 @@ data class ServiceConfig(val filterInaccurateLocations: Boolean = false,val retryIntervalSeconds: Int = 30,val isOfflineMode: Boolean = false,- val isWifiOnlySync: Boolean = false,+ val syncCondition: String = "any",+ val syncSsid: String = "",val fieldMap: String? = null,val customFields: String? = null,val httpMethod: String = "POST",@@ -46,7 +47,8 @@ data class ServiceConfig(filterInaccurateLocations = saved["filterInaccurateLocations"]?.toBoolean() ?: false,retryIntervalSeconds = saved["retryInterval"]?.toIntOrNull() ?: 30,isOfflineMode = saved["isOfflineMode"]?.toBoolean() ?: false,- isWifiOnlySync = saved["isWifiOnlySync"]?.toBoolean() ?: false,+ syncCondition = saved["syncCondition"] ?: if (saved["isWifiOnlySync"]?.toBoolean() == true) "wifi_any" else "any",+ syncSsid = saved["syncSsid"] ?: "",fieldMap = saved["fieldMap"],customFields = saved["customFields"],httpMethod = httpMethod,@@ -90,7 +92,8 @@ data class ServiceConfig(filterInaccurateLocations = config.getBooleanOrNull("filterInaccurateLocations") ?: dbConfig.filterInaccurateLocations,retryIntervalSeconds = config.getIntOrNull("retryInterval") ?: dbConfig.retryIntervalSeconds,isOfflineMode = config.getBooleanOrNull("isOfflineMode") ?: dbConfig.isOfflineMode,- isWifiOnlySync = config.getBooleanOrNull("isWifiOnlySync") ?: dbConfig.isWifiOnlySync,+ syncCondition = config.getStringOrNull("syncCondition") ?: dbConfig.syncCondition,+ syncSsid = config.getStringOrNull("syncSsid") ?: dbConfig.syncSsid,fieldMap = fieldMapJson ?: dbConfig.fieldMap,customFields = customFieldsJson ?: dbConfig.customFields,httpMethod = httpMethod,@@ -111,7 +114,8 @@ data class ServiceConfig(filterInaccurateLocations = extras.getBooleanOrDefault("filterInaccurateLocations", dbConfig.filterInaccurateLocations),retryIntervalSeconds = extras.getIntOrDefault("retryInterval", dbConfig.retryIntervalSeconds),isOfflineMode = extras.getBooleanOrDefault("isOfflineMode", dbConfig.isOfflineMode),- isWifiOnlySync = extras.getBooleanOrDefault("isWifiOnlySync", dbConfig.isWifiOnlySync),+ syncCondition = extras.getStringOrDefault("syncCondition", dbConfig.syncCondition) ?: "any",+ syncSsid = extras.getStringOrDefault("syncSsid", dbConfig.syncSsid) ?: "",fieldMap = extras.getStringOrDefault("fieldMap", dbConfig.fieldMap),customFields = extras.getStringOrDefault("customFields", dbConfig.customFields),httpMethod = extras.getStringOrDefault("httpMethod", dbConfig.httpMethod) ?: "POST",@@ -130,7 +134,8 @@ data class ServiceConfig(putExtra("filterInaccurateLocations", filterInaccurateLocations)putExtra("retryInterval", retryIntervalSeconds)putExtra("isOfflineMode", isOfflineMode)- putExtra("isWifiOnlySync", isWifiOnlySync)+ putExtra("syncCondition", syncCondition)+ putExtra("syncSsid", syncSsid)fieldMap?.let { putExtra("fieldMap", it) }customFields?.let { putExtra("customFields", it) }putExtra("httpMethod", httpMethod)diff --git a/apps/mobile/android/app/src/main/java/com/colota/sync/NetworkManager.kt b/apps/mobile/android/app/src/main/java/com/colota/sync/NetworkManager.ktindex be4d02c1..d6cbe8a2 100644--- a/apps/mobile/android/app/src/main/java/com/colota/sync/NetworkManager.kt+++ b/apps/mobile/android/app/src/main/java/com/colota/sync/NetworkManager.kt@@ -1,10 +1,12 @@package com.Colota.syncimport android.content.Context+import android.net.wifi.WifiInfoimport com.Colota.BuildConfigimport com.Colota.util.AppLoggerimport com.Colota.util.TimedCacheimport android.net.ConnectivityManager+import android.net.Networkimport android.net.NetworkCapabilitiesimport kotlinx.coroutines.Dispatchersimport kotlinx.coroutines.withContext@@ -29,6 +31,30 @@ class NetworkManager(private val context: Context) {private val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager+ @Volatile private var currentSsid: String = ""+ @Volatile private var isVpn: Boolean = false++ private val networkCallback = object : ConnectivityManager.NetworkCallback(FLAG_INCLUDE_LOCATION_INFO) {+ override fun onCapabilitiesChanged(network: Network, caps: NetworkCapabilities) {+ val wifiInfo = caps.transportInfo as? WifiInfo+ currentSsid = wifiInfo?.ssid?.removeSurrounding("\"") ?: ""+ isVpn = caps.hasTransport(NetworkCapabilities.TRANSPORT_VPN)+ }++ override fun onLost(network: Network) {+ currentSsid = ""+ isVpn = false+ }+ }++ init {+ try {+ connectivityManager.registerDefaultNetworkCallback(networkCallback)+ } catch (e: Exception) {+ AppLogger.e(TAG, "Failed to register network callback", e)+ }+ }+private val networkCache = TimedCache(NETWORK_CHECK_CACHE_MS) {try {val network = connectivityManager.activeNetwork@@ -295,4 +321,27 @@ class NetworkManager(private val context: Context) {* Cached for [NETWORK_CHECK_CACHE_MS] to avoid repeated IPC calls.*/fun isUnmeteredConnection(): Boolean = unmeteredCache.get()++ /**+ * Returns true when connected to a WiFi network matching the given SSID.+ * SSID is updated via NetworkCallback with FLAG_INCLUDE_LOCATION_INFO.+ */+ fun isConnectedToSsid(ssid: String): Boolean {+ if (ssid.isBlank()) return false+ return currentSsid.equals(ssid, ignoreCase = true)+ }++ /**+ * Returns true when the active network uses a VPN transport.+ * Updated via NetworkCallback.+ */+ fun isVpnConnected(): Boolean = isVpn++ fun getCurrentSsid(): String = currentSsid++ fun destroy() {+ try {+ connectivityManager.unregisterNetworkCallback(networkCallback)+ } catch (_: Exception) {}+ }}\ No newline at end of filediff --git a/apps/mobile/android/app/src/main/java/com/colota/sync/SyncManager.kt b/apps/mobile/android/app/src/main/java/com/colota/sync/SyncManager.ktindex 0dad87c3..605e6240 100644--- a/apps/mobile/android/app/src/main/java/com/colota/sync/SyncManager.kt+++ b/apps/mobile/android/app/src/main/java/com/colota/sync/SyncManager.kt@@ -30,7 +30,8 @@ class SyncManager(@Volatile private var syncIntervalSeconds: Int = 0@Volatile private var retryIntervalSeconds: Int = 300@Volatile private var isOfflineMode: Boolean = false- @Volatile private var isWifiOnlySync: Boolean = false+ @Volatile private var syncCondition: String = "any"+ @Volatile private var syncSsid: String = ""@Volatile private var authHeaders: Map<String, String> = emptyMap()@Volatile private var httpMethod: String = "POST"@Volatile private var apiFormat: String = ""@@ -49,7 +50,8 @@ class SyncManager(syncIntervalSeconds: Int,retryIntervalSeconds: Int,isOfflineMode: Boolean,- isWifiOnlySync: Boolean,+ syncCondition: String,+ syncSsid: String,authHeaders: Map<String, String>,httpMethod: String = "POST",apiFormat: String = ""@@ -58,7 +60,8 @@ class SyncManager(this.syncIntervalSeconds = syncIntervalSecondsthis.retryIntervalSeconds = retryIntervalSecondsthis.isOfflineMode = isOfflineMode- this.isWifiOnlySync = isWifiOnlySync+ this.syncCondition = syncCondition+ this.syncSsid = syncSsidthis.authHeaders = authHeadersthis.httpMethod = httpMethodthis.apiFormat = apiFormat@@ -71,8 +74,7 @@ class SyncManager(val baseDelay = calculateNextSyncDelay()delay(baseDelay * 1000L)- if (isOfflineMode || !networkManager.isNetworkAvailable() ||- (isWifiOnlySync && !networkManager.isUnmeteredConnection())) {+ if (!isSyncAllowed()) {continue}@@ -139,8 +141,7 @@ class SyncManager(}// Immediate send mode (syncInterval = 0)- if (syncIntervalSeconds == 0 && networkManager.isNetworkAvailable() &&- !(isWifiOnlySync && !networkManager.isUnmeteredConnection())) {+ if (syncIntervalSeconds == 0 && isSyncAllowed()) {AppLogger.d(TAG, "Instant send")val success = networkManager.sendToEndpoint(payload, endpoint, authHeaders, httpMethod, apiFormat)@@ -156,6 +157,20 @@ class SyncManager(// If syncInterval > 0, the periodic sync job will handle it}+ fun isSyncAllowed(): Boolean {+ if (isOfflineMode || !networkManager.isNetworkAvailable()) return false+ val allowed = when (syncCondition) {+ "wifi_any" -> networkManager.isUnmeteredConnection()+ "wifi_ssid" -> networkManager.isConnectedToSsid(syncSsid)+ "vpn" -> networkManager.isVpnConnected()+ else -> true // "any"+ }+ if (!allowed && syncCondition != "any") {+ AppLogger.d(TAG, "Sync skipped: condition=$syncCondition not met")+ }+ return allowed+ }+fun getCachedQueuedCount(): Int = queueCountCache.get()fun invalidateQueueCache() = queueCountCache.invalidate()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.ktindex 0b121077..3ff5fb70 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.data.GeofenceHelperimport com.Colota.location.LocationProviderimport com.Colota.location.LocationUpdateCallbackimport com.Colota.sync.PayloadBuilder+import com.Colota.sync.NetworkManagerimport com.Colota.sync.SyncManagerimport com.Colota.util.AppLoggerimport com.Colota.util.DeviceInfoHelper@@ -44,6 +45,7 @@ class LocationForegroundServiceTest {private lateinit var profileManager: ProfileManagerprivate lateinit var conditionMonitor: ConditionMonitorprivate lateinit var secureStorage: SecureStorageHelper+ private lateinit var networkManager: NetworkManagerprivate lateinit var androidNotificationManager: NotificationManagerprivate lateinit var testDispatcher: TestDispatcher@@ -62,6 +64,7 @@ class LocationForegroundServiceTest {profileManager = mockk(relaxed = true)conditionMonitor = mockk(relaxed = true)secureStorage = mockk(relaxed = true)+ networkManager = mockk(relaxed = true)androidNotificationManager = mockk(relaxed = true)testDispatcher = UnconfinedTestDispatcher()@@ -121,6 +124,7 @@ class LocationForegroundServiceTest {setField("profileManager", profileManager)setField("conditionMonitor", conditionMonitor)setField("secureStorage", secureStorage)+ setField("networkManager", networkManager)setField("notificationManager", androidNotificationManager)setField("serviceScope", testScope as CoroutineScope)setField("config", ServiceConfig(@@ -1122,7 +1126,8 @@ class LocationForegroundServiceTest {endpoint = "https://example.com",retryIntervalSeconds = 60,isOfflineMode = true,- isWifiOnlySync = true,+ syncCondition = "wifi_any",+ syncSsid = "",httpMethod = "GET"))@@ -1133,7 +1138,8 @@ class LocationForegroundServiceTest {syncIntervalSeconds = 30,retryIntervalSeconds = 60,isOfflineMode = true,- isWifiOnlySync = true,+ syncCondition = "wifi_any",+ syncSsid = "",authHeaders = mapOf("Authorization" to "Bearer token"),httpMethod = "GET") }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.ktindex b6f04be1..a73b1283 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@@ -32,31 +32,32 @@ class ServiceConfigTest {"filterInaccurateLocations" to "false","retryInterval" to "30","isOfflineMode" to "false",- "isWifiOnlySync" to "false",+ "syncCondition" to "any",+ "syncSsid" to "","httpMethod" to "POST")// --- fromDatabase ---@Test- fun `fromDatabase defaults isWifiOnlySync to false`() {- val db = mockDbHelper(baseSettings - "isWifiOnlySync")+ fun `fromDatabase defaults syncCondition to any`() {+ val db = mockDbHelper(baseSettings - "syncCondition")val config = ServiceConfig.fromDatabase(db)- assertFalse(config.isWifiOnlySync)+ assertEquals("any", config.syncCondition)}@Test- fun `fromDatabase reads isWifiOnlySync true`() {- val db = mockDbHelper(baseSettings + ("isWifiOnlySync" to "true"))+ fun `fromDatabase reads syncCondition wifi_any`() {+ val db = mockDbHelper(baseSettings + ("syncCondition" to "wifi_any"))val config = ServiceConfig.fromDatabase(db)- assertTrue(config.isWifiOnlySync)+ assertEquals("wifi_any", config.syncCondition)}@Test- fun `fromDatabase reads isWifiOnlySync false`() {- val db = mockDbHelper(baseSettings + ("isWifiOnlySync" to "false"))+ fun `fromDatabase migrates isWifiOnlySync true to wifi_any`() {+ val db = mockDbHelper(baseSettings - "syncCondition" + ("isWifiOnlySync" to "true"))val config = ServiceConfig.fromDatabase(db)- assertFalse(config.isWifiOnlySync)+ assertEquals("wifi_any", config.syncCondition)}@Test@@ -88,7 +89,7 @@ class ServiceConfigTest {assertFalse(config.filterInaccurateLocations)assertEquals(30, config.retryIntervalSeconds)assertFalse(config.isOfflineMode)- assertFalse(config.isWifiOnlySync)+ assertEquals("any", config.syncCondition)assertEquals("POST", config.httpMethod)}@@ -144,15 +145,17 @@ class ServiceConfigTest {// --- data class defaults ---@Test- fun `default constructor sets isWifiOnlySync to false`() {+ fun `default constructor sets syncCondition to any`() {val config = ServiceConfig()- assertFalse(config.isWifiOnlySync)+ assertEquals("any", config.syncCondition)+ assertEquals("", config.syncSsid)}@Test- fun `constructor accepts isWifiOnlySync true`() {- val config = ServiceConfig(isWifiOnlySync = true)- assertTrue(config.isWifiOnlySync)+ fun `constructor accepts syncCondition wifi_ssid`() {+ val config = ServiceConfig(syncCondition = "wifi_ssid", syncSsid = "MyNetwork")+ assertEquals("wifi_ssid", config.syncCondition)+ assertEquals("MyNetwork", config.syncSsid)}@Test@@ -167,22 +170,22 @@ class ServiceConfigTest {assertFalse(config.filterInaccurateLocations)assertEquals(30, config.retryIntervalSeconds)assertFalse(config.isOfflineMode)- assertFalse(config.isWifiOnlySync)+ assertEquals("any", config.syncCondition)assertNull(config.fieldMap)assertNull(config.customFields)assertEquals("POST", config.httpMethod)}- // --- isOfflineMode and isWifiOnlySync are independent ---+ // --- isOfflineMode and syncCondition are independent ---@Test- fun `isOfflineMode and isWifiOnlySync are independent`() {+ fun `isOfflineMode and syncCondition are independent`() {val db = mockDbHelper(- baseSettings + ("isOfflineMode" to "true") + ("isWifiOnlySync" to "false")+ baseSettings + ("isOfflineMode" to "true") + ("syncCondition" to "vpn"))val config = ServiceConfig.fromDatabase(db)assertTrue(config.isOfflineMode)- assertFalse(config.isWifiOnlySync)+ assertEquals("vpn", config.syncCondition)}// --- fromIntent with mocked Bundle ---@@ -230,7 +233,8 @@ class ServiceConfigTest {every { getBoolean("filterInaccurateLocations") } returns trueevery { getInt("retryInterval") } returns 60every { getBoolean("isOfflineMode") } returns true- every { getBoolean("isWifiOnlySync") } returns true+ every { getString("syncCondition") } returns "wifi_any"+ every { getString("syncSsid") } returns ""every { getString("fieldMap") } returns """{"lat":"latitude"}"""every { getString("customFields") } returns """{"_type":"location"}"""every { getString("httpMethod") } returns "GET"@@ -250,7 +254,7 @@ class ServiceConfigTest {assertTrue(config.filterInaccurateLocations)assertEquals(60, config.retryIntervalSeconds)assertTrue(config.isOfflineMode)- assertTrue(config.isWifiOnlySync)+ assertEquals("wifi_any", config.syncCondition)assertEquals("""{"lat":"latitude"}""", config.fieldMap)assertEquals("GET", config.httpMethod)assertEquals("traccar_json", config.apiFormat)@@ -294,7 +298,7 @@ class ServiceConfigTest {assertEquals(120, config.syncIntervalSeconds)assertTrue(config.isOfflineMode)// Unset values fall back to DB- assertFalse(config.isWifiOnlySync)+ assertEquals("any", config.syncCondition)}@Testdiff --git a/apps/mobile/android/app/src/test/java/com/Colota/sync/SyncManagerTest.kt b/apps/mobile/android/app/src/test/java/com/Colota/sync/SyncManagerTest.ktindex be060233..7d375347 100644--- a/apps/mobile/android/app/src/test/java/com/Colota/sync/SyncManagerTest.kt+++ b/apps/mobile/android/app/src/test/java/com/Colota/sync/SyncManagerTest.kt@@ -51,7 +51,8 @@ class SyncManagerTest {syncIntervalSeconds = 0,retryIntervalSeconds = 30,isOfflineMode = true,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -69,7 +70,8 @@ class SyncManagerTest {syncIntervalSeconds = 0,retryIntervalSeconds = 30,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -89,7 +91,8 @@ class SyncManagerTest {syncIntervalSeconds = 0,retryIntervalSeconds = 30,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -112,7 +115,8 @@ class SyncManagerTest {syncIntervalSeconds = 0,retryIntervalSeconds = 30,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -133,7 +137,8 @@ class SyncManagerTest {syncIntervalSeconds = 0,retryIntervalSeconds = 30,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -155,7 +160,8 @@ class SyncManagerTest {syncIntervalSeconds = 0,retryIntervalSeconds = 30,isOfflineMode = false,- isWifiOnlySync = true,+ syncCondition = "wifi_any",+ syncSsid = "",authHeaders = emptyMap())@@ -175,7 +181,8 @@ class SyncManagerTest {syncIntervalSeconds = 0,retryIntervalSeconds = 30,isOfflineMode = false,- isWifiOnlySync = true,+ syncCondition = "wifi_any",+ syncSsid = "",authHeaders = emptyMap())@@ -189,6 +196,96 @@ class SyncManagerTest {coVerify { networkManager.sendToEndpoint(any(), "https://example.com", any(), any()) }}+ // --- queueAndSend: Wi-Fi SSID ---++ @Test+ fun `queueAndSend skips send when wifi_ssid and wrong SSID`() = scope.runTest {+ syncManager.updateConfig(+ endpoint = "https://example.com",+ syncIntervalSeconds = 0,+ retryIntervalSeconds = 30,+ isOfflineMode = false,+ syncCondition = "wifi_ssid",+ syncSsid = "HomeNetwork",+ authHeaders = emptyMap()+ )++ coEvery { networkManager.isNetworkAvailable() } returns true+ every { networkManager.isConnectedToSsid("HomeNetwork") } returns false++ val payload = JSONObject().put("lat", 52.0)+ syncManager.queueAndSend(1L, payload)++ coVerify(exactly = 0) { networkManager.sendToEndpoint(any(), any(), any(), any()) }+ }++ @Test+ fun `queueAndSend sends when wifi_ssid and matching SSID`() = scope.runTest {+ syncManager.updateConfig(+ endpoint = "https://example.com",+ syncIntervalSeconds = 0,+ retryIntervalSeconds = 30,+ isOfflineMode = false,+ syncCondition = "wifi_ssid",+ syncSsid = "HomeNetwork",+ authHeaders = emptyMap()+ )++ coEvery { networkManager.isNetworkAvailable() } returns true+ every { networkManager.isConnectedToSsid("HomeNetwork") } returns true+ coEvery { networkManager.sendToEndpoint(any(), any(), any(), any()) } returns true++ val payload = JSONObject().put("lat", 52.0)+ syncManager.queueAndSend(1L, payload)++ coVerify { networkManager.sendToEndpoint(any(), "https://example.com", any(), any()) }+ }++ // --- queueAndSend: VPN ---++ @Test+ fun `queueAndSend skips send when vpn condition and no VPN`() = scope.runTest {+ syncManager.updateConfig(+ endpoint = "https://example.com",+ syncIntervalSeconds = 0,+ retryIntervalSeconds = 30,+ isOfflineMode = false,+ syncCondition = "vpn",+ syncSsid = "",+ authHeaders = emptyMap()+ )++ coEvery { networkManager.isNetworkAvailable() } returns true+ every { networkManager.isVpnConnected() } returns false++ val payload = JSONObject().put("lat", 52.0)+ syncManager.queueAndSend(1L, payload)++ coVerify(exactly = 0) { networkManager.sendToEndpoint(any(), any(), any(), any()) }+ }++ @Test+ fun `queueAndSend sends when vpn condition and VPN connected`() = scope.runTest {+ syncManager.updateConfig(+ endpoint = "https://example.com",+ syncIntervalSeconds = 0,+ retryIntervalSeconds = 30,+ isOfflineMode = false,+ syncCondition = "vpn",+ syncSsid = "",+ authHeaders = emptyMap()+ )++ coEvery { networkManager.isNetworkAvailable() } returns true+ every { networkManager.isVpnConnected() } returns true+ coEvery { networkManager.sendToEndpoint(any(), any(), any(), any()) } returns true++ val payload = JSONObject().put("lat", 52.0)+ syncManager.queueAndSend(1L, payload)++ coVerify { networkManager.sendToEndpoint(any(), "https://example.com", any(), any()) }+ }+// --- queueAndSend: periodic mode ---@Test@@ -198,7 +295,8 @@ class SyncManagerTest {syncIntervalSeconds = 300,retryIntervalSeconds = 30,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -221,7 +319,8 @@ class SyncManagerTest {syncIntervalSeconds = 0,retryIntervalSeconds = 30,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = headers,httpMethod = "GET")@@ -243,7 +342,8 @@ class SyncManagerTest {syncIntervalSeconds = 0,retryIntervalSeconds = 30,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -266,7 +366,8 @@ class SyncManagerTest {syncIntervalSeconds = 0,retryIntervalSeconds = 30,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -282,7 +383,8 @@ class SyncManagerTest {syncIntervalSeconds = 0,retryIntervalSeconds = 30,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -305,7 +407,8 @@ class SyncManagerTest {syncIntervalSeconds = 0,retryIntervalSeconds = 30,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -389,7 +492,8 @@ class SyncManagerTest {syncIntervalSeconds = 0,retryIntervalSeconds = 30,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -410,7 +514,8 @@ class SyncManagerTest {syncIntervalSeconds = 0,retryIntervalSeconds = 30,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -437,7 +542,8 @@ class SyncManagerTest {syncIntervalSeconds = 1,retryIntervalSeconds = 1,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -469,7 +575,8 @@ class SyncManagerTest {syncIntervalSeconds = 1,retryIntervalSeconds = 1,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -503,7 +610,8 @@ class SyncManagerTest {syncIntervalSeconds = 1,retryIntervalSeconds = 1,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -530,7 +638,8 @@ class SyncManagerTest {syncIntervalSeconds = 1,retryIntervalSeconds = 1,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -563,7 +672,8 @@ class SyncManagerTest {syncIntervalSeconds = 60,retryIntervalSeconds = 30,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -596,7 +706,8 @@ class SyncManagerTest {syncIntervalSeconds = 1,retryIntervalSeconds = 1,isOfflineMode = true,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -616,7 +727,8 @@ class SyncManagerTest {syncIntervalSeconds = 1,retryIntervalSeconds = 1,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -637,7 +749,8 @@ class SyncManagerTest {syncIntervalSeconds = 1,retryIntervalSeconds = 1,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -668,7 +781,8 @@ class SyncManagerTest {syncIntervalSeconds = 0,retryIntervalSeconds = 30,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap())@@ -703,7 +817,8 @@ class SyncManagerTest {syncIntervalSeconds = 0,retryIntervalSeconds = 30,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap(),httpMethod = "POST",apiFormat = "traccar_json"@@ -724,7 +839,8 @@ class SyncManagerTest {syncIntervalSeconds = 0,retryIntervalSeconds = 30,isOfflineMode = false,- isWifiOnlySync = false,+ syncCondition = "any",+ syncSsid = "",authHeaders = emptyMap(),httpMethod = "POST",apiFormat = "traccar_json"diff --git a/apps/mobile/src/components/features/settings/SyncStrategySettings.tsx b/apps/mobile/src/components/features/settings/SyncStrategySettings.tsxindex c8ee528d..39d6e33f 100644--- a/apps/mobile/src/components/features/settings/SyncStrategySettings.tsx+++ b/apps/mobile/src/components/features/settings/SyncStrategySettings.tsx@@ -4,14 +4,15 @@*/import React, { useState, useCallback, useEffect } from "react"-import { Text, StyleSheet, Switch, View, Pressable } from "react-native"+import { Text, StyleSheet, Switch, View, Pressable, TextInput, AppState } from "react-native"import { Lightbulb, ChevronDown, ChevronUp } from "lucide-react-native"-import { Settings, TRACKING_PRESETS, SelectablePreset, ThemeColors } from "../../../types/global"+import { Settings, TRACKING_PRESETS, SelectablePreset, ThemeColors, SyncCondition } from "../../../types/global"import { fonts, fontSizes } from "../../../styles/typography"import { SYNC_INTERVAL_PRESETS, SYNC_INTERVAL_LABELS } from "../../../constants"import { SectionTitle, Card, Divider, NumericInput, SettingRow } from "../../index"import { PresetOption } from "./PresetOption"import { shortDistanceUnit, inputToMeters, metersToInput } from "../../../utils/geo"+import NativeLocationService from "../../../services/NativeLocationService"interface SyncStrategySettingsProps {settings: Settings@@ -35,6 +36,19 @@ export function SyncStrategySettings({)const [syncIntervalInput, setSyncIntervalInput] = useState(settings.syncInterval.toString())const [showAdvanced, setShowAdvanced] = useState(false)+ const [currentSsid, setCurrentSsid] = useState("")++ useEffect(() => {+ if (settings.syncCondition !== "wifi_ssid") return++ const fetchSsid = () => NativeLocationService.getCurrentSsid().then(setCurrentSsid)+ fetchSsid()++ const sub = AppState.addEventListener("change", (state) => {+ if (state === "active") fetchSsid()+ })+ return () => sub.remove()+ }, [settings.syncCondition])const isCustomSyncInterval = !SYNC_INTERVAL_PRESETS.includes(settings.syncInterval)@@ -285,30 +299,92 @@ export function SyncStrategySettings({</View>)}- {/* Wi-Fi Only Sync Toggle */}- <SettingRow- label="Wi-Fi Only Sync"- hint="Only upload when connected to Wi-Fi"- style={styles.settingRowSpaced}- >- <Switch- value={settings.isWifiOnlySync}- onValueChange={(value) => {- const next = {- ...settings,- isWifiOnlySync: value,- syncPreset: "custom" as const- }- onSettingsChange(next)- onImmediateSave(next)- }}- trackColor={{- false: colors.border,- true: colors.primary + "80"- }}- thumbColor={settings.isWifiOnlySync ? colors.primary : colors.border}- />- </SettingRow>+ {/* Sync Condition */}+ <View style={styles.settingRowSpaced}>+ <Text style={[styles.blockLabel, { color: colors.text }]}>Sync Only On</Text>+ <Text style={[styles.blockHint, { color: colors.textSecondary }]}>+ {settings.syncCondition === "any" && "Upload on any network connection"}+ {settings.syncCondition === "wifi_any" && "Upload only when connected to Wi-Fi"}+ {settings.syncCondition === "wifi_ssid" && "Upload only on a specific Wi-Fi network"}+ {settings.syncCondition === "vpn" && "Upload only when VPN is active"}+ </Text>+ <View style={styles.syncConditionChips}>+ {(+ [+ { value: "any", label: "Any" },+ { value: "wifi_any", label: "Wi-Fi" },+ { value: "wifi_ssid", label: "SSID" },+ { value: "vpn", label: "VPN" }+ ] as { value: SyncCondition; label: string }[]+ ).map((option) => (+ <Pressable+ key={option.value}+ onPress={() => {+ const next = {+ ...settings,+ syncCondition: option.value,+ syncPreset: "custom" as const+ }+ onSettingsChange(next)+ onImmediateSave(next)+ }}+ style={[+ styles.syncConditionChip,+ {+ backgroundColor:+ settings.syncCondition === option.value ? colors.primary + "20" : colors.background,+ borderColor: settings.syncCondition === option.value ? colors.primary : colors.border+ }+ ]}+ >+ <Text+ style={[+ styles.syncConditionChipText,+ { color: settings.syncCondition === option.value ? colors.primary : colors.textSecondary }+ ]}+ >+ {option.label}+ </Text>+ </Pressable>+ ))}+ </View>+ {settings.syncCondition === "wifi_ssid" && (+ <View style={styles.ssidRow}>+ <TextInput+ style={[+ styles.ssidInput,+ { borderColor: colors.border, color: colors.text, backgroundColor: colors.background }+ ]}+ value={settings.syncSsid}+ onChangeText={(text) => {+ const next = { ...settings, syncSsid: text }+ onSettingsChange(next)+ onDebouncedSave(next)+ }}+ placeholder="Enter Wi-Fi SSID"+ placeholderTextColor={colors.placeholder}+ autoCapitalize="none"+ autoCorrect={false}+ />+ {currentSsid !== "" && currentSsid.toLowerCase() !== settings.syncSsid.toLowerCase() && (+ <Pressable+ style={({ pressed }) => [+ styles.ssidFillButton,+ { borderColor: colors.primary, backgroundColor: colors.primary + "15" },+ pressed && { opacity: colors.pressedOpacity }+ ]}+ onPress={() => {+ const next = { ...settings, syncSsid: currentSsid }+ onSettingsChange(next)+ onImmediateSave(next)+ }}+ >+ <Text style={[styles.ssidFillText, { color: colors.primary }]}>Use current</Text>+ </Pressable>+ )}+ </View>+ )}+ </View></View><Divider />@@ -443,5 +519,46 @@ const styles = StyleSheet.create({},customSyncInput: {marginTop: 12+ },+ syncConditionChips: {+ flexDirection: "row",+ gap: 6,+ marginTop: 8+ },+ syncConditionChip: {+ paddingHorizontal: 12,+ paddingVertical: 6,+ borderRadius: 12,+ borderWidth: 1+ },+ syncConditionChipText: {+ ...fonts.medium,+ fontSize: 12+ },+ ssidRow: {+ flexDirection: "row",+ alignItems: "center",+ marginTop: 8,+ gap: 8+ },+ ssidInput: {+ flex: 1,+ borderWidth: 1.5,+ borderRadius: 8,+ paddingHorizontal: 10,+ paddingVertical: 6,+ fontSize: 13,+ fontFamily: "monospace"+ },+ ssidFillButton: {+ alignSelf: "flex-start",+ paddingHorizontal: 10,+ paddingVertical: 6,+ borderRadius: 8,+ borderWidth: 1+ },+ ssidFillText: {+ ...fonts.medium,+ fontSize: 12}})diff --git a/apps/mobile/src/contexts/TrackingProvider.tsx b/apps/mobile/src/contexts/TrackingProvider.tsxindex 6c84c22c..ea8146dd 100644--- a/apps/mobile/src/contexts/TrackingProvider.tsx+++ b/apps/mobile/src/contexts/TrackingProvider.tsx@@ -51,7 +51,9 @@ function parseRawSettings(allRaw: Record<string, string>): Settings {: DEFAULT_SETTINGS.accuracyThreshold,isOfflineMode: allRaw.isOfflineMode === "true",- isWifiOnlySync: allRaw.isWifiOnlySync === "true",+ syncCondition:+ (allRaw.syncCondition as any) ?? (allRaw.isWifiOnlySync === "true" ? "wifi_any" : DEFAULT_SETTINGS.syncCondition),+ syncSsid: allRaw.syncSsid ?? DEFAULT_SETTINGS.syncSsid,endpoint: allRaw.endpoint ?? DEFAULT_SETTINGS.endpoint,syncPreset: (allRaw.syncPreset as any) ?? DEFAULT_SETTINGS.syncPreset,filterInaccurateLocations: allRaw.filterInaccurateLocations === "true",diff --git a/apps/mobile/src/screens/SetupImportScreen.tsx b/apps/mobile/src/screens/SetupImportScreen.tsxindex fdb73058..3a0594c4 100644--- a/apps/mobile/src/screens/SetupImportScreen.tsx+++ b/apps/mobile/src/screens/SetupImportScreen.tsx@@ -147,9 +147,14 @@ function validateConfig(raw: unknown): ValidationResult {entries.push({ label: "Offline mode", value: obj.isOfflineMode ? "Yes" : "No", category: "tracking" })}- if ("isWifiOnlySync" in obj && typeof obj.isWifiOnlySync === "boolean") {- settings.isWifiOnlySync = obj.isWifiOnlySync- entries.push({ label: "Wi-Fi only sync", value: obj.isWifiOnlySync ? "Yes" : "No", category: "tracking" })+ if ("syncCondition" in obj && typeof obj.syncCondition === "string") {+ settings.syncCondition = obj.syncCondition as any+ entries.push({ label: "Sync condition", value: obj.syncCondition, category: "tracking" })+ }++ if ("syncSsid" in obj && typeof obj.syncSsid === "string") {+ settings.syncSsid = obj.syncSsid+ entries.push({ label: "Sync SSID", value: obj.syncSsid, category: "tracking" })}// --- API settings ---diff --git a/apps/mobile/src/services/NativeLocationService.ts b/apps/mobile/src/services/NativeLocationService.tsindex d632f71e..f9746f75 100644--- a/apps/mobile/src/services/NativeLocationService.ts+++ b/apps/mobile/src/services/NativeLocationService.ts@@ -70,7 +70,8 @@ class NativeLocationService {filterInaccurateLocations: settings.filterInaccurateLocations,accuracyThreshold: settings.accuracyThreshold,isOfflineMode: settings.isOfflineMode,- isWifiOnlySync: settings.isWifiOnlySync,+ syncCondition: settings.syncCondition,+ syncSsid: settings.syncSsid,httpMethod: settings.httpMethod,apiTemplate: settings.apiTemplate,customFields: Object.fromEntries(settings.customFields.filter((f) => f.key).map((f) => [f.key, f.value]))@@ -502,6 +503,14 @@ class NativeLocationService {return this.safeExecute(() => LocationServiceModule.isUnmeteredConnection(), false, "isUnmeteredConnection failed")}+ /**+ * Returns the SSID of the currently connected Wi-Fi network, or empty string if unavailable.+ */+ static async getCurrentSsid(): Promise<string> {+ this.ensureModule()+ return this.safeExecute(() => LocationServiceModule.getCurrentSsid(), "", "getCurrentSsid failed")+ }+/*** Returns available device storage in MB, or -1 if the check fails.*/diff --git a/apps/mobile/src/services/SettingsService.ts b/apps/mobile/src/services/SettingsService.tsindex eb4202f4..6f83d059 100644--- a/apps/mobile/src/services/SettingsService.ts+++ b/apps/mobile/src/services/SettingsService.ts@@ -48,11 +48,15 @@ export const SettingsService = {case "filterInaccurateLocations":case "isOfflineMode":- case "isWifiOnlySync":// Boolean → "true"/"false"stringValue = String(value)break+ case "syncCondition":+ case "syncSsid":+ stringValue = String(value)+ break+default:// Handles 'endpoint', 'syncPreset', etc.stringValue = String(value)diff --git a/apps/mobile/src/services/__tests__/NativeLocationService.test.ts b/apps/mobile/src/services/__tests__/NativeLocationService.test.tsindex 6a3376bf..5ab5c3b1 100644--- a/apps/mobile/src/services/__tests__/NativeLocationService.test.ts+++ b/apps/mobile/src/services/__tests__/NativeLocationService.test.ts@@ -112,7 +112,8 @@ describe("NativeLocationService", () => {filterInaccurateLocations: false,accuracyThreshold: 50,isOfflineMode: false,- isWifiOnlySync: false,+ syncCondition: "any" as const,+ syncSsid: "",customFields: [],apiTemplate: "custom" as const,syncPreset: "instant" as const,@@ -143,7 +144,8 @@ describe("NativeLocationService", () => {filterInaccurateLocations: false,accuracyThreshold: 50,isOfflineMode: false,- isWifiOnlySync: false,+ syncCondition: "any" as const,+ syncSsid: "",customFields: [],apiTemplate: "traccar" as const,syncPreset: "instant" as const,@@ -172,7 +174,8 @@ describe("NativeLocationService", () => {filterInaccurateLocations: false,accuracyThreshold: 50,isOfflineMode: false,- isWifiOnlySync: false,+ syncCondition: "any" as const,+ syncSsid: "",customFields: [],apiTemplate: "traccar" as const,syncPreset: "instant" as const,diff --git a/apps/mobile/src/types/global.ts b/apps/mobile/src/types/global.tsindex 01d96a94..b9a0d9ba 100644--- a/apps/mobile/src/types/global.ts+++ b/apps/mobile/src/types/global.ts@@ -99,6 +99,8 @@ export interface CustomField {export type HttpMethod = "POST" | "GET"+export type SyncCondition = "any" | "wifi_any" | "wifi_ssid" | "vpn"+export type ApiTemplateName =| "custom"| "dawarich"@@ -315,7 +317,8 @@ export interface Settings {syncInterval: numberretryInterval: numberisOfflineMode: boolean- isWifiOnlySync: boolean+ syncCondition: SyncCondition+ syncSsid: string// UI StatesyncPreset: SyncPresethasCompletedSetup: boolean@@ -334,7 +337,8 @@ export const DEFAULT_SETTINGS: Settings = {accuracyThreshold: 50,syncPreset: "instant",isOfflineMode: false,- isWifiOnlySync: false,+ syncCondition: "any",+ syncSsid: "",hasCompletedSetup: false,httpMethod: "POST"} as const