←back to thread

410 points morsch | 2 comments | | HN request time: 0.545s | source
Show context
moonshot5 ◴[] No.43986181[source]
AOSP platform dev here. (Filesystem) Opinions my own, I don't speak for Google.

Disclaimer: I don't use nextcloud, and have not looked at their app specifically, this is just a surface level observation from my relatively informed perspective.

My take: SAF would work for this use case, as others have already mentioned.

Google Drive does not have the permissions that next cloud claims Google is giving preferential treatment to, and is delivered via the Play store in the same way nextcloud's app is.

As others have also observed, permissions such as MANAGE_EXTERNAL_STORAGE have been rampantly abused in the past, often in horrific ways.

replies(7): >>43986712 #>>43987576 #>>43987745 #>>43989733 #>>43990209 #>>43991397 #>>43992185 #
noname120 ◴[] No.43987745[source]
SAF is not an option because it is HORRIBLY slow[1][2][3][4][5], which makes it an absolute no-go for any decent cloud synchronization app.

Excerpt from [1]:

> SAF is slow. Every SAF file IO operation takes like 20-30ms because it uses an IPC call. And sometimes you may want to check whether a lot of files exist on the disk and if they do not then create them (or something similar that requires a lot of file operations). It's so slow that even in google example they use hacks to make it faster.

Excerpt from [3]:

> Just to add a new sample for the performance of SAF vs standard File operations:

> […]

> 15 seconds with SAF, 6 milliseconds with native ls ! And there's only 128 files LOL

————————

[1] https://github.com/K1rakishou/Fuck-Storage-Access-Framework#...

[2] https://www.reddit.com/r/androiddev/comments/ga5u72/saf_is_s...

[3] https://issuetracker.google.com/issues/73044953#comment5

[4] https://magicbox.imejl.sk/forums/topic/storage-access-framew...

[5] https://issuetracker.google.com/issues/130261278#comment52

replies(3): >>43987999 #>>43988073 #>>43989372 #
tadfisher ◴[] No.43987999[source]
This may be true, may have workarounds, and may be solved on later Android versions, but it also is not why Nextcloud says they are avoiding the framework. And Google Drive provides the same functionality using SAF, so I'm not sure it's a problem for this use case.
replies(1): >>43989855 #
1. noname120 ◴[] No.43989855[source]
There are no good workarounds unfortunately and it's definitely not solved on later Android versions. I agree though that the reason that Nextcloud gives is factually incorrect (they say that SAF is for providing files rather than accessing them, which is plain wrong).
replies(1): >>43990454 #
2. tadfisher ◴[] No.43990454[source]
From what I understand, you can resolve most issues by making ContentResolver queries yourself once you have URI permissions for a folder, including data like filename, mime type and file size in the query projection. This reduces an NxM number of queries to N, where N is the number of nested directories in the tree and M is the number of files in the directory.

Obviously this should be solved with a better API at the SAF layer.