Skip to content

FtpService improvements#4379

Merged
EmmanuelMess merged 5 commits into
TeamAmaze:release/4.0from
TranceLove:feature/ftp-eventbus-replace-with-kotlinx-flow
Jan 21, 2026
Merged

FtpService improvements#4379
EmmanuelMess merged 5 commits into
TeamAmaze:release/4.0from
TranceLove:feature/ftp-eventbus-replace-with-kotlinx-flow

Conversation

@TranceLove
Copy link
Copy Markdown
Collaborator

Description

  • FtpTileService convert to Kotlin
  • Replace EventBus with kotlinx.coroutines
  • FtpServerFragment update code to recommended
  • FtpService explicitly acquires wakelock and enforces START_STICKY to ensure it's still running in the background even in the doze mode
  • Upgrade ACRA to 2.13 for fixing Android 14 One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED square/leakcanary#2568, which would also break FtpService when device screen is turned off

Issue tracker

Fixes #4125

Automatic tests

  • Added test cases

Manual tests

  • Done

Device: Fairphone 5 running LineageOS 22 (Android 15)

  1. Start FTP server
  2. Connect to the FTP server using other device
  3. Start a file transfer
  4. Turn off the screen while transfer in progress
  5. File transfer should not break

Build tasks success

Successfully running following tasks on local:

  • ./gradlew assembledebug
  • ./gradlew spotlessCheck

Related PR

Depends on PR #4378

@TranceLove TranceLove added the Area-FTP Related to FTP Server. label Apr 6, 2025
@TranceLove TranceLove requested a review from Copilot April 6, 2025 13:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.

Files not reviewed (2)
  • app/build.gradle: Language not supported
  • app/src/main/AndroidManifest.xml: Language not supported
Comments suppressed due to low confidence (1)

gradle/libs.versions.toml:37

  • Verify that the updated alias 'kotlinxCoroutines' for the kotlinx-coroutine-test dependency is intentional and that it aligns with the expected versioning across the project.
+kotlinxCoroutines = "1.7.3"

Comment thread app/src/main/java/com/amaze/filemanager/asynchronous/services/ftp/FtpService.kt Outdated
- Replace EventBus with kotlinx.coroutines
- FtpServerFragment update code to recommended
- FtpService explicitly acquires wakelock and enforces START_STICKY to ensure it's still running in the background even in the doze mode. Fixes TeamAmaze#4125
- Upgrade ACRA to 2.13 for fixing square/leakcanary#2568
@TranceLove TranceLove force-pushed the feature/ftp-eventbus-replace-with-kotlinx-flow branch from 5abbb83 to c2b8a7b Compare April 6, 2025 15:18
@VishnuSanal
Copy link
Copy Markdown
Member

3e2cbf3 for the conflict introduced by #4371

@VishnuSanal VishnuSanal added the PR-Awaiting-Initial-Review this PR is awaiting for an initial review label Apr 14, 2025
Copy link
Copy Markdown
Member

@EmmanuelMess EmmanuelMess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When pressing the tile I get:

2025-04-15 19:07:45.696  4747-4747  FtpReceiver             com.amaze.filemanager.debug          E  Failed to start/stop on intent startForegroundService() not allowed due to mAllowStartForeground false: service com.amaze.filemanager.debug/com.amaze.filemanager.asynchronous.services.ftp.FtpService

And when starting from the app it crashes:

