Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to retrieve the selected path on removable media #47

Closed
BOB74j opened this issue Aug 22, 2021 · 27 comments
Closed

Unable to retrieve the selected path on removable media #47

BOB74j opened this issue Aug 22, 2021 · 27 comments

Comments

@BOB74j
Copy link

BOB74j commented Aug 22, 2021

OS: Android 10
Device: Moto G5+
Platform: ARM64
DroidFS version: 1.5.2

Cannot select a path on removable 8GB exFAT flash drive connected via USB OTG. Attempting to choose the volume path on the flash drive shows "Error: Failed to retrieve the selected path".

@hardcore-sushi
Copy link
Owner

Yes it's an expected behavior. When you pick a file or a directory on Android, you get an URI. So DroidFS will try to extract a path from it, but if it's not a regular URI that point to a location in shared storage, it fails most of the time. Do you have a way to see what's the URI being retrieved when picking a folder on USB ?

@BOB74j
Copy link
Author

BOB74j commented Aug 22, 2021

Yes it's an expected behavior. When you pick a file or a directory on Android, you get an URI. So DroidFS will try to extract a path from it, but if it's not a regular URI that point to a location in shared storage, it fails most of the time. Do you have a way to see what's the URI being retrieved when picking a folder on USB ?

URI to GoCryptfs config on USB OTG: content://com.android.externalstorage.documents/document/4839-8D98%3Acppcryptfs%2Fgocryptfs.conf

Interestingly, DroidFS is able to mount GoCryptfs volumes on external SD card. Copying the whole volume to my SD card allows the app to mount as read-only. URI is content://com.android.externalstorage.documents/document/EFFA-5B80%3Acppcryptfs%2Fgocryptfs.conf

@hardcore-sushi
Copy link
Owner

Awesome, how did you get this URIs ?
So I guess DroidFS can't retrieve the path if the volume is located on a USB OTG device. Since I don't have a USB OTG cable, I can't debug the problem. But maybe you can do it for me ? Are you able to compile the app from source ? Otherwise I can send you test APKs.

@BOB74j
Copy link
Author

BOB74j commented Aug 22, 2021

URIs were collected by opening the directory in the "Files" (com.android.documentsui) app, which is used as the default document storage provider when selecting a volume path through DroidFS. Long-pressing any file in that directory and selecting the share sheet brings up a Clipboard option through MiXplorer, a file manager app I use more frequently than Files. The document storage URI can then be pasted to any text field.

I would be a little unsure compiling from source, so test APKs would be appreciated. Thanks for working on this issue! My use case requires accessing encrypted storage from USB OTG.

@hardcore-sushi
Copy link
Owner

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

OK, I made a debug APK which will print some information in logcat. Don't expect it to work, I didn't modified the actual processing code. You can download it from here:

https://drop.underworld.fr/r/TNKgRcH6DF#hiQC6j+VTO+vKoi4vmdOKlUQiGHZhHj/RyygVYIMiMY=
SHA256: a9b83bf4660effffad88edb71a81d4a5de2375492baea03778146448ffa4eb1b

It's signed with my keys so if you installed DroidFS from F-Droid, you will probably need to uninstall the old version first (WARNING: this will remove all your hidden volumes).

