From 461fe2e5f51a19d206fb045baefdefb529885227 Mon Sep 17 00:00:00 2001 From: Dhruv Dangi Date: Tue, 29 Sep 2026 20:51:30 +0530 Subject: [PATCH] Stop the dataSync foreground service on Android 15 timeout Android 15 gives an app's dataSync foreground services six hours per day in the background. At the limit the system calls onTimeout and expects stopSelf within a few seconds, or it kills the process with ForegroundServiceDidNotStopInTimeException. WorkManager 2.9 never implemented onTimeout, so every long upload that outlived the budget took the app down. WorkManager 2.10 added the handler: it stops each worker of the timed-out type with STOP_REASON_FOREGROUND_SERVICE_TIMEOUT and stops the service. The stopped workers re-run, setForeground is refused because the budget is spent, and the existing isForegroundStartDenied path carries the upload on without foreground priority until the user opens the app and the budget resets. Bumps androidx.work to 2.12.0, which raises the library's floor to minSdk 24. Ours is 29. Co-Authored-By: Claude Fable 5.1 --- CHANGELOG.md | 8 ++++++++ android/build.gradle | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8e026b2..efbc0e92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ Fixed: the file, and Swift cannot catch it. A file deleted after the caller checked it ended the app. `startUpload` now rejects instead, and a chunked part that cannot be enqueued journals an `error` with `errorKind: 'file'`. +- **Android 15+ no longer kills the app when the `dataSync` foreground-service + budget runs out.** Android gives `dataSync` services six hours per day in the + background, then calls `onTimeout` and expects the service to stop. + WorkManager 2.9 never answered, so the system threw + `ForegroundServiceDidNotStopInTimeException` and the process died mid-upload. + WorkManager 2.12 stops the timed-out workers itself. They re-run without + foreground priority until the user opens the app, which resets the budget. + Bumps `androidx.work` to 2.12.0 (minSdk 24). ## 9.0.0 diff --git a/android/build.gradle b/android/build.gradle index 591768ac..d155f4b5 100755 --- a/android/build.gradle +++ b/android/build.gradle @@ -46,7 +46,7 @@ dependencies { implementation 'com.facebook.react:react-android' implementation 'androidx.core:core-ktx:1.13.1' - implementation 'androidx.work:work-runtime-ktx:2.9.1' + implementation 'androidx.work:work-runtime-ktx:2.12.0' implementation 'com.squareup.okhttp3:okhttp:4.12.0' implementation 'com.google.code.gson:gson:2.11.0' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1'