by iggldiggl · 1w ago · 0 comments
The problem is that for anything more complicated than a simple "grant access to this one file/directory" both the permission system and its associated UI also get pretty complicated pretty quickly.
Like "opening a file with a certain app will allow that app to read that file" is pretty easy to understand, but "opening a file with a certain app will allow that app to read all other files within that directory" already less so (but is precisely what would be needed for an image viewer).
Eventually you get to a point where it's easier to just fall back to a generic "all files" permissions, which then leads back to arguments whether users can be trusted with it.
> The fact that the full path isn't revealed just seems like a sensible thing to do. Even if you give an app access to a full directory, why would it need to know where that directory is located?
You wouldn't necessarily need the full path of the directory, but you need at least some kind of handle to it, and Android doesn't give you one when you're receiving a single file from another app. And since the file path is hidden from you even if the file is local and not cloud-based or something else, you can't even ask the user for directory viewing permissions yourself (or maybe you've even already been granted those permissions, but you still can't use them because you don't know where that file resides).
The technical justification was that the new file sharing API could in theory be backed by anything, not just the local file system, so they didn't want apps to rely on a local file system path and therefore made the design to force apps away from it (only semi-successfully, because at the same time the default implementation still somewhat leaks the original path, so you could try to reverse-engineer it from that, plus when I tried to research a bit, it seemed that possibly even without root there still was some way of getting a file system path back from a raw file handle, provided of course that the file really was backed by something local, and not cloud storage).
So far so fine, but it does break some stuff. E.g. it messes up LRU lists (opening the same file once via app A and once via app B creates two distinct LRU entries in app C), plus like I said, even if the receiving app already holds sufficient file system permissions itself, it cannot use them because it doesn't (officially) know which file and which directory it's dealing with.
And like I said, for the use case of an image viewer being able to browse adjacent files, it needs to know not only the specific file it's supposed to open, but also its containing folder.
> It's been a long time since i used Android, but why don't they just implement the ability to grant access to a given folder?
They did, but in combination with the new file sharing API that is precisely what broke advanced UX workflows like wanting to browse adjacent files in an image viewer. (Or being able to view local HTML files that aren't monolithic MHTML archives – if you pick such a file from a file browser to open it in your web browser, the web browser won't be able to open any associated subresources or follow any links to other local files.)
No comments yet.