Like LG4
Description
Related Objects
I noticed I don't have write access on my SD card with the SFTP plugin, is it part of this task?
Well, this task is about doing anything necessary to make it work :P On some phones, kdeconnect doesn't have access to the sdcard, indeed, and that's big part of the problem. I don't know why it happens though nor how to fix it.
These two stackoverflow discussions, here and here, seem to answer how to write to external storage with the Storage Access Framework. Android also provides docs for the SAF, but it's not great imo.
I don't plan on working on this, as I don't have any experience on Android, and the SAF in particular is not very appealing. But that's what I found.
I lied, I've actually been working on this. I'm far from done yet, but at least I managed to write to the SD card, which wasn't possible before. I'm currently trying to make it work through the SFTP plugin. I'll upload a diff when I have a somewhat working version to get some feedback.
:D To make it work, do you first need to make the user select the SD root directory from the app, to obtain permissions to access it? That's what I thought would be necessary, but I'm curious to know if you found a different way :)
That's what I did, yes. I don't think there is any other way, Android really doesn't want anyone to access the filesystem without their API :/
We could ask the user for it the same way we ask for permissions... The wording could be something like "Please select the root directory of your phone to make it available from your PC" maybe?
That's what I had in mind too. Right now there's an intermediate screen with the FindMyPhone UI because I copy-pasted so it looks stupid but I couldn't be bothered :D
Progress report: creating a new empty file, renaming and deleting work (although it's definitely not pretty or optimised) but I can't get transferring or modifying files to work. Something with the write() method in SftpSubsystem or createOutputStream(). And I can override createOutputStream() which is what I'm working on but I can't override write(). With my own streams and write(), writing data to files actually works.
Beside rewriting a big portion of SftpSubsystem which is not really desirable, I don't have a lead for now. I'll post more details here (and maybe on StackOverflow) if I keep being stuck.
Here's the StackOverflow question: https://stackoverflow.com/questions/46060113/writing-with-an-outputstream-to-a-documentfile-data-seem-to-be-written-but-file, feel free to take a look and give a vote
I haven't been working on this lately because even though quite a few features work (permissions, creating new files, renaming, moving, deleting...), I was stuck on several major problems, in particular transferred files are empty until the device is rebooted (an outputstream doesn't close properly or something like that I think).
On top of that, working with the Android API is very frustrating, especially when it comes to filesystems.
Here is my private repository if someone wants to see (I worked on the storage-access-framework branch): https://gitlab.com/jean-sh/kdeconnect-a-private. The entire AndroidSftpSubsystem class is just a copy of SftpSubsystem so that I can test modifying stuff in it.
I might give it another go later so I won't abandon the task for now...