Once installed, just select a volume on your USB-OTG storage from the app to reproduce the bug. Then send me the logcat output. You can get it using adb, Android Studio, or an awesome app like this one: https://f-droid.org/en/packages/com.dp.logcatapp
DroidFS will log with the tag "USB-OTG". You can look for it in the logcat output to check you are sending the right thing.
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEvVYhR557dNNqQFvoAH+EEgEHGR4FAmEinQcACgkQAH+EEgEH
GR6Yow/+OvCNSaxuPR94oicuP/2ClkWpO4ErlZ8dkjyxDgoNASS49H3EnUsM63wo
qERjTkggoCbxf7paLlHQbFN7lkRVL3aG4sR9wa2OhRF2emK5XpeIzOzqTY9SfF9Q
1WNJn+/PCf5EOMH9QD72EZFzpx/5dun/HMTSisZNftLwUmh38pg5tAU3cBfHDlIq
rHZTIMcE7mXG90Z6P5Zcf+s4mG1oI6fSLw0W/+WnvbEW1Q/LR7eLoPWBHki+lkiu
Bg3sVCdYysBptXE65jn4YBpPQkVLmwNo3VfR94QxLIL9V2pNWGNEXaZbwyU0aNYP
iuIQw6nunpVvYQw89/Aovx+zlIJU7mWJ4ozLRoZNumCe8fpQ8Z/OSvJDAAjffkls
ewQ/h/ovxh0b+GrzLxC98txpbBxPmhRSdWL/iAFNh6mdYJrAfz5nEoiZY/k/Uc4x
k6cLhN8fx6BXQ7JiXWaNrT3KZ73z2Ynk21WIo1GfeXJfx/DSlaA+EAPqGEva4YbT
dK6NyWu7mJQhAhLJf+u0v18yYL0dzALUI8IEof7lD+LIBGDsXohCgrUhvSFFo5X/
xkdseEsDKKtnyUX9kbFHTHKbvg2uRxNK9Q6vGI8czePuhGXl+Uy80D35o0q+OBro
84uyxWNSb+NzcDZneCEV3C1ZlGvVq8meymRBVCXSJHXNsCm5A5g=
=T9dv
-----END PGP SIGNATURE-----

@BOB74j
Copy link
Author

BOB74j commented Aug 22, 2021

I have attached a logcat when selecting the OTG volume path and a logcat from selecting the volume on external SD card.

logcat_extsd.txt
logcat_otg.txt

@hardcore-sushi
Copy link
Owner

That's what I thought, the USB-OTG device is not in the storage volume list that DroidFS can deduce a path from. Maybe a dirty string manipulation can do the trick...

@hardcore-sushi
Copy link
Owner

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

OK, I modified the code so that it will try path manipulation if the first method fails.

You can download this APK from here: https://drop.underworld.fr/r/6gxdAyG7gE#XMFbQg2yibzRo27bd6eGYmVyXBxo6nL3CX/zhBpnhHs=
SHA256: 72d4594039fd6b43ed8903442c111684b0ea9f165e0fdcf10071ee215ec17cf0

I added some debug information so a logcat dump would still be appreciated.
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEvVYhR557dNNqQFvoAH+EEgEHGR4FAmEmGkkACgkQAH+EEgEH
GR6evg//dKbR8hnmncrg0hpOQSDLMWctRr2MdBy0DPb8i+CcsKPdJ7jT81yG0c2t
TJ2GVTM0bLqCVjoOWy6geiUdLAMVnJmCw9brChsOuQVC4LyEgex4Oz06A6nJskYb
V8gUdFDw67GgwdEeFPWL5N2aqZzjROLtDOW6uEfLwztBFoOjh8Xh7c4eb7E7U+0U
dC2hBSJVuahILActqHEot4m+wSL+4QjdHcVIEjZ5quR7g/2E11bHGQknlKH+RKwC
h5lIRuKjuvR+OhuwmDzmdUssXF5tr33t0aNdtPwM3HX2KKNdtukFosKD4LMv9Fe5
+XXViSkd7thuVCeQ/J22ItWLyTErH/J60tRaYJFWZOUrCgu6qAwEz7JbozTeedW6
OmlbDem8YVLQ18IgqiqOVDOMloolHoFr8rEB8LC7asuNH4PjzTgDwM0ttXrFwfbb
pM7wU08Z3BQEYMNiBapt5E8haduDNq0P9u5ef6QSZujMpzzdNiwPAdPNO6dxdjPs
rZ6fjY3ABiPrMjaOzBtUNNV7jZFyQ275HDaUt6QIBvfDnP7VlHIs2y/cRYv+4TJ1
iUq4m6kMbzQeN/N3Fv/pKSXfBIQPhVOc9i3a14KgOwr13wqRxsxdz7KjAkf3ellA
MERikd87L44BH42VAMTNQqsdhFbGgVXeFCccxg7fC9BVfg2lUdc=
=L4ms
-----END PGP SIGNATURE-----

Thanks !

@BOB74j
Copy link
Author

BOB74j commented Aug 25, 2021

That's progress: Volume path can now be chosen over USB-OTG, but after entering the password and choosing open, an error is displayed:

Gocryptfs volume not recognized. Please check the selected path.

