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
{{ message }}
Repository navigation
Crash when the app is opened right after an update: WebService stopped before startForeground #308
Seen on aceline-3 (Android 10, API 29) with 2.30.0 from latest; the code is the same since 2.27.0 (#289, 9aa04e8), so it is not new in 2.30.0.
Repro:adb install -r decoder-v2.apk over an installed Decoder with remote access allowed, then am start -n com.openipc.decoder/.Decoder at once. 2 of 3 tries crashed:
android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{… com.openipc.decoder/.WebService}
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1945)
The Crash screen shows; a new start of the app works.
Cause:MY_PACKAGE_REPLACED → WebService.startAfterUpdate → startForegroundService (the app is not open yet). The activity opens before the service's onStartCommand ran and calls WebService.stop → stopService. A foreground service stopped before it called startForeground crashes the app (Android 9+).
Fix idea: do not stop a service whose start is still pending: stop() leaves it, and onStartCommand (after startForeground) stops itself when the app is open or opening (Decoder.openOrOpening()), as it already does when remote access is off.
Activity