Catfriend1 / syncthing-android

Syncthing-Fork - A Syncthing Wrapper for Android.
Mozilla Public License 2.0
1.24k stars 40 forks source link

Service.startForeground() not allowed due to mAllowStartForeground false #1109

Open odlg opened 4 months ago

odlg commented 4 months ago

Description of the issue

Syncthing-Fork frequently has issues starting. The phone tells me it has crashed and provides this information:

type: crash
osVersion: google/husky/husky:14/AP1A.240505.005/2024052100:user/release-keys
package: com.github.catfriend1.syncthingandroid:1270700
process: com.github.catfriend1.syncthingandroid
processUptime: 147 + 442 ms
installer: com.machiav3lli.fdroid

java.lang.RuntimeException: Unable to start service com.nutomic.syncthingandroid.service.SyncthingService@7de6ba2 with null: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service com.github.catfriend1.syncthingandroid/com.nutomic.syncthingandroid.service.SyncthingService
    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5079)
    at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2397)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loopOnce(Looper.java:232)
    at android.os.Looper.loop(Looper.java:317)
    at android.app.ActivityThread.main(ActivityThread.java:8532)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
    at com.android.internal.os.ExecInit.main(ExecInit.java:50)
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:359)
Caused by: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service com.github.catfriend1.syncthingandroid/com.nutomic.syncthingandroid.service.SyncthingService
    at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
    at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
    at android.os.Parcel.readParcelableInternal(Parcel.java:5035)
    at android.os.Parcel.readParcelable(Parcel.java:5017)
    at android.os.Parcel.createExceptionOrNull(Parcel.java:3186)
    at android.os.Parcel.createException(Parcel.java:3175)
    at android.os.Parcel.readException(Parcel.java:3151)
    at android.os.Parcel.readException(Parcel.java:3093)
    at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6876)
    at android.app.Service.startForeground(Service.java:878)
    at com.nutomic.syncthingandroid.service.NotificationHandler.updatePersistentNotification(NotificationHandler.java:216)
    at com.nutomic.syncthingandroid.service.NotificationHandler.updatePersistentNotification(NotificationHandler.java:109)
    at com.nutomic.syncthingandroid.service.SyncthingService.onStartCommand(SyncthingService.java:306)
    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5061)
    ... 11 more

Reproduction Steps

Version Information

Catfriend1 commented 3 months ago

Seems like the OS revoked the foreground service permission?! Maybe reinstalling helps? Export your config first, so it'll be easy to re-import it to the new installation.