From ca01168be7b3388d240b7bd0d483888fbe557bc2 Mon Sep 17 00:00:00 2001 From: Camille Simon <43054281+camsim99@users.noreply.github.com> Date: Mon, 6 May 2024 15:47:11 -0400 Subject: [PATCH] [camerax] Add empty implementation for `prepareForVideoRecording` not used on Android (#6676) Adds empty implementation for the camera plugin method `prepareForVideoRecording` that is not used on Android. Prequel to https://github.com/flutter/packages/pull/6629 --- .../camera/camera_android_camerax/CHANGELOG.md | 4 ++++ .../lib/src/android_camera_camerax.dart | 9 +++++++++ .../camera/camera_android_camerax/pubspec.yaml | 2 +- .../test/android_camera_camerax_test.dart | 18 ++++++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/camera/camera_android_camerax/CHANGELOG.md b/packages/camera/camera_android_camerax/CHANGELOG.md index 863f99b8aa80..17c007087abf 100644 --- a/packages/camera/camera_android_camerax/CHANGELOG.md +++ b/packages/camera/camera_android_camerax/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.4+1 + +* Adds empty implementation for `prepareForVideoRecording` since this optimization is not used on Android. + ## 0.6.4 * Prevents usage of unsupported concurrent `UseCase`s based on the capabiliites of the camera device. diff --git a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart index b73ce0186bec..5ced7ccccb38 100644 --- a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart +++ b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart @@ -867,6 +867,15 @@ class AndroidCameraCameraX extends CameraPlatform { } } + /// Prepare the capture session for video recording. + /// + /// This optimization is not used on Android, so this implementation is a + /// no-op. + @override + Future prepareForVideoRecording() { + return Future.value(); + } + /// Configures and starts a video recording. Returns silently without doing /// anything if there is currently an active recording. /// diff --git a/packages/camera/camera_android_camerax/pubspec.yaml b/packages/camera/camera_android_camerax/pubspec.yaml index 8f1b5d11bbc6..cabd26b66a2d 100644 --- a/packages/camera/camera_android_camerax/pubspec.yaml +++ b/packages/camera/camera_android_camerax/pubspec.yaml @@ -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.4 +version: 0.6.4+1 environment: sdk: ^3.1.0 diff --git a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart index f0caef74a24c..23af67c5ca18 100644 --- a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart +++ b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart @@ -4040,4 +4040,22 @@ void main() { verify( camera.processCameraProvider!.unbind([camera.imageAnalysis!])); }); + + test( + 'prepareForVideoRecording does not make any calls involving starting video recording', + () async { + final AndroidCameraCameraX camera = AndroidCameraCameraX(); + + // Set directly for test versus calling createCamera. + camera.processCameraProvider = MockProcessCameraProvider(); + camera.recorder = MockRecorder(); + camera.videoCapture = MockVideoCapture(); + camera.camera = MockCamera(); + + await camera.prepareForVideoRecording(); + verifyNoMoreInteractions(camera.processCameraProvider); + verifyNoMoreInteractions(camera.recorder); + verifyNoMoreInteractions(camera.videoCapture); + verifyNoMoreInteractions(camera.camera); + }); }