Skip to content

Conversation

@ivan-vanyusho
Copy link

@ivan-vanyusho ivan-vanyusho commented Nov 23, 2025

Fixed a SecurityException that 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_AUDIO permission is now only requested when audio recording is explicitly enabled.

fixed issues:
-flutter/flutter#175020

Pre-Review Checklist

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-assist bot 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

  1. 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

@flutter-dashboard
Copy link

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.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines 40 to 52
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);
}

Choose a reason for hiding this comment

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

medium

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;
}

@stuartmorgan-g
Copy link
Collaborator

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.

@stuartmorgan-g stuartmorgan-g marked this pull request as draft November 24, 2025 14:08
@camsim99
Copy link
Contributor

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!

@camsim99 camsim99 closed this Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants