Skip to content

Wrap all RemoteException-throwing calls with LocalStorageException #2784

Description

@rfc2822

BatchOperation.commit() is documented to @throws RemoteException on calendar/task/contacts provider errors, and most callers wrap it correctly:

try {
    ...
    batch.commit()
    ...
} catch (e: RemoteException) {
    throw LocalStorageException("...", e)
}

However, several synctools call sites call batch.commit() without any surrounding try/catch, so a raw android.os.RemoteException (or its subclass DeadObjectException, thrown when the content provider process is dead/cached) can propagate un-wrapped up to SyncManager's exception handling.

Unwrapped call sites found so far:

  • AndroidContact.add()
  • AndroidContact.update()
  • AndroidCalendar's orphaned-exception cleanup
  • AndroidRecurringCalendar's exception-instance helper
  • AndroidRecurringCalendar's exception-instance helper
  • DmfsRecurringTaskList's exception-instance helper
  • DmfsRecurringTaskList's exception-instance helper
  • JtxRecurringCollection's exception-instance helper
  • JtxRecurringCollection's exception-instance helper

Consequence

SyncExceptionHandler.classifySyncException() has a special case that rethrows a LocalStorageException whose cause is DeadObjectException, so the sync gets rescheduled as a soft/cached-process condition instead of being shown to the user as an error. That special case only matches when the DeadObjectException is wrapped as documented above.

When all call sites are updated, we can also remove handling the RemoteException in SyncManager's error handling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions