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: keep OngoingCallService always running during call [WPB-10467] #3300

Merged

Conversation

saleniuk
Copy link
Contributor

@saleniuk saleniuk commented Aug 8, 2024

BugWPB-10467 [Android] crash after a call


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

There are some ForegroundServiceStartNotAllowedException crashes.

Causes (Optional)

This exception happens when when trying to start foreground service while the app is not allowed to do so, like when the app is considered to be in the background. More on that here: https://developer.android.com/develop/background-work/services/foreground-services#bg-access-restrictions
Sometimes the onStop event is emitted with some delay, we can't really make sure that the app will fit within the allowed time, it's not clear how the system determines whether the app is still able to start foreground service or not.

Solutions

Instead of starting the OngoingCallService only when the app goes into background, start it always when there's a new ongoing call and keep it running until it ends, so that the service is not stopped and started again when user puts app into foreground and background, so it's way less error-prone, and in that case starting foreground service should always be allowed because it happens right when the user makes an action to start or answer the call.
We actually already have that logic for Android 14 upwards, because of the microphone background restrictions, so another benefit of this change is that we will have that unified for all Android versions.

Testing

Test Coverage (Optional)

  • I have added automated test to this contribution

How to Test

Create or join a call, the notification about ongoing call indicating that the OngoingCallService is running should be visible during the entire call, no matter if the app is in the background or foreground and it shouldn't crash when putting the app into background during the call.


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.

@echoes-hq echoes-hq bot added the echoes: bugs Technical or functional defects in the product label Aug 8, 2024
@codecov-commenter
Copy link

codecov-commenter commented Aug 8, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Project coverage is 44.55%. Comparing base (3b93ee2) to head (30defbe).
Report is 1 commits behind head on release/candidate.

Files Patch % Lines
...re/android/notification/WireNotificationManager.kt 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##           release/candidate    #3300   +/-   ##
==================================================
  Coverage              44.55%   44.55%           
==================================================
  Files                    453      453           
  Lines                  15331    15322    -9     
  Branches                2558     2557    -1     
==================================================
- Hits                    6831     6827    -4     
+ Misses                  7782     7778    -4     
+ Partials                 718      717    -1     
Files Coverage Δ
...re/android/notification/CallNotificationManager.kt 44.91% <ø> (ø)
...re/android/notification/WireNotificationManager.kt 81.15% <88.88%> (+1.52%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3b93ee2...30defbe. Read the comment docs.

Copy link
Contributor

github-actions bot commented Aug 8, 2024

Built wire-android-staging-compat-pr-3300.apk is available for download

Copy link
Contributor

github-actions bot commented Aug 8, 2024

Built wire-android-internal-compat-pr-3300.apk is available for download

@saleniuk saleniuk requested review from a team, typfel, yamilmedina, alexandreferris, mchenani and ohassine and removed request for a team August 8, 2024 13:41
…into fix/keep-service-always-running-during-call
Copy link

sonarcloud bot commented Aug 8, 2024

@yamilmedina
Copy link
Contributor

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Project coverage is 44.55%. Comparing base (3b93ee2) to head (30defbe).
Report is 1 commits behind head on release/candidate.

Files Patch % Lines
...re/android/notification/WireNotificationManager.kt 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Thanks for this 88.88 % 👏

Copy link
Contributor

github-actions bot commented Aug 8, 2024

Built wire-android-staging-compat-pr-3300.apk is available for download

Copy link
Contributor

github-actions bot commented Aug 8, 2024

Built wire-android-internal-compat-pr-3300.apk is available for download

@saleniuk saleniuk added this pull request to the merge queue Aug 8, 2024
Merged via the queue into release/candidate with commit 8df3b3d Aug 8, 2024
11 of 12 checks passed
@saleniuk saleniuk deleted the fix/keep-service-always-running-during-call branch August 8, 2024 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
echoes: bugs Technical or functional defects in the product size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants