Skip to content

Commit ebcc4f0

Browse files
authored
[camerax] Correct assumption about preview being correctly rotated by default on API 29 (flutter#7714)
Changes assumption about camera preview being automatically corrected by CameraX on API <= 29 to API < 29 based on the fact that an `ImageReader` backs devices running API 29+, on which the camera preview will not automatically be corrected by CameraX. Related to flutter/flutter#154241.
1 parent 33fa73a commit ebcc4f0

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

packages/camera/camera_android_camerax/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.6.9
2+
3+
* Corrects assumption about automatic preview correction happening on API >= 29 to API > 29,
4+
based on the fact that the `ImageReader` Impeller backend is not used for the most part on
5+
devices running API 29+.
6+
17
## 0.6.8+3
28

39
* Removes dependency on org.jetbrains.kotlin:kotlin-bom.

packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/SystemServicesHostApiImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,16 @@ public String getTempFilePath(@NonNull String prefix, @NonNull String suffix) {
106106
}
107107

108108
/**
109-
* Returns whether or not a {@code SurfaceTexture} backs the {@code Surface} provided to CameraX
110-
* to build the camera preview. If it is backed by a {@code Surface}, then the transformation
111-
* needed to correctly rotate the preview has already been applied.
109+
* Returns whether or not Impeller uses an {@code ImageReader} backend to provide a {@code
110+
* Surface} to CameraX to build the preview. If it is backed by an {@code ImageReader}, then
111+
* CameraX will not automatically apply the transformation needed to correct the preview.
112112
*
113-
* <p>This is determined by the engine, who uses {@code SurfaceTexture}s on Android SDKs 29 and
114-
* below.
113+
* <p>This is determined by the engine, which approximately uses {@code SurfaceTexture}s on
114+
* Android SDKs below 29.
115115
*/
116116
@Override
117117
@NonNull
118118
public Boolean isPreviewPreTransformed() {
119-
return Build.VERSION.SDK_INT <= 29;
119+
return Build.VERSION.SDK_INT < 29;
120120
}
121121
}

packages/camera/camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/SystemServicesTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,16 @@ public void isPreviewPreTransformed_returnsTrueWhenRunningBelowSdk29() {
146146
}
147147

148148
@Test
149-
@Config(sdk = 29)
150-
public void isPreviewPreTransformed_returnsTrueWhenRunningSdk29() {
149+
@Config(sdk = 28)
150+
public void isPreviewPreTransformed_returnsTrueWhenRunningSdk28() {
151151
final SystemServicesHostApiImpl systemServicesHostApi =
152152
new SystemServicesHostApiImpl(mockBinaryMessenger, mockInstanceManager, mockContext);
153153
assertTrue(systemServicesHostApi.isPreviewPreTransformed());
154154
}
155155

156156
@Test
157-
@Config(sdk = 30)
158-
public void isPreviewPreTransformed_returnsFalseWhenRunningAboveSdk29() {
157+
@Config(sdk = 29)
158+
public void isPreviewPreTransformed_returnsFalseWhenRunningAboveSdk28() {
159159
final SystemServicesHostApiImpl systemServicesHostApi =
160160
new SystemServicesHostApiImpl(mockBinaryMessenger, mockInstanceManager, mockContext);
161161
assertFalse(systemServicesHostApi.isPreviewPreTransformed());

packages/camera/camera_android_camerax/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera_android_camerax
22
description: Android implementation of the camera plugin using the CameraX library.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android_camerax
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
5-
version: 0.6.8+3
5+
version: 0.6.9
66

77
environment:
88
sdk: ^3.5.0

0 commit comments

Comments
 (0)