Bug 391464 - KDEConnect does not browse my external SD correctly
Summary: KDEConnect does not browse my external SD correctly
Status: RESOLVED DUPLICATE of bug 336043
Alias: None
Product: kdeconnect
Classification: Applications
Component: common (show other bugs)
Version: 1.0
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Albert Vaca Cintora
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-06 10:59 UTC by eduardo.dejuan
Modified: 2018-05-28 13:29 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
KDE Connect browser (174.54 KB, image/png)
2018-03-06 11:07 UTC, eduardo.dejuan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description eduardo.dejuan 2018-03-06 10:59:02 UTC
Hi
the KDE Connect utility does not browse (mount) my mobile's external SD correctly.

After installing KDE Connect on my linux box and on my android Samsung mobile I clicked on the KDE Connect folder icon, a dolphin browser popped up, and I can see the following directory structure 4 entries (in my case in Spanish):

  SD Card
> Camera Images (SD Card)
  Camera Images (Internal storage)
> Internal Storage

I am able to browse both Internal Storage directory structures and I can write a file and delete it.
But when I click on the SD Card entry nothing is shown although if I write the subdirectory name (which I know is there) the browser does load it, i.e.

/home/gloriyedu/.config/kdeconnect/818cabcb6a68141a/kdeconnect_sftp/818cabcb6a68141a/storage/7F66-AAD9/Music

however I cannot create (write) any new file there.

The other directory "Camera Images (SD Card)" is mounted correctly and I see the photos that are stored there but I cannot write there either.

My Linux box is OpenSuse Leap 42.3, 64 bit, with KDE Connect 1.0.3-2.1

My mobile is a Samsung SM-J500FN with Android 6.0.1

Let me know if you need any other information to debug this issue.

regards, Eduardo
Comment 1 eduardo.dejuan 2018-03-06 11:07:59 UTC
Created attachment 111219 [details]
KDE Connect browser
Comment 2 eduardo.dejuan 2018-03-06 11:22:27 UTC
This is how the output of mount for the kdeconnect

gloriyedu@linux-palomar:~> mount | grep kdeco
kdeconnect@192.168.1.130:/ on /home/gloriyedu/.config/kdeconnect/818cabcb6a68141a/kdeconnect_sftp/818cabcb6a68141a type fuse.sshfs (rw,nosuid,nodev,relatime,user_id=1000,group_id=100)

regards
Comment 3 p 2018-03-21 20:39:10 UTC
I have the same issue on an S8. If you give me a hint where in the Android code this part is executed I could try to debug the code a little bit.
Comment 4 Nicolas Fella 2018-03-26 12:38:12 UTC
The responsible Package can be found at
https://cgit.kde.org/kdeconnect-android.git/tree/src/org/kde/kdeconnect/Plugins/SftpPlugin
Comment 5 eduardo.dejuan 2018-03-26 16:29:13 UTC
Hi Nicolas
are you suggesting I should load the sftp plugin on my android device?
I've searched for "sftp plugin" on Android Play Store but there is only a match called "Sftp plugin to ghost commander".
R/Eduardo
Comment 6 Nicolas Fella 2018-03-26 16:33:20 UTC
No, the SFTP Plugin is part of KDE Connect. My comment was directed to the comment above, asking where to find the code
Comment 7 p 2018-03-30 06:33:48 UTC

(In reply to Nicolas Fella from comment #4)
> The responsible Package can be found at
> https://cgit.kde.org/kdeconnect-android.git/tree/src/org/kde/kdeconnect/
> Plugins/SftpPlugin

SimpleSftServer has a class AdnroidFileSystemView which overrides method getFile. I see that this method is called multiple times when a directory is read. I can see that in Dolphin after every few executions of this method one directory after the other gets its numbers of entries shown. What I really don't see right now is, who is calling this method? I assume that KDE sends to KDE connect at some point in time "Hey show me the contents of directory xyz". And somehow in the reply the getFile method gets read. Can you give me a nudge into the right direction here?
Comment 8 p 2018-04-01 05:47:15 UTC
(In reply to Nicolas Fella from comment #4)
> The responsible Package can be found at
> https://cgit.kde.org/kdeconnect-android.git/tree/src/org/kde/kdeconnect/
> Plugins/SftpPlugin

Just posting my further findings, maybe that gives someone an idea or someone can give me a nudge into the right direction. When reading the SD card and doing a SSH_FXP_READDIR (SftpSubsystem.java) I get a java.io.FileNotFoundException for .android_secure file. I took my SD card out of my phone and mounted it in my Linux box. This file shows as available. Not sure if that is an expected behavior. Maybe someone can comment.
Comment 9 p 2018-04-01 12:39:13 UTC
Another update. I am either on a completely wrong track, or it is getting a bit more work.

SftpSubsystem in method process for case SSH_FXP_READDIR is a method call sendName(id,dh). That is the one which fails for .android_secure. If in the debugger I set the id from 0 to 1, then I see all the subdirectories on my SD card. In the code further down the line, the system all of a sudden claims that this file doesn't exist. All this part of the code comes org.apache.sshd:sshd-core. In the grade file I see that you use version 0.8 and claim that 1.+ requires java.nio.file which doesn't exit in Android. It is there since API Level 26 https://developer.android.com/reference/java/nio/file/package-summary.html which is Android 8.0. My device is Android 8.0. I tried to change the code to use sshd-core 1.7 (your version is about 6 years old). Unfortunately it seems that the package was refactored quite heavily in the past 6 years. I failed to do a quick exchange.

Am I on the wrong track? Is there an option for you to switch to 1.7? Any other opinions?
Comment 10 p 2018-04-01 17:42:33 UTC
Tested  a Samsung XCover with Android 5.1.1. Exactly the same behavior. I guess that means it doesn't depend on the Android version.
Comment 11 p 2018-04-14 05:31:45 UTC
Hello, I started to look into the write issue. Though I still believe the Apache sshd should get updated maybe the read issue can be prevented in some other way as well. I get the gut feeling that the raised issue here has to do with the Android storage access framework (SAF) introduced in Kitkat with some larger changes in Lollipop.

https://developer.android.com/guide/topics/providers/document-provider.html
https://stackoverflow.com/questions/36862675/android-sd-card-write-permission-using-saf-storage-access-framework

I see in the code that you use SAF in the share plugin, so if you want to send a file. For sending a file accessing the SD card access works fine. When browsing the phone from KDE it seems that SAF is not being used but that Apache sshd does all the work (which is a Java lib and not specifically for Android, hence it doesn't now these specifics and will never know about them).

Unfortunately I still don't understand the architecture of kde connect too well. Hence, currently I don't have an idea how to fix it. HELP! :-) I willing to look more into the issue, but I believe in order to help here (is that help wanted? If not please let me know) I need some insight into how kde connect works internally. If you are willing to give these insight and discuss this topic I believe that this bug tracker is the wrong place. Are there any proposals on how to continue on this?
Comment 12 Nicolas Fella 2018-04-14 16:17:40 UTC
Your help is very welcome!
We have a Telegram group for KDE Connect Development https://t.me/joinchat/AOS6gA37orb2dZCLhqbZjg
If you don't like to use Telegram you can reach us on our mailing list https://mail.kde.org/mailman/listinfo/kdeconnect

You will find a quick introduction in our README files https://cgit.kde.org/kdeconnect-kde.git/about/
Comment 13 Nicolas Fella 2018-05-28 13:29:23 UTC

*** This bug has been marked as a duplicate of bug 336043 ***