2025-04-15 19:09:26.452  4747-4747  AndroidRuntime          com.amaze.filemanager.debug          E  FATAL EXCEPTION: main
                                                                                                    Process: com.amaze.filemanager.debug, PID: 4747
                                                                                                    java.lang.RuntimeException: Unable to start service com.amaze.filemanager.asynchronous.services.ftp.FtpService@95ee603 with Intent { cmp=com.amaze.filemanager.debug/com.amaze.filemanager.asynchronous.services.ftp.FtpService }: java.lang.IllegalArgumentException: foregroundServiceType 0x00000001 is not a subset of foregroundServiceType attribute 0x00000000 in service element of manifest file
                                                                                                    	at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4962)
                                                                                                    	at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0)
                                                                                                    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2393)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:242)
                                                                                                    	at android.os.Looper.loop(Looper.java:362)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8393)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:992)
                                                                                                    Caused by: java.lang.IllegalArgumentException: foregroundServiceType 0x00000001 is not a subset of foregroundServiceType attribute 0x00000000 in service element of manifest file
                                                                                                    	at android.os.Parcel.createExceptionOrNull(Parcel.java:3083)
                                                                                                    	at android.os.Parcel.createException(Parcel.java:3063)
                                                                                                    	at android.os.Parcel.readException(Parcel.java:3046)
                                                                                                    	at android.os.Parcel.readException(Parcel.java:2988)
                                                                                                    	at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7154)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at leakcanary.ServiceWatcher$install$4$2.invoke(ServiceWatcher.kt:93)
                                                                                                    	at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
                                                                                                    	at $Proxy4.setServiceForeground(Unknown Source)
                                                                                                    	at android.app.Service.startForeground(Service.java:862)
                                                                                                    	at androidx.core.app.ServiceCompat$Api34Impl.startForeground(ServiceCompat.java:241)
                                                                                                    	at androidx.core.app.ServiceCompat.startForeground(ServiceCompat.java:172)
                                                                                                    	at com.amaze.filemanager.asynchronous.services.ftp.FtpService.onStartCommand(FtpService.kt:132)
                                                                                                    	at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4944)
                                                                                                    	at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0) 
                                                                                                    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2393) 
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:111) 
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:242) 
                                                                                                    	at android.os.Looper.loop(Looper.java:362) 
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8393) 
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) 
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:992) 
                                                                                                    Caused by: android.os.RemoteException: Remote stack trace:
                                                                                                    	at com.android.server.am.ActiveServices.setServiceForegroundInnerLocked(ActiveServices.java:2061)
                                                                                                    	at com.android.server.am.ActiveServices.setServiceForegroundLocked(ActiveServices.java:1687)
                                                                                                    	at com.android.server.am.ActivityManagerService.setServiceForeground(ActivityManagerService.java:13761)
                                                                                                    	at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:3500)
                                                                                                    	at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2834)
2025-04-15 19:09:26.454  4747-4747  ACRA                    com.amaze.filemanager.debug          E  ACRA caught a RuntimeException for com.amaze.filemanager.debug
                                                                                                    java.lang.RuntimeException: Unable to start service com.amaze.filemanager.asynchronous.services.ftp.FtpService@95ee603 with Intent { cmp=com.amaze.filemanager.debug/com.amaze.filemanager.asynchronous.services.ftp.FtpService }: java.lang.IllegalArgumentException: foregroundServiceType 0x00000001 is not a subset of foregroundServiceType attribute 0x00000000 in service element of manifest file
                                                                                                    	at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4962)
                                                                                                    	at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0)
                                                                                                    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2393)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:242)
                                                                                                    	at android.os.Looper.loop(Looper.java:362)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8393)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:992)
                                                                                                    Caused by: java.lang.IllegalArgumentException: foregroundServiceType 0x00000001 is not a subset of foregroundServiceType attribute 0x00000000 in service element of manifest file
                                                                                                    	at android.os.Parcel.createExceptionOrNull(Parcel.java:3083)
                                                                                                    	at android.os.Parcel.createException(Parcel.java:3063)
                                                                                                    	at android.os.Parcel.readException(Parcel.java:3046)
                                                                                                    	at android.os.Parcel.readException(Parcel.java:2988)
                                                                                                    	at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7154)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at leakcanary.ServiceWatcher$install$4$2.invoke(ServiceWatcher.kt:93)
                                                                                                    	at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
                                                                                                    	at $Proxy4.setServiceForeground(Unknown Source)
                                                                                                    	at android.app.Service.startForeground(Service.java:862)
                                                                                                    	at androidx.core.app.ServiceCompat$Api34Impl.startForeground(ServiceCompat.java:241)
                                                                                                    	at androidx.core.app.ServiceCompat.startForeground(ServiceCompat.java:172)
                                                                                                    	at com.amaze.filemanager.asynchronous.services.ftp.FtpService.onStartCommand(FtpService.kt:132)
                                                                                                    	at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4944)
                                                                                                    	at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0) 
                                                                                                    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2393) 
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:111) 
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:242) 
                                                                                                    	at android.os.Looper.loop(Looper.java:362) 
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8393) 
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) 
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:992) 
                                                                                                    Caused by: android.os.RemoteException: Remote stack trace:
                                                                                                    	at com.android.server.am.ActiveServices.setServiceForegroundInnerLocked(ActiveServices.java:2061)
                                                                                                    	at com.android.server.am.ActiveServices.setServiceForegroundLocked(ActiveServices.java:1687)
                                                                                                    	at com.android.server.am.ActivityManagerService.setServiceForeground(ActivityManagerService.java:13761)
                                                                                                    	at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:3500)
                                                                                                    	at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2834)

