GSConnect / gnome-shell-extension-gsconnect

KDE Connect implementation for GNOME
GNU General Public License v2.0
3.1k stars 253 forks source link

mount /sdcard/ #1801

Open lollilol opened 1 month ago

lollilol commented 1 month ago

android apps without root access and permission granted MANAGE_EXTERNAL_STORAGE can only access /sdcard/

when trying to access sftp://192.168.178.21:1739/ this error appears: image

after appending /sdcard/ to the sftp uri, i was able to successfully connect: image

ferdnyc commented 1 month ago

@lollilol

android apps without root access and permission granted MANAGE_EXTERNAL_STORAGE can only access /sdcard/

While that's true, I'm not sure it's that simple.

Looking at the latest KDEConnect Android app, I see the Filesystem Expose preferences seem to have vanished again, so you can no longer configure multiple shared storage locations.

In the past, after giving filesystem access permission, you'd be able to select one or more device locations to share, and they'd be exposed with the pathnames the user set. For example, here's the kdeconect.sftp packet that comes back from my older phone still running a version of the app with filesystem-selection preferences:

{
  "id": 1715569869701,
  "type": "kdeconnect.sftp",
  "body": {
    "ip": "L.M.N.O",
    "port": 1739,
    "user": "kdeconnect",
    "password": "XXXXXXXXX",
    "path": "/",
    "multiPaths": [
      "/primary",
      "/primary/DCIM"
    ],
    "pathNames": [
      "primary",
      "DCIM"
    ]
  }
}

...Now, that never worked very well, and it looks like it's gone again. The latest version of the app has no filesystem-expose preferences, and when it's activated and GSConnect tries to mount, this is the packet that comes back instead:

{
  "id": 1715570673060,
  "type": "kdeconnect.sftp",
  "body": {
    "ip": "L.M.N.O",
    "port": 1739,
    "user": "kdeconnect",
    "password": "XXXXXXXX",
    "path": "/storage/emulated/0",
    "multiPaths": [
      "/storage/emulated/0"
    ],
    "pathNames": [
      "Internal storage"
    ]
  }
}

Point being, I don't think there's a simple mapping. Your device is probably responding with a packet that includes:

    "path": "/sdcard",
    "multiPaths": [
      "/sdcard"
    ],
    "pathNames": [
      "Internal storage"
    ]

We likely need to start picking up that "path" from the packet (which always used to be "/", AFAICT, so it was hardcoded), and using it in the connection. But it'll likely be different for every device, so hardcoding it to /sdcard is as wrong as hardcoding it to /.

(If you could confirm that the kdeconnect.sftp packet includes /sdcard as the path on your phone, by doing a Generate Support Log collection, that'd be a big help.)

ferdnyc commented 1 month ago

@lollilol I've updated your branch to be in sync with main, so if you're going to make any changes locally be sure to first do a git pull to pick up the remote changes.

ferdnyc commented 1 month ago

We'll likely need to get rid of the Mount submenu, as well — it used to be, the contents of / were just a list of the configured share locations, so it was a relatively short list. But if the mount is going to go directly into the user's storage, there's no benefit in showing the entire directory listing as a submenu of GSConnect's device menu.

https://github.com/GSConnect/gnome-shell-extension-gsconnect/blob/883a8f62027f128bea9d09c80bc72de6adf0e5f8/src/service/plugins/sftp.js#L337-L352

ferdnyc commented 1 month ago

That'll mean eliminating the UnmountSection of (what was) the submenu, and promoting the Unmount action up to replace "Mount" in the device menu, instead of it being replaced with the submenu.

ferdnyc commented 1 month ago

Yeah, this is the kdeconnect-android commit that switched over to using MANAGE_EXTERNAL_STORAGE, and made the path value no longer hardcoded to / on their end.