-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix SecurityException when trying to record video with audio disabled #10498
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
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request addresses a SecurityException that occurs when video recording is initiated with audio disabled. The fix involves correcting the logic in PendingRecordingProxyApi.java to properly check for audio recording permissions before enabling the audio pipeline. Specifically, the withAudioEnabled method is updated to only attempt to enable audio if it's requested and the RECORD_AUDIO permission has been granted. I've added a suggestion to simplify the logic slightly for better readability. The version in pubspec.yaml has also been correctly updated.
| public PendingRecording withAudioEnabled(PendingRecording pigeonInstance, boolean initialMuted) { | ||
| if (!initialMuted | ||
| && ContextCompat.checkSelfPermission( | ||
| getPigeonRegistrar().getContext(), Manifest.permission.RECORD_AUDIO) | ||
| if (initialMuted) { | ||
| return pigeonInstance; | ||
| } | ||
|
|
||
| if (ContextCompat.checkSelfPermission( | ||
| getPigeonRegistrar().getContext(), Manifest.permission.RECORD_AUDIO) | ||
| == PackageManager.PERMISSION_GRANTED) { | ||
| return pigeonInstance.withAudioEnabled(false); | ||
| return pigeonInstance.withAudioEnabled(true); | ||
| } | ||
|
|
||
| return pigeonInstance.withAudioEnabled(true); | ||
| return pigeonInstance.withAudioEnabled(false); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updated logic correctly handles the audio enabling based on permissions. However, it can be simplified. Instead of returning the instance directly when initialMuted is true, you can consolidate the logic to always call withAudioEnabled with the appropriate boolean value. This makes the flow of control a bit clearer.
public PendingRecording withAudioEnabled(PendingRecording pigeonInstance, boolean initialMuted) {
boolean enableAudio = !initialMuted && ContextCompat.checkSelfPermission(
getPigeonRegistrar().getContext(), Manifest.permission.RECORD_AUDIO)
== PackageManager.PERMISSION_GRANTED;
if (enableAudio) {
return pigeonInstance.withAudioEnabled();
}
return pigeonInstance;
}|
Thanks for the contribution! You’ve checked boxes in the PR checklist above that are not reflected in this PR, so I’m assuming this is a work in progress and am marking it as a Draft. Please review the checklist, updating the PR as appropriate, and when the state of the PR as posted reflects the checklist please feel free to mark it as ready for review. |
|
Hi @ivan-vanyusho! Thank you so much for taking on this issue! I know that this was marked as a draft, but I'm going to go ahead and close this PR because this is already being addressed by #10424 which is under review. Feel free to review that PR and help us get it landed to fix the issue. Thanks! |
Fixed a
SecurityExceptionthat occurred when starting video recording without audio.On Android, when initiating a video recording session with audio disabled, the package could throw a
SecurityException:This happened because the recording setup incorrectly attempted to enable the audio pipeline even when audio was explicitly disabled.
Modified the Android implementation to properly check the audio recording flag before configuring the audio pipeline. The
RECORD_AUDIOpermission is now only requested when audio recording is explicitly enabled.fixed issues:
-flutter/flutter#175020
Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3