DBFlow: FlowContentObserver Crash on Android O

DBFlow Version: 4.0.3 Issue Kind (Bug, Question, Feature): Bug/Question

Description: Calling registerForContentChanges() on FlowContentObserver causes java.lang.SecurityException: Failed to find provider TimeEntry_Model for user 0; expected to find a valid ContentProvider for this authority

This link explains the change in Android O https://developer.android.com/preview/behavior-changes.html#ccn

In debugging I found that the Uri DBFlow uses for my model is dbflow://%60TimeEntry_Model%60 I’ve tried adding that to the authorities property for my content provider in the android manifest file. I also tried adding TimeEntry_Model. However, I always get the same crash. My question is does this change in Android require something to change in DBFlow, or am I just not specifying the correct authority for my database model?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 6
  • Comments: 15 (5 by maintainers)

Most upvoted comments

observeOnTableChanges in the RX implementation also don’t seem to work anymore on Oreo, and when removing .modelNotifier(DirectModelNotifier.get()) from the init it goes back to SecurityException with the invalid uri.

Yes. I do not want to force consumers on it. If it’s exported there could be collisions in Android os that will prevent installing. If I included it in the library, most devs might not be aware it was there and get bug reports later about it.

@CapnSpellcheck You’re right that its only an issue if you target api 26. I’m not targeting that api yet mainly because of this crash. I’m not in a huge hurry to target 26 either, but it would be nice to have this addressed some time in the near future.

These APIs now require that a valid ContentProvider is defined for the authority in all Uris. 
Defining a valid ContentProvider with relevant permissions will help defend your app against content changes from malicious apps, and prevent you from leaking potentially private data to malicious apps.

meaning if you do not provide a ContentProvider that has the authority you’re targeting then you cannot use the default ContentResolverNotifier anymore. I will have to introduce a breaking change in DBFlow in order to switch over default to DirectModelNotifier. For now your best option to switch to the direct option. I may have to deprecate ContentResolverNotifier in a near-future release in order to have people switch over as some may not be aware they’re using it.