super-productivity/android/app
Johannes Millan 7c948a4d51
fix(android): prevent FGS start-timeout crash from start/stop race (#7991)
ForegroundServiceDidNotStartInTimeException was reported on Play Console
(Android 14+, OEM-throttled devices, app in foreground). The stop helpers
stopTrackingService()/stopFocusModeService() used Activity.stopService(),
which bypasses onStartCommand and tears the service down directly. When a
focus/tracking session is started and quickly cancelled, AOSP
bringDownServiceLocked() crashes the process if the service is destroyed
while fgRequired is still true, i.e. before its first startForeground().

Add an isStartPending flag to each service companion (set before
startForegroundService(), cleared after promotion in onStartCommand and in
onDestroy) and route stops through ACTION_STOP via startService() while a
start is pending or the service is running, so onStartCommand promotes the
service before tearing it down. Cold no-op stops still use stopService().
A backgrounded stop (startService disallowed) falls back to stopService()
only when no start is pending; a pending start is left for onStartCommand
to promote and a later foreground sync to stop, so the fallback can never
re-trigger the same crash.
2026-06-03 17:45:17 +02:00
..
src fix(android): prevent FGS start-timeout crash from start/stop race (#7991) 2026-06-03 17:45:17 +02:00
.gitignore ____MERGING SUPER PRODUCTIVITY ANDROID ____ 2024-10-11 14:11:23 +02:00
app_config.properties ____MERGING SUPER PRODUCTIVITY ANDROID ____ 2024-10-11 14:11:23 +02:00
build.gradle 18.8.0 2026-05-30 01:19:30 +02:00
capacitor.build.gradle build(android): register edge-to-edge support plugin in gradle 2026-05-28 23:54:51 +02:00
config.gradle ____MERGING SUPER PRODUCTIVITY ANDROID ____ 2024-10-11 14:11:23 +02:00
google.properties ____MERGING SUPER PRODUCTIVITY ANDROID ____ 2024-10-11 14:11:23 +02:00
proguard-rules.pro feat(droid): background sync notifications for android 2026-03-20 10:24:02 +01:00