Device: Moto G73 5G

@TranceLove
Copy link
Copy Markdown
Collaborator Author

Need to pass #4378 first to fix the foregroundService problem.

@EmmanuelMess EmmanuelMess self-requested a review April 16, 2025 22:29
@EmmanuelMess
Copy link
Copy Markdown
Member

EmmanuelMess commented Apr 23, 2025

Filezilla is not able to connect to the server. I have rebased to release/4.0 head:

Estado:	Conectando a 192.168.100.13:2211...
Respuesta:	fzSftp started, protocol_version=11
Comando:	open "test@192.168.100.13" 2211
Error:	FATAL ERROR: Remote side unexpectedly closed network connection
Error:	No se pudo conectar al servidor

Device: Moto G73 5G

@EmmanuelMess EmmanuelMess added PR-Requested-Changes this PR is awaiting an update from the author and removed PR-Awaiting-Initial-Review this PR is awaiting for an initial review labels May 1, 2025
@TranceLove
Copy link
Copy Markdown
Collaborator Author

Filezilla is not able to connect to the server. I have rebased to release/4.0 head:

Estado:	Conectando a 192.168.100.13:2211...
Respuesta:	fzSftp started, protocol_version=11
Comando:	open "test@192.168.100.13" 2211
Error:	FATAL ERROR: Remote side unexpectedly closed network connection
Error:	No se pudo conectar al servidor

Device: Moto G73 5G

SFTP is not FTPS which we have here - a FTP server with TLS support 👀

@EmmanuelMess
Copy link
Copy Markdown
Member

Okay,how are you testing this? I cannot get it to connect. With lftp on a real phone I get "`ls' en 0 [Negociando FEAT...]". For an emulator it doesn't even connect, but I suspect the ip bridging is broken.

@TranceLove
Copy link
Copy Markdown
Collaborator Author

Easiest way would be let the FTP server run on real device, then connect over LAN. I too have a lot of trouble to get it run on emulator for local clients to connect.

@EmmanuelMess EmmanuelMess added PR-Awaiting-Initial-Review this PR is awaiting for an initial review and removed PR-Requested-Changes this PR is awaiting an update from the author labels Jan 13, 2026
@EmmanuelMess
Copy link
Copy Markdown
Member

I need to try to retest this. Please remind me if I forget.

Copy link
Copy Markdown
Member

@EmmanuelMess EmmanuelMess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as tested on my Motorola G73 5G.

@EmmanuelMess EmmanuelMess merged commit a434812 into TeamAmaze:release/4.0 Jan 21, 2026
4 checks passed
@EmmanuelMess EmmanuelMess deleted the feature/ftp-eventbus-replace-with-kotlinx-flow branch January 21, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-FTP Related to FTP Server. PR-Awaiting-Initial-Review this PR is awaiting for an initial review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FTP Stops when the screen auto-sleeps

4 participants