Keep foregroundService active if there is other connections #826
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
Imagine that you received a call while your app is in the background, accepted it and now have an active conversation.
Then you receive a second incoming call. In that case you may decline second call at once, or you may put on hold the first call and accept the second one, then after a while you finish your conversation and press hang up button, or remote party presses it and you should invoke endCall method to hide second call screen. Anyway, after finishing or declining you going to get back to first call, remove from hold (if needed) and resume conversation. But in all that cases mentioned above you will find that remote party can't hear you anymore.
It happens because any kind of finish of second call fires endCall event which leads unconditionally to currentConnectionService.stopForegroundService() method, therefore your app loses access to microphone in background.
My solution is making a check wether other connections still exist and invoke stopForegroundService only if not.