Copying the volume to internal storage or external SD card permits mounting as normal. Logcat and screenshot are attached below.

logcat_otg2.txt

Screenshot_20210825-180428738

@hardcore-sushi
Copy link
Owner

This is probably because Android doesn't allow DroidFS to access USB-OTG using raw file path. I built another debug APK that should confirm this:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

https://drop.underworld.fr/r/SNFZSPWx11#mqL83pY6G7Bb59boH/sSoCk6fcRL3VcssOSn0FfNF9g=
SHA256: 3a5e5b875d5f923bc7ec16bf14cfb588b1b2177a5b4321262183dda3023600f0
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEvVYhR557dNNqQFvoAH+EEgEHGR4FAmEnaFIACgkQAH+EEgEH
GR7fJg/+O12zapXB6RcQ0u83cVRJjKgcYzDzF16B8xAz1ZVmESLHLWihaU4v5vRj
uqqaAHw0lDlnVdbpZ/XRSuyvb3NwAhPeJWShAAgZ1CksQ+HqRtz5RtIlQMQpxyIc
LnpBRi2eu8RsTCF2eUtk/FNKbZmh5wt7dAC2M98ocZhIfNncF5urgmMNsg2OquNo
ds9Qb5A3e1jYSS0xDYAB0QJ3EBIyMwGcfNhsV3AbfbHdbxSCoIl9sfjy9Ca4+9mn
Lhrah0SzijBs3bfqeHz5FgFOCmEoT3RPkVd5S35JNRJVVElKb0G+SnhrHr7Ww9io
h27mjoEbD1LgFy1JJ2BsIxHm97lFxz/N9Dh6fHHIxDyUwWWqDv3JLN0ADXwn2c+f
50Pbi+5dSo4482N10Aiz1Xt5liW1YJU0he81SsicIJj6V/1lfKDq1kUXPcNBz0pd
OsvAIsBYCAmrvFsL+4vyutS5oYI7Wb+XYSVwj1SyvKC9ZfrAXcHhwPLO/gwSHndN
PHtEXqE9Vtxu+A1sYi0GpqjnHE67ulGTv4WanRs3Xc/TIZtaTFWf80BnM6272lwE
ZI2ZkiHTtuXp0fPhh9VMsBqcpALxsqknxWPwGMK1jip0trnYb++B5wnGokegfdiG
z0SKXW7INIvT7GJ+wNz32OFne/BtSgBqT+FfbPQSHjY20AhrfeU=
=Lot2
-----END PGP SIGNATURE-----

@BOB74j
Copy link
Author

BOB74j commented Aug 26, 2021

Logcat from trying to mount from OTG with latest debug APK.

logcat_otg3.txt

@hardcore-sushi
Copy link
Owner

Strange, it says that the path /storage/9007-78F2/cppcryptfs doesn't exist. Can you cd in it then do a ls from command line on a terminal emulator (non system app, without root access) ? Android probably denies apps from accessing USB-OTG devices through raw file paths. Unless becoming root, I don't know how to bypass that. If anyone has a solution, it would be greatly appreciated.

@BOB74j
Copy link
Author

BOB74j commented Aug 26, 2021

ls works for /storage/EFFA-5B80/ (external SD) but it's showing "No such file or directory" for /storage/9007-78F2/. Material Terminal screenshot here.

I know EDS Lite allows mounting and even editing EncFS and other container formats from OTG, but unfortunately the app does not support gocryptfs. See workflow here. The container path used was doc-tree://com.android.externalstorage.documents/tree/9007-78F2%3A/document/9007-78F2%3AEncfs.encfs

@hardcore-sushi
Copy link
Owner

OK so Android has a very strict policy concerning USB-OTG device access. Apps seems not allowed to use file paths with them. I read some part of the EDS Lite source code and it seems that the app only uses URI. Unfortunately, I don't see any solution except becoming root or rewrite the whole gocryptfs code to Kotlin/Android. I'm afraid that your USB device won't be accessible from DroidFS for a while...

@jwmh
Copy link

jwmh commented Sep 9, 2021

What about as a file manager using Ghost Commander (latest version from the Google Play store)?

market://details?id=com.ghostsq.commander

(Note-- be sure to use the Play Store, not fdroid, for latest version...)
and maybe some plugins for it, too.
Then copying/pasting the path used in GhostCommander to access the folder.

I did this on AndroidGO 8.1.0 to get the raw file access instead of the contentprovider URI.

@BOB74j
Copy link
Author

BOB74j commented Sep 10, 2021

What about as a file manager using Ghost Commander (latest version from the Google Play store)?

market://details?id=com.ghostsq.commander

(Note-- be sure to use the Play Store, not fdroid, for latest version...)
and maybe some plugins for it, too.
Then copying/pasting the path used in GhostCommander to access the folder.

I did this on AndroidGO 8.1.0 to get the raw file access instead of the contentprovider URI.

Android 10, DroidFS v1.5.4 here, still no dice using any of the path formats provided by GhostCommander.

@hardcore-sushi
Copy link
Owner

Hi, on SD cards, DroidFS can write under Android/data/sushi.hardcore.droidfs through raw file paths. Does it work also with USB-OTG devices ?

@lxsycht
Copy link

lxsycht commented Jan 19, 2022

Hi. I don't know much about Android development but I hope this might be helpful.

Android 11 introduced some changes in how storage is handled, including the option to access files per direct file path, as documented here

Could DroidFS possibly take advantage of this new feature?

@hardcore-sushi
Copy link
Owner

Yes it's planned to use MANAGE_EXTERNAL_STORAGE but that's only available on Android 11+.

@ramezquitao
Copy link

Hello, I'm having the same issue in a Samsung A70. Is there any way to access the external USB key in this devices?

Thanks

@BOB74j
Copy link
Author

BOB74j commented Dec 12, 2022

Hi, on SD cards, DroidFS can write under Android/data/sushi.hardcore.droidfs through raw file paths. Does it work also with USB-OTG devices ?

Sorry for being a year late coming back to the party. On Android 10, DroidFS version 1.10.1, attempting to enter USB-OTG path /mnt/media_rw/5088-7DB7/data/sushi.hardcore.droidfs or /storage/5088-7DB7/Android/data/sushi.hardcore.droidfs to the Add volume menu returns the error DroidFS doesn't have write access to this path. Please try another location.

The same path selected through storage access framework gives the error Failed to retrieve the selected path. In contrast to OTG devices, selecting the Android/data/sushi.hardcore.droidfs path on the SD card works (though other SD card directories, as expected, do not).

So it seems that on Android 10, OTG devices are still not compatible. Am I correct to interpret that OTG devices may work on Android 11+ when MANAGE_EXTERNAL_STORAGE is implemented in DroidFS?

@hardcore-sushi
Copy link
Owner

hardcore-sushi commented Dec 12, 2022

Thanks for your feedback. I don't know if it's going to work at all, but it's planned to be implemented for DroidFS v2.0.0 (stable).

@BOB74j
Copy link
Author

BOB74j commented Apr 19, 2023

OTG volumes may now be mounted on latest 2.0.0 release! Read/write access works, no need to place volumes under /Android/data/sushi.hardcore.droidfs Tested on Galaxy S23/Android 13.

@BOB74j BOB74j closed this as completed Apr 19, 2023
@rootdeck
Copy link

rootdeck commented Jul 3, 2023

I have read issue #47 and I thought usb otg is working since v2 but I still get this error "DroidFS doesn't have write access to this path. Please try another location" when I try to add a volume from the usb. I tried it both on android 11, 13 and it shows the same error. Thank you for the great app.

@hardcore-sushi
Copy link
Owner

What's your device model and ROM ?

Make sure that DroidFS is granted "All files access" permission and that your drive is mounted read/write.

Please show your logcat while reproducing the bug.

@rootdeck
Copy link

rootdeck commented Jul 4, 2023

I manage to make it work using v2.0.2 on android 13

  1. Plug in the USB, Open the app and try to mount/create the volume.
  2. The error "DroidFS doesn't have write access to this path. Please try another location" will pop up.
  3. close the app
  4. Open the app. Try to mount it again and it will work.

I don't know why I need to close the app but it works when I do that. no luck on android 11 so I just update to 13.

@hardcore-sushi
Copy link
Owner

OK, that's weird. Can you please show your logcat of the bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants