Collect: Externally accessing a content provider silently fails if storage permissions haven't been granted

Created on 3 Oct 2018  路  4Comments  路  Source: getodk/collect

Software and hardware versions

Collect v1.17.1, Android 6+

Problem description

If an external application tries to read from a content provider, no content is provided if the storage permissions haven't been granted. Discussed at https://github.com/opendatakit/collect/pull/2606#issuecomment-426646708

Steps to reproduce the problem

  1. Download some blank forms and fill out some of them
  2. Install @grzesiek2010's external integration tester: https://github.com/grzesiek2010/collectTester
  3. Revoke Collect's storage permissions
  4. Tap on "Form list" or "Instance list"

No content is shown. "Form list" should show all the blank forms downloaded in the first step. "Instance list" should show all the filled forms.

Expected behavior

Prompt for storage permissions.

Other information

I'm not sure whether this is possible or whether it's intended that content providers return no values if their host app doesn't have user permission to access the resource the provide access to. I think the first step is to see whether there is any place in the content provider definition where a permissions failure might be silently ignored rather than shown to the user.

help wanted

All 4 comments

Good point. I thought about this as well when the implementation was being done.

I think the first step is to see whether there is any place in the content provider definition where a permissions failure might be silently ignored rather than shown to the user.

Yes, it's being silently ignored on the premise that it was highly unlikely it would occur but here we are :sweat_smile:

In this case, what's the right thing do? Throw a permission denied exception?

The ideal would be to trigger the permission request the same way any other storage access does. Is that possible?

I don't think so especially since it's via a ContentProvider and permission requests will require an activity to be spawned. Also the usage seems a bit out of scope for a ContentProvider as well in my opinion.

Ok, I think that's right, thanks. Closing this and we can make sure the documentation includes information about the behavior in Android 6+ when permissions aren't granted. https://github.com/opendatakit/docs/issues/876

Was this page helpful?
0 / 5 - 0 ratings