aldenml / libtorrent4j

libtorrent for java, a swig Java interface for libtorrent
http://libtorrent4j.org
Other
219 stars 31 forks source link

[Android] NTFS/exFAT is unsupported: (1) Operation not permitted [write : file_open] #201

Closed proninyaroslav closed 2 years ago

proninyaroslav commented 2 years ago

I got this from a user of my app. libtorrent4j 2.0.4-21 is used here. So far I can't test it with 2.0.4-22-RC1, but there will be a release soon. He uses NTFS for SD card on Android 11. At the same time, he can download to the internal storage without any problems: disk error: (1) Operation not permitted [write : file_open] in file: /storage/B8CCF31FCCF2D69A/Download/***

Full log: LibreTorrent_log_11-29-2021_12-36-35.txt

aldenml commented 2 years ago

Is NTFS supported in Android already?

proninyaroslav commented 2 years ago

I don't know about AOSP, but many firmwares have NTFS support.

proninyaroslav commented 2 years ago

@aldenml As it turned out, libtorrent4j has problems not only with NTFS, but also with exFAT https://gitlab.com/proninyaroslav/libretorrent/-/issues/384#note_817005551. As I found out, sdfat is the old name of the exFAT driver in Android. It looks like exFAT has become the most common fs for SD cards since Android 12 (because SdCardFs is deprecated since Android 11).

proninyaroslav commented 2 years ago

This seems to be a bug on the Android Framework side. The system gives incorrect information about the write permission.

aldenml commented 2 years ago

This was my thinking, the way they manage the access at the process layer is really complicated.

proninyaroslav commented 2 years ago

Yeah, actually it's weird, the permission check sometimes fails.

sam-gq commented 1 year ago

It seems I found the similar problem when mounting an SD card and flash drive with exFAT to Android device. It shows not supported and need to format the disk which is not ideal.

But this is a Good News!

I found out on the Internet that exFAT filesystem is supposed to be a supported on Android 13 and beyond, and it seems to be shipped with Linux Kernel 5.10 or later (where 5.4 initially released a new feature to support exFAT.).

And there is a potential if you have initial released Android 12 device with Kernel 5.10 or later, there is a chance to work with exFAT. But it requires to root your device with Magisk and install the Vold-exFAT module. https://github.com/Jimbo77/Vold-exFAT

Rejoice for Flash Drive/SD card users. But unfortunately, lots of devices doesn't have a dedicated slot (SD card slot).

References: https://www.androidpolice.com/pixel-android-13-exfat-support-history/ https://forum.xda-developers.com/t/mod-magisk-android-12-vold-exfat-otg-support-for-pixel-6-pro.4401527/

Hope it helps bro. EDIT: BTW I used LibreTorrent.