localsend / localsend

An open-source cross-platform alternative to AirDrop
https://localsend.org
Apache License 2.0
48.41k stars 2.64k forks source link

[bug] File Transfer Fails in Custom Directories on Android 1.15+ Versions #1544

Closed shing-yu closed 2 months ago

shing-yu commented 2 months ago

Describe the bug

After updating to LocalSend version 1.15+ on my Android device, I have encountered an issue where file transfers fail when the save directory is set to a location outside the default "Download" directory. This issue was not present in previous versions.

Based on my observations, the issue seems to be related to the permissions requested by the app. In earlier versions, after setting a custom path, the app would request "Manage All Files (MANAGE_EXTERNAL_STORAGE) " permission, which allowed file transfers to custom directories. However, in versions 1.15+ this permission request appears to be removing, leading to transfer failures when using non-default directories.

I am not certain if this issue occurs on all devices, but it has consistently occurred on my device.

To reproduce

  1. Update LocalSend to version 1.15+ on an Android device.
  2. Change the save directory to a non-Download directory.
  3. Try transferring the file to this device.
  4. Observe the error message indicating a failure in file transfer.

Expected behavior

The file transfer operation was successful.

Screenshots

7a97beb819056ed858518ef95c939301

Desktop (please complete the following information)

Smartphone (please complete the following information)

Additional context

I tried using adb shell appops set --uid org.localsend.localsend_app MANAGE_EXTERNAL_STORAGE allow, but it didn't help.

May be related to #1493 .

weiwei-cool commented 2 months ago

Yes!i can reapper on ColorOS 14 with Android 14. Error will apper unless the path is "Download"

weiwei-cool commented 2 months ago

I trid to give it the root permission or the adb permission, but Error still apper.

Tienisto commented 2 months ago

Yes, #1493 did broke some things. I've noticed that you can create a sub folder like "Download/LocalSend" and it should work (if you want to have a separate LocalSend folder).

Other than that, I guess we need to use "content URI" to save files outside the Download folder. For example: https://github.com/localsend/localsend/blob/422e65dde19726c8f35a5a09e31f7103b0c88b3e/app/lib/util/native/file_saver.dart#L33

It might have a performance impact because Dart/Flutter doesn't write directly to the file system anymore.

shing-yu commented 2 months ago

I've noticed that you can create a sub folder like "Download/LocalSend" and it should work (if you want to have a separate LocalSend folder).

Yeah, this is indeed a temporary solution.

SRC267 commented 2 months ago

Can confirm, The temporary solution does work, however applying the same sub folder method still throws an error if i select external SD Card as download path.