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

fix: location sharing without gms when not moving [WPB-9724] #3136

Merged
merged 9 commits into from
Jun 28, 2024

Conversation

saleniuk
Copy link
Contributor

@saleniuk saleniuk commented Jun 27, 2024

BugWPB-9724 [Android] Location sharing on graphene devices sometimes not working


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

Issues

Sometimes when we want to share the location on grapehene devices, the app is stuck on loading.

Causes (Optional)

On graphene there is no google services so the app uses the native manager to get the location, by requesting location updates. It works fine when the user is moving, but not when standing in the same place, probably because requestLocationUpdates emits items only when the location changes.

Solutions

On newer Android versions use new way of getting location - getCurrentLocation and on old ones instead of requestLocationUpdates, use requestSingleUpdate because the app needs and uses only a single data anyway, doesn't need to listen for multiple changes.
Also, to make it even faster and more user friendly, first the last known location is checked and if it's not too old (currently if it's not older than 1m) then just use this last location because it looks like the user hasn't moved since then.
If the last location is too old, then just request the current one. There is also a timeout of 10s to get the current location, getCurrentLocation has some timeout anyway, but it's not configurable and it's unclear how big it is, so to make it unified a custom one is created - if the new location doesn't appear within 10s, then user gets the info that the app couldn't get the location.
Added tests for both LocationPickerHelper (to test getting location without google services on both new and old Android versions using robolectric) and LocationPickerHelperFlavor (to test getting location with google services using mockk).

Testing

Test Coverage (Optional)

  • I have added automated test to this contribution

How to Test

Open conversation screen and try to share location.


PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

Copy link
Contributor

github-actions bot commented Jun 27, 2024

Test Results

855 tests   855 ✅  13m 46s ⏱️
117 suites    0 💤
117 files      0 ❌

Results for commit 0789dc7.

♻️ This comment has been updated with latest results.

Copy link
Contributor

APKs built during tests are available here. Scroll down to Artifacts!

@saleniuk saleniuk requested review from yamilmedina, a team, typfel, alexandreferris, mchenani and ohassine and removed request for a team June 28, 2024 07:12
@yamilmedina
Copy link
Contributor

yamilmedina commented Jun 28, 2024

I just realized these tests, were not in 4.6. But they are on release/candidate and up, so just raising as probably they will be conflicts to RC and Develop 🙈 I think if you have, just prefer these changes over whatever we have nowadays.

Copy link

Copy link
Contributor

APKs built during tests are available here. Scroll down to Artifacts!

@saleniuk saleniuk merged commit d768fce into release/cycle-4.6 Jun 28, 2024
12 checks passed
@saleniuk saleniuk deleted the fix/share-location-without-gms branch June 28, 2024 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants