Tweak instance generation

The code that regenerates the Instances table understands _sync_id
and originalSyncId, but is generally unaware of originalId.
This isn't a supported mode of operation for the app -- you're not
allowed to create a recurrence exception until after the event has
been synchronized with the server -- but you can hit it with the
provider's exception creation URI.

This change doesn't fix the problem, but does take a step toward it.
In particular:

- Deletion of existing instances is now correct.  This may be more
  visually jarring than the previous approach when creating
  exceptions in airplane mode: instead of seeing a doubled-up event,
  you'll see the original event vanish (it adds an instance for
  the exception, but can't find the recurrence).
- isRecurrenceEvent() now recognizes an event with a non-empty
  originalId as a recurrence exception.
- Some stuff in updateRecurrenceInstancesLocked() was hitting the
  database, some was assuming that values were in the set of goodies
  passed in.  This was potentially wrong for event updates, which
  could have a partial set of goodies.
- The exception creation URI code now only updates the affected
  Instances entries, instead of blowing away the entire table.

Two new tests have been added to exercise the various paths through
the instance regeneration code.

Also, adjusted the code that updates the Attendees table when an
exception changes selfAttendeeStatus to be more tolerant of transient
situations.

Bug 4473786

Change-Id: Ibd409373be002e71d5709ee1c17eb16976481ce2
3 files changed