Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it normal for functions to be called multiple times in StorageProvider? #54

Open
jacopotediosi opened this issue May 27, 2020 · 3 comments

Comments

@jacopotediosi
Copy link

I am studying Documents Providers and I have found something that I cannot understand, which also happens with the "StorageProvider" example of this repository.

It appears that all functions are called more than once when I open SAF.

I report the logcat:

When I first open SAF:

2020-05-27 19:57:45.888 20322-20362/com.example.android.storageprovider V/MyCloudProvider: queryDocument
2020-05-27 19:57:45.971 20322-20362/com.example.android.storageprovider V/MyCloudProvider: queryChildDocuments, parentDocumentId: root: sortOrder: _display_name ASC
2020-05-27 19:57:45.990 20322-20362/com.example.android.storageprovider V/MyCloudProvider: queryChildDocuments, parentDocumentId: root: sortOrder: _display_name ASC
2020-05-27 19:57:46.036 20322-20362/com.example.android.storageprovider V/MyCloudProvider: openDocumentThumbnail
2020-05-27 19:57:46.078 20322-20362/com.example.android.storageprovider V/MyCloudProvider: openDocumentThumbnail
2020-05-27 19:57:46.093 20322-20362/com.example.android.storageprovider V/MyCloudProvider: openDocumentThumbnail
2020-05-27 19:57:46.109 20322-20362/com.example.android.storageprovider V/MyCloudProvider: openDocumentThumbnail

When I open a file (eg a photo with Google Foto):

2020-05-27 19:58:01.127 20322-20341/com.example.android.storageprovider V/MyCloudProvider: queryDocument
2020-05-27 19:58:01.273 20322-20362/com.example.android.storageprovider V/MyCloudProvider: openDocument, mode: r
2020-05-27 19:58:01.306 20322-20362/com.example.android.storageprovider V/MyCloudProvider: openDocument, mode: r
2020-05-27 19:58:01.344 20322-20362/com.example.android.storageprovider V/MyCloudProvider: openDocument, mode: r
2020-05-27 19:58:01.345 20322-20341/com.example.android.storageprovider V/MyCloudProvider: openDocument, mode: r
2020-05-27 19:58:01.381 20322-20341/com.example.android.storageprovider V/MyCloudProvider: openDocument, mode: r
2020-05-27 19:58:01.775 20322-20341/com.example.android.storageprovider V/MyCloudProvider: queryDocument
2020-05-27 19:58:01.810 20322-20341/com.example.android.storageprovider V/MyCloudProvider: queryDocument
2020-05-27 19:58:01.843 20322-20341/com.example.android.storageprovider V/MyCloudProvider: openDocument, mode: r
2020-05-27 19:58:01.849 20322-20362/com.example.android.storageprovider V/MyCloudProvider: openDocument, mode: r
2020-05-27 19:58:01.854 20322-20341/com.example.android.storageprovider V/MyCloudProvider: openDocument, mode: r
2020-05-27 19:58:01.868 20322-20362/com.example.android.storageprovider V/MyCloudProvider: openDocument, mode: r

Is it normal for queryDocument() and openDocument () to be called so many times?
That way, if my document provider were to download a file over the network, wouldn't it be downloaded multiple times?

@lukeisontheroad
Copy link

@jacopotediosi we do see the same issue on an Android 8.1 device. Were you able to fix this?

@jacopotediosi
Copy link
Author

@lukeisontheroad Unfortunately no. The documentation is very weak on this point.

@cketti
Copy link
Contributor

cketti commented Jun 5, 2020

I think these are absolutely cases that you need to be able to handle. Even if the SAF screen is changed to only query your providers once, there's nothing preventing apps from querying your provider multiple times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants