diff --git a/packages/camera/camera_android_camerax/CHANGELOG.md b/packages/camera/camera_android_camerax/CHANGELOG.md index b46ca3bbee7..07175134c88 100644 --- a/packages/camera/camera_android_camerax/CHANGELOG.md +++ b/packages/camera/camera_android_camerax/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.6.11 + +* Replaces deprecated Android embedder APIs (`onSurfaceCreated` -> `onSurfaceAvailable`). +* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. + ## 0.6.10+3 * Bumps com.google.guava:guava from 33.3.1-android to 33.4.0-android. diff --git a/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/PreviewHostApiImpl.java b/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/PreviewHostApiImpl.java index e9b7b0d89ac..b3757c3a9ca 100644 --- a/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/PreviewHostApiImpl.java +++ b/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/PreviewHostApiImpl.java @@ -83,10 +83,7 @@ public void onSurfaceRequested(@NonNull SurfaceRequest request) { surfaceProducer.setCallback( new TextureRegistry.SurfaceProducer.Callback() { @Override - // TODO(matanlurey): Replace with onSurfaceAvailable once available on stable; - // https://github.com/flutter/flutter/issues/155131. - @SuppressWarnings({"deprecation", "removal"}) - public void onSurfaceCreated() { + public void onSurfaceAvailable() { // Do nothing. The Preview.SurfaceProvider will handle this whenever a new // Surface is needed. } diff --git a/packages/camera/camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/PreviewTest.java b/packages/camera/camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/PreviewTest.java index 83ccb1edd9c..69f9a910c75 100644 --- a/packages/camera/camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/PreviewTest.java +++ b/packages/camera/camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/PreviewTest.java @@ -133,8 +133,8 @@ public void createSurfaceProducer_setsExpectedSurfaceProducerCallback() { reset(mockSurfaceRequest); - // Verify callback's onSurfaceCreated does not interact with the SurfaceRequest. - simulateSurfaceCreation(callback); + // Verify callback's onSurfaceAvailable does not interact with the SurfaceRequest. + callback.onSurfaceAvailable(); verifyNoMoreInteractions(mockSurfaceRequest); } @@ -262,12 +262,4 @@ public void setTargetRotation_makesCallToSetTargetRotation() { verify(mockPreview).setTargetRotation(targetRotation); } - - // TODO(matanlurey): Replace with inline calls to onSurfaceAvailable once - // available on stable; see https://github.com/flutter/flutter/issues/155131. - // This seperate method only exists to scope the suppression. - @SuppressWarnings({"deprecation", "removal"}) - void simulateSurfaceCreation(TextureRegistry.SurfaceProducer.Callback producerLifecycle) { - producerLifecycle.onSurfaceCreated(); - } } diff --git a/packages/camera/camera_android_camerax/pubspec.yaml b/packages/camera/camera_android_camerax/pubspec.yaml index d3358f305c5..0cdcd81c840 100644 --- a/packages/camera/camera_android_camerax/pubspec.yaml +++ b/packages/camera/camera_android_camerax/pubspec.yaml @@ -2,11 +2,11 @@ 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.10+3 +version: 0.6.11 environment: - sdk: ^3.5.0 - flutter: ">=3.24.0" + sdk: ^3.6.0 + flutter: ">=3.27.0" flutter: plugin: diff --git a/packages/video_player/video_player_android/CHANGELOG.md b/packages/video_player/video_player_android/CHANGELOG.md index ef0db8cc591..a78d4fe4263 100644 --- a/packages/video_player/video_player_android/CHANGELOG.md +++ b/packages/video_player/video_player_android/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.7.17 + +* Replaces deprecated Android embedder APIs (`onSurfaceCreated` -> `onSurfaceAvailable`). +* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. + ## 2.7.16 * Updates internal Pigeon API to use newer features. diff --git a/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java b/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java index c481df2d779..64f88871171 100644 --- a/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java +++ b/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java @@ -85,9 +85,7 @@ interface ExoPlayerProvider { } @RestrictTo(RestrictTo.Scope.LIBRARY) - // TODO(matanlurey): https://github.com/flutter/flutter/issues/155131. - @SuppressWarnings({"deprecation", "removal"}) - public void onSurfaceCreated() { + public void onSurfaceAvailable() { if (savedStateDuring != null) { exoPlayer = createVideoPlayer(); savedStateDuring.restore(exoPlayer); diff --git a/packages/video_player/video_player_android/android/src/test/java/io/flutter/plugins/videoplayer/VideoPlayerTest.java b/packages/video_player/video_player_android/android/src/test/java/io/flutter/plugins/videoplayer/VideoPlayerTest.java index 4912803ce1d..509d7946c2d 100644 --- a/packages/video_player/video_player_android/android/src/test/java/io/flutter/plugins/videoplayer/VideoPlayerTest.java +++ b/packages/video_player/video_player_android/android/src/test/java/io/flutter/plugins/videoplayer/VideoPlayerTest.java @@ -172,7 +172,7 @@ public void seekAndGetPosition() { } @Test - public void onSurfaceProducerDestroyedAndRecreatedReleasesAndThenRecreatesAndResumesPlayer() { + public void onSurfaceProducerDestroyedAndAvailableReleasesAndThenRecreatesAndResumesPlayer() { VideoPlayer videoPlayer = createVideoPlayer(); verify(mockProducer).setCallback(callbackCaptor.capture()); @@ -190,7 +190,7 @@ public void onSurfaceProducerDestroyedAndRecreatedReleasesAndThenRecreatesAndRes // Create a new mock exo player so that we get a new instance. mockExoPlayer = mock(ExoPlayer.class); - simulateSurfaceCreation(producerLifecycle); + producerLifecycle.onSurfaceAvailable(); verify(mockExoPlayer).seekTo(10L); verify(mockExoPlayer).setRepeatMode(Player.REPEAT_MODE_ALL); @@ -226,7 +226,7 @@ public void onDisposeSurfaceProducerCallbackIsDisconnected() { } @Test - public void onInitializedCalledWhenVideoPlayerInitiallyCreated() { + public void onInitializedCalledWhenVideoPlayerInitiallyAvailable() { VideoPlayer videoPlayer = createVideoPlayer(); // Pretend we have a video, and capture the registered event listener. @@ -242,7 +242,7 @@ public void onInitializedCalledWhenVideoPlayerInitiallyCreated() { } @Test - public void onSurfaceCreatedDoesNotSendInitializeEventAgain() { + public void onSurfaceAvailableDoesNotSendInitializeEventAgain() { // The VideoPlayer contract assumes that the event "initialized" is sent exactly once // (duplicate events cause an error to be thrown at the shared Dart layer). This test verifies // that the onInitialized event is sent exactly once per player. @@ -251,13 +251,13 @@ public void onSurfaceCreatedDoesNotSendInitializeEventAgain() { VideoPlayer videoPlayer = createVideoPlayer(); when(mockExoPlayer.getVideoSize()).thenReturn(new VideoSize(300, 200)); - // Capture the lifecycle events so we can simulate onSurfaceCreated/Destroyed. + // Capture the lifecycle events so we can simulate onSurfaceAvailableDestroyed. verify(mockProducer).setCallback(callbackCaptor.capture()); TextureRegistry.SurfaceProducer.Callback producerLifecycle = callbackCaptor.getValue(); - // Trigger destroyed/created. + // Trigger destroyed/available. producerLifecycle.onSurfaceDestroyed(); - simulateSurfaceCreation(producerLifecycle); + producerLifecycle.onSurfaceAvailable(); // Initial listener, and the new one from the resume. verify(mockExoPlayer, times(2)).addListener(listenerCaptor.capture()); @@ -273,17 +273,17 @@ public void onSurfaceCreatedDoesNotSendInitializeEventAgain() { } @Test - public void onSurfaceCreatedWithoutDestroyDoesNotRecreate() { + public void onSurfaceAvailableWithoutDestroyDoesNotRecreate() { // Initially create the video player, which creates the initial surface. VideoPlayer videoPlayer = createVideoPlayer(); verify(mockProducer).getSurface(); - // Capture the lifecycle events so we can simulate onSurfaceCreated/Destroyed. + // Capture the lifecycle events so we can simulate onSurfaceAvailable/Destroyed. verify(mockProducer).setCallback(callbackCaptor.capture()); TextureRegistry.SurfaceProducer.Callback producerLifecycle = callbackCaptor.getValue(); - // Calling onSurfaceCreated does not do anything, since the surface was never destroyed. - simulateSurfaceCreation(producerLifecycle); + // Calling onSurfaceAvailable does not do anything, since the surface was never destroyed. + producerLifecycle.onSurfaceAvailable(); verifyNoMoreInteractions(mockProducer); videoPlayer.dispose(); @@ -301,12 +301,4 @@ public void disposeReleasesExoPlayerBeforeTexture() { inOrder.verify(mockExoPlayer).release(); inOrder.verify(mockProducer).release(); } - - // TODO(matanlurey): Replace with inline calls to onSurfaceAvailable once - // available on stable; see https://github.com/flutter/flutter/issues/155131. - // This separate method only exists to scope the suppression. - @SuppressWarnings({"deprecation", "removal"}) - void simulateSurfaceCreation(TextureRegistry.SurfaceProducer.Callback producerLifecycle) { - producerLifecycle.onSurfaceCreated(); - } } diff --git a/packages/video_player/video_player_android/pubspec.yaml b/packages/video_player/video_player_android/pubspec.yaml index ababc4aca4e..c32c49579d1 100644 --- a/packages/video_player/video_player_android/pubspec.yaml +++ b/packages/video_player/video_player_android/pubspec.yaml @@ -2,11 +2,11 @@ name: video_player_android description: Android implementation of the video_player plugin. repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22 -version: 2.7.16 +version: 2.7.17 environment: - sdk: ^3.5.0 - flutter: ">=3.24.0" + sdk: ^3.6.0 + flutter: ">=3.27.0" flutter: plugin: