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

SyncAdapter: Hilt error handling #1299

Merged

Conversation

rfc2822
Copy link
Member

@rfc2822 rfc2822 commented Feb 6, 2025

After a lot of playing around and testing, I chose the simplest modification to work around the problem. I think it can't be completely avoided that syncs are called (except when we would use a "test account" account type for testing, but then we would test something else that we'd use in the real app).

Short description

  • This PR handles the "Hilt: component not initialized" exception in SyncAdapterServices, so that the tests don't fail when such an (unwanted) sync is started.
  • Adds a comment to sync_calendars.xml to explain what isAlwaysSyncable really does.
  • Adds a comment to the SyncAdapter constructor to explain what autoInitialize really does.
  • Requires Android P for instrumented tests (throws error on <P) because the tests use MockK features which are not available for <P.

CC @sunkup

@rfc2822 rfc2822 added the bug Something isn't working label Feb 6, 2025
@rfc2822 rfc2822 self-assigned this Feb 6, 2025
@rfc2822 rfc2822 marked this pull request as ready for review February 6, 2025 16:24
@rfc2822 rfc2822 merged commit 946c450 into main-ose Feb 6, 2025
8 checks passed
@rfc2822 rfc2822 deleted the 1273-dont-crash-when-syncadapter-is-called-before-hilt-init branch February 6, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CI] Tests sometimes fail, probably because sync framework is called for short-lived test accounts
1 participant