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

Call: ensure that the microphone is working when the application is backgrounded. #3685

Merged
merged 5 commits into from
Oct 16, 2024

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Oct 15, 2024

Content

Request audio focus only when the call is actually started and start the foreground service as soon as the call is started.
Second commit change the service permission. We do not really need the permission MANAGE_OWN_CALLS but are rather interested by FOREGROUND_SERVICE_MICROPHONE.

Motivation and context

Close #3679

Screenshots / GIFs

Tests

  • Start a call
  • put the app in BG
  • Switch the screen of.

the call should stay active, with a working microphone

Tested devices

  • Physical running Android 14.
  • Emulator
  • OS version(s):

Checklist

  • Changes have been tested on an Android device or Android emulator with API 23
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • Pull request includes a sign off
  • You've made a self review of your PR

@bmarty bmarty requested a review from a team as a code owner October 15, 2024 14:43
@bmarty bmarty requested review from jmartinesp and removed request for a team October 15, 2024 14:43
@bmarty bmarty changed the title Feature/bma/call improvment Call: ensure that the microphone is working when the application is backgrounded. Oct 15, 2024
@bmarty bmarty added the PR-Bugfix For bug fix label Oct 15, 2024
Copy link
Contributor

github-actions bot commented Oct 15, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/hRxHWS

Copy link

codecov bot commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 22.22222% with 14 lines in your changes missing coverage. Please review.

Project coverage is 82.81%. Comparing base (a4966ef) to head (5d09d9c).
Report is 21 commits behind head on develop.

Files with missing lines Patch % Lines
...droid/features/call/impl/ui/ElementCallActivity.kt 0.00% 8 Missing ⚠️
...atures/call/impl/services/CallForegroundService.kt 0.00% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3685      +/-   ##
===========================================
- Coverage    82.81%   82.81%   -0.01%     
===========================================
  Files         1748     1748              
  Lines        41777    41782       +5     
  Branches      5108     5109       +1     
===========================================
+ Hits         34597    34601       +4     
- Misses        5365     5366       +1     
  Partials      1815     1815              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

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

There are a few things I'd like to double check.

@@ -33,8 +35,12 @@ import timber.log.Timber
class CallForegroundService : Service() {
companion object {
fun start(context: Context) {
val intent = Intent(context, CallForegroundService::class.java)
ContextCompat.startForegroundService(context, intent)
if (ContextCompat.checkSelfPermission(context, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED) {
Copy link
Member

Choose a reason for hiding this comment

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

Really weird corner case, but what happens if the user didn't enable the microphone permission and joined the room anyway? Will the audio from the other side still be heard, even when the device is locked? I assume it would work for the app just being in background since the PiP window is alive.

Copy link

sonarcloud bot commented Oct 16, 2024

Copy link
Member

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, the feature now seems a lot more stable and useful!

@jmartinesp
Copy link
Member

cc @toger5 since he was especially interested in this. He might also be a good early tester 😛 .

@bmarty bmarty merged commit 2c253be into develop Oct 16, 2024
24 of 26 checks passed
@bmarty bmarty deleted the feature/bma/callImprovment branch October 16, 2024 09:44
@davidegirardi
Copy link

I tested the latest nightly. It failed on the very first call but then worked with no issues, even if I revoked the picture in picture permissions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Bugfix For bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bluetooth mic muted during call if the app is not in foreground and the screen is on
3 participants