zhanghai / MaterialFiles

Material Design file manager for Android
https://play.google.com/store/apps/details?id=me.zhanghai.android.files
GNU General Public License v3.0
5.44k stars 378 forks source link

FTP tile causes crash #1238

Closed lucaxvi closed 3 days ago

lucaxvi commented 1 month ago

Tapping the FTP server quick setting tile in the notification panel crashes the app (version 1.7.2, Android 14).

F-Droid and Google Play Store versions are both affected.

05-25 18:39:40.286  2390  5188 W ActivityManager: startForegroundService() not allowed due to mAllowStartForeground false: service me.zhanghai.android.files/.ftpserver.FtpServerService
05-25 18:39:40.288 28802 28802 D AndroidRuntime: Shutting down VM
05-25 18:39:40.290 28802 28802 E AndroidRuntime: FATAL EXCEPTION: main
05-25 18:39:40.290 28802 28802 E AndroidRuntime: Process: me.zhanghai.android.files, PID: 28802
05-25 18:39:40.290 28802 28802 E AndroidRuntime: android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service me.zhanghai.android.files/.ftpserver.FtpServerService
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at android.os.Parcel.readParcelableInternal(Parcel.java:4870)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at android.os.Parcel.readParcelable(Parcel.java:4852)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at android.os.Parcel.createExceptionOrNull(Parcel.java:3052)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at android.os.Parcel.createException(Parcel.java:3041)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at android.os.Parcel.readException(Parcel.java:3024)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at android.os.Parcel.readException(Parcel.java:2966)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at android.app.IActivityManager$Stub$Proxy.startService(IActivityManager.java:6013)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1931)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at android.app.ContextImpl.startForegroundService(ContextImpl.java:1906)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:830)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at D.c.b(SourceFile:1)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at G4.i.f(SourceFile:51)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at me.zhanghai.android.files.ftpserver.FtpServerTileService.onClick(SourceFile:23)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at android.service.quicksettings.TileService$H.handleMessage(TileService.java:494)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:106)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:205)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:294)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:8248)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
05-25 18:39:40.290 28802 28802 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
05-25 18:39:40.294  2390 28827 I DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2
05-25 18:39:40.297  2390  2437 I ActivityManager: Showing crash dialog for package me.zhanghai.android.files u0
zhanghai commented 1 month ago

Is this occasional or always happening? I think there's a bug in AOSP for sometimes disallowing apps to start foreground service from notification tiles.

lucaxvi commented 1 month ago

It happens every time. I don't recall it happening in Android 13. Could this be relevant?

EDIT: Is this call missing an argument? https://github.com/zhanghai/MaterialFiles/blob/88b66e021f8dee7369ded451b19cf4431b5de2ba/app/src/main/java/me/zhanghai/android/files/ftpserver/FtpServerNotification.kt#L69

zhanghai commented 1 month ago

If the foreground service type is not specified in the call, the type defaults to the values defined in the manifest. If you didn't specify the service type in the manifest, the system throws MissingForegroundServiceTypeException.

Since the exception is not MissingForegroundServiceTypeException, I don't think it's related.

However, this does seem reproducible so I'll look into it...

Possibly related links:

bosko101 commented 3 weeks ago

Hi, is there any workaround about this bug? I have it too.

zhanghai commented 5 days ago

Is anyone seeing this on Android 13? If not, I'll only try to work around it in Android 14.

zhanghai commented 4 days ago

Note that this is an Android 14 bug https://issuetracker.google.com/issues/299506164 .