You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Android 9 crash - Implement getForegroundInfo() for WorkManager Expedited Work (Issue #15)
This commit fixes the critical crash on Android 9 (API 28) that occurred when using
WorkManager Expedited Work for background sync operations.
## Root Cause
When setExpedited() is used in WorkManager, the CoroutineWorker must implement
getForegroundInfo() to return a ForegroundInfo object with a Foreground Service
notification. On Android 9-11, WorkManager calls this method, but the default
implementation throws: IllegalStateException: Not implemented
## Solution
- Implemented getForegroundInfo() in SyncWorker
- Returns ForegroundInfo with sync progress notification
- Android 10+: Sets FOREGROUND_SERVICE_TYPE_DATA_SYNC for proper service typing
- Added required Foreground Service permissions to AndroidManifest.xml
## Technical Changes
- SyncWorker.kt: Added getForegroundInfo() override
- NotificationHelper.kt: Added createSyncProgressNotification() factory method
- strings.xml: Added sync_in_progress UI strings (EN + DE)
- AndroidManifest.xml: Added FOREGROUND_SERVICE permissions
- Version updated to 1.7.1 (versionCode 18)
## Previously Fixed (in this release)
- Kernel-VPN compatibility (Wireguard interface detection)
- HTTP connection lifecycle optimization (SafeSardineWrapper)
- Stability improvements for sync sessions
## Testing
- Tested on Android 9 (API 28) - No crash on second app start
- Tested on Android 15 (API 35) - No regressions
- WiFi-connect sync working correctly
- Expedited work notifications display properly
Fixes#15
Thanks to @roughnecks for detailed bug report and testing!
- Traffic wird korrekt durch VPN-Tunnel geleitet statt direkt über WiFi
23
-
- Behebt "Verbindungs-Timeout" beim Sync zu externen Servern über VPN
17
+
**Problem:** App stürzte auf Android 9 (API 28) ab wenn WorkManager Expedited Work für Hintergrund-Sync verwendet wurde.
18
+
19
+
**Root Cause:** Wenn `setExpedited()` in WorkManager verwendet wird, muss die `CoroutineWorker` die Methode `getForegroundInfo()` implementieren um eine Foreground Service Notification zurückzugeben. Auf Android 9-11 ruft WorkManager diese Methode auf, aber die Standard-Implementierung wirft `IllegalStateException: Not implemented`.
20
+
21
+
**Lösung:**`getForegroundInfo()` in `SyncWorker` implementiert um eine korrekte `ForegroundInfo` mit Sync-Progress-Notification zurückzugeben.
22
+
23
+
**Details:**
24
+
-`ForegroundInfo` mit Sync-Progress-Notification für Android 9-11 hinzugefügt
25
+
- Android 10+: Setzt `FOREGROUND_SERVICE_TYPE_DATA_SYNC` für korrekte Service-Typisierung
26
+
- Foreground Service Permissions in AndroidManifest.xml hinzugefügt
27
+
- Notification zeigt Sync-Progress mit indeterminiertem Progress Bar
28
+
- Danke an [@roughnecks](https://github.com/roughnecks) für das detaillierte Debugging!
- Traffic routes through VPN tunnel instead of bypassing it directly to WiFi
23
-
- Fixes "Connection timeout" when syncing to external servers via VPN
17
+
**Problem:** App crashed on Android 9 (API 28) when using WorkManager Expedited Work for background sync.
18
+
19
+
**Root Cause:** When `setExpedited()` is used in WorkManager, the `CoroutineWorker` must implement `getForegroundInfo()` to return a Foreground Service notification. On Android 9-11, WorkManager calls this method, but the default implementation throws `IllegalStateException: Not implemented`.
20
+
21
+
**Solution:** Implemented `getForegroundInfo()` in `SyncWorker` to return a proper `ForegroundInfo` with sync progress notification.
22
+
23
+
**Details:**
24
+
- Added `ForegroundInfo` with sync progress notification for Android 9-11
25
+
- Android 10+: Sets `FOREGROUND_SERVICE_TYPE_DATA_SYNC` for proper service typing
26
+
- Added Foreground Service permissions to AndroidManifest.xml
27
+
- Notification shows sync progress with indeterminate progress bar
28
+
- Thanks to [@roughnecks](https://github.com/roughnecks) for the detailed debugging!
0 commit comments