haiwen/seadroid — pull request #117 by forouher (2014-10-05 10:50:37+00:00)
Title: Add support for the Storage Access Framework

The Storage Access Framework allows other apps to access files stored in Seafile repositories. See https://developer.android.com/guide/topics/providers/document-provider.html for more details.

It was added to Android with version 4.4 (API level 19), so there is not that much support yet. I tested it mainly with the K9Mail app, which uses it to add attachments to mails.
(Other apps that support it are Gmail and OpenKeyChain).

Implementation is done as an DocumentProvider. Only moderate changes to the existing code of Seafdroid were necessary. I've separated them out into individual patches for easier review.

I tested this using a Nexus 4 device, running Android 4.4.4. Browsing accounts/repositories/directories and downloading files should hopefully be pretty stable. Uploading/Creating/Deleting files is currently unsupported, mainly because I couldn't yet find an app that would make use of these features.

Caveat: I haven't yet fully understood the locking concept of Seafdroid. This patch set might therefore add race conditions, e.g. when accessing the database or downloading stuff from the server. There was one issue (see the patch for details) I observed, but there might be more out there. Someone should probably review this patch carefully, especially regarding the use of DataManager and AccountDbHelper from within the DocumentProvider.