Init Calendar Provider Rule
JUnit ClassRule which initializes the AOSP calendar provider so that queries work as they should.
It seems that the calendar provider unfortunately forgets the very first requests when it is used the very first time (like in a fresh emulator in CI tests or directly after clearing the calendar provider storage), so things like querying the instances fails in that case.
Android-internal CalendarProvider2Tests
use a CalendarProvider2ForTesting
that disables the asynchronous code which causes the problems (like updateTimezoneDependentFields()
). Unfortunately, we can't do that because we have to use the real calendar provider.
So this rule brings the calendar provider into its "normal working state" by creating an event and querying its instances as long until the result is correct. This works for now, but may fail in the future because it's only a trial-and-error workaround.