Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@ public PendingRecording asPersistentRecording(PendingRecording pigeonInstance) {
@NonNull
@Override
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);
}
Comment on lines 40 to 52

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


@NonNull
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_android_camerax/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera_android_camerax
description: Android implementation of the camera plugin using the CameraX library.
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android_camerax
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.6.24+1
version: 0.6.25

environment:
sdk: ^3.9.0
Expand Down