davx5-ose
davx5-ose copied to clipboard
Use Workmanager content triggers instead of sync framework
Right now the sync framework has two ways to trigger our sync workers which happens when:
- a user requests sync via button in calendar/contact/tasks app
- content in calendar or contacts provider changes
The first is not really a problem for us. It works well and we will probably always need to listen to sync framework sync requests to catch user initiated syncs (ie. pull-to-refresh). On the contrary, Pending syncs are unreliable in A14+ in the sync adapter framework - and so this issue tries to explore long term alternatives.
Workmanager content triggers make it easier to enqueue work from ContentObservers. We tried implementing this already, but stopped because restraining triggers to DAVx5 managed calendars and specific DAVx5 accounts became too complex.
The issue is that since ContentUriTrigger relies on ContentObserver we only get updates for table-level URIs, not individual row URIs.
content://com.android.calendar/eventsworks (entire events table)content://com.android.calendar/events/123doesn't work (single event or calendar)
This issue intends to explore what possibilities we have when notified of a table wide content change.
Contacts:
Query the whole table, but filtered for our account(s) and a positive dirty flag.
Calendars:
- Remember last sync time (per collection or account/service)
- query for events which belong to our account/calendar and have LAST_MODIFIED > sync time
- if there are > 0 entries one of our calendars changed and we need to sync it - or the account