Repository navigation
Start the call service without the microphone type when it isn't allowed - #2250
Draft
mpretty-cyro wants to merge 2 commits into
Draft
mpretty-cyro wants to merge 2 commits into
mpretty-cyro wants to merge 2 commits into
Conversation
CallForegroundService always started with the phone-call and microphone types. Android 14+ throws SecurityException for the microphone type when RECORD_AUDIO isn't granted or the service starts from the background, and only IllegalStateException was caught, so the app crashed. Include the microphone type only with the permission, and fall back to the phone-call type alone if the system still refuses it.
Falling back to phone-call only on a restart, such as when a call connects in the background, would drop the microphone type for the rest of the call. A running service now keeps its types and only its notification is updated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Contributor checklist
Fixes #1234syntaxDescription
Crash cluster:
SecurityExceptionfromService.startForegroundinCallForegroundService.startForeground(
onStartCommand). The service always asked forphoneCall|microphone; Android 14+ refuses the microphone type withoutRECORD_AUDIO, or when started from the background, and onlyIllegalStateExceptionwas caught.The microphone type is now included only when
RECORD_AUDIOis granted, and aSecurityExceptionfalls back to the phone-calltype alone. The exception message in the reports is empty, so which of the two conditions applies isn't known; this covers both.
A refusal is handled differently depending on whether the service is already running:
TYPE_ESTABLISHED, when the call connects while the app is in the background, keeps the types the service already has, and only its notification is updated. Falling back to phone-call only here would have dropped the microphone type for the rest of the call.That a refused restart leaves the existing types in place comes from reading the platform's behaviour; it isn't tested.
Testing: compiled. Not exercised on a device; it needs an incoming call.