Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace android sync framework result class with our own #1094

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

sunkup
Copy link
Member

@sunkup sunkup commented Oct 22, 2024

Purpose

More control over the sync result and less dependency on android.

Short description

  1. Add our own SyncResult data class with the following differences:
  • Not parcelable
  • Replaced databaseError with localStorageError and contentProviderError; Updated it's usages.
  • dropped methods, because unused:
    • madeSomeProgress()
    • clear()
    • describeContents()
    • writeToParcel()
    • toDebugString()
  • dropped properties, because unused:
    • fullSyncRequested
    • moreRecordsToGet
    • partialSyncUnavailable
    • syncAlreadyInProgress
    • tooManyDeletions
    • tooManyRetries
  1. Add our own SyncStats data class with the following differences:
  • Not parcelable
  • dropped properties, because unused or replaced:
    • numConflictDetectedExceptions (unused)
    • numParseExceptions (replaced by numDeadObjectExceptions and numServiceUnavailableExceptions)
  • added properties, to avoid overloading existing properties:
    • numHttpExceptions
    • numUnclassifiedErrors
    • numDeadObjectExceptions
    • numServiceUnavailableExceptions
  1. Tests ... to be added after first review

Note

  • I have not added SyncResult to BaseSyncWorker even though it's the only place where it's used, bacause BaseSyncWorker is a damn long file already.

  • I have not added tests yet because I am afraid there will be wishes for changes in the design.

Further Information
https://developer.android.com/reference/android/content/SyncResult

Checklist

  • The PR has a proper title, description and label.
  • I have self-reviewed the PR.
  • I have added documentation to complex functions and functions that can be used by other modules.
  • I have added reasonable tests or consciously decided to not add tests.

@sunkup sunkup added the refactoring Internal improvement of existing functions label Oct 22, 2024
@sunkup sunkup self-assigned this Oct 22, 2024
@sunkup sunkup linked an issue Oct 22, 2024 that may be closed by this pull request
@sunkup sunkup changed the title [WIP] Replace android sync result with our own Oct 22, 2024
@sunkup sunkup changed the title Replace android sync result with our own Replace android sync framework result class with our own Oct 22, 2024
@sunkup sunkup force-pushed the 886-replace-android-syncresult-by-custom-result branch from a1e47b4 to 9869f88 Compare October 22, 2024 12:31
@sunkup sunkup marked this pull request as ready for review October 22, 2024 13:05
@sunkup sunkup requested review from rfc2822 and ArnyminerZ and removed request for rfc2822 October 22, 2024 13:05
Copy link
Member

@ArnyminerZ ArnyminerZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. It's really odd to me to see data classes with vars and vals, but according to Kotlin it's valid sooo

@sunkup sunkup requested a review from rfc2822 October 24, 2024 08:13
Copy link
Member

@rfc2822 rfc2822 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Now we have it under our control, so we can further adapt it in the future, for instance drop / adapt the SyncStats etc.

@rfc2822 rfc2822 merged commit d00353b into main-ose Oct 25, 2024
7 checks passed
@rfc2822 rfc2822 deleted the 886-replace-android-syncresult-by-custom-result branch October 25, 2024 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Internal improvement of existing functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace Android SyncResult by custom result
3 participants