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
4 changes: 4 additions & 0 deletions packages/camera/camera_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.10.8

* Provides a default exposure point if null.

## 0.10.7

* Adds support for NV21 as a new streaming format in Android which includes correct handling of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class ExposurePointFeature extends CameraFeature<Point> {

private Size cameraBoundaries;
@Nullable private Point exposurePoint;
private Point exposurePoint;
private MeteringRectangle[] defaultExposureRectangle;
private MeteringRectangle exposureRectangle;
@NonNull private final SensorOrientationFeature sensorOrientationFeature;

Expand Down Expand Up @@ -78,9 +80,15 @@ public void updateBuilder(@NonNull CaptureRequest.Builder requestBuilder) {
if (!checkIsSupported()) {
return;
}
requestBuilder.set(
CaptureRequest.CONTROL_AE_REGIONS,
exposureRectangle == null ? null : new MeteringRectangle[] {exposureRectangle});
if (defaultExposureRectangle == null) {
defaultExposureRectangle = requestBuilder.get(CaptureRequest.CONTROL_AE_REGIONS);
}
if (exposureRectangle != null) {
requestBuilder.set(
CaptureRequest.CONTROL_AE_REGIONS, new MeteringRectangle[] {exposureRectangle});
} else if (shouldReset(requestBuilder)) {
Comment thread
Mairramer marked this conversation as resolved.
requestBuilder.set(CaptureRequest.CONTROL_AE_REGIONS, defaultExposureRectangle);
}
}

private void buildExposureRectangle() {
Expand All @@ -102,4 +110,9 @@ private void buildExposureRectangle() {
this.cameraBoundaries, this.exposurePoint.x, this.exposurePoint.y, orientation);
}
}

public boolean shouldReset(CaptureRequest.Builder requestBuilder) {
MeteringRectangle[] currentRectangles = requestBuilder.get(CaptureRequest.CONTROL_AE_REGIONS);
return currentRectangles == null || currentRectangles.length == 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class ExposurePointFeatureTest {
Size mockCameraBoundaries;
SensorOrientationFeature mockSensorOrientationFeature;
DeviceOrientationManager mockDeviceOrientationManager;
MeteringRectangle[] mockDefaultExposureRectangle;
MeteringRectangle mockExposureRectangle;

@Before
public void setUp() {
Expand Down Expand Up @@ -308,6 +310,24 @@ public void updateBuilder_shouldNotSetMeteringRectangleWhenNoValidCoordsAreSuppl
exposurePointFeature.updateBuilder(mockCaptureRequestBuilder);
exposurePointFeature.setValue(new Point(null, 0d));
exposurePointFeature.updateBuilder(mockCaptureRequestBuilder);

verify(mockCaptureRequestBuilder, times(3)).set(any(), isNull());
}

@Test
public void testShouldResetReturnsFalse() {
CaptureRequest.Builder mockCaptureRequestBuilder = mock(CaptureRequest.Builder.class);
MeteringRectangle[] defaultRectangles = new MeteringRectangle[1];
defaultRectangles[0] = mock(MeteringRectangle.class);
when(mockCaptureRequestBuilder.get(CaptureRequest.CONTROL_AE_REGIONS))
.thenReturn(defaultRectangles);
mockCaptureRequestBuilder.set(CaptureRequest.CONTROL_AE_REGIONS, defaultRectangles);

ExposurePointFeature exposurePointFeature = mock(ExposurePointFeature.class);
exposurePointFeature.setCameraBoundaries(this.mockCameraBoundaries);
exposurePointFeature.setValue(new Point(0.5, 0.5));
exposurePointFeature.updateBuilder(mockCaptureRequestBuilder);

assertFalse(exposurePointFeature.shouldReset(mockCaptureRequestBuilder));
}
}
3 changes: 2 additions & 1 deletion packages/camera/camera_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: camera_android
description: Android implementation of the camera plugin.
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.10.7

version: 0.10.8

environment:
sdk: ">=2.17.0 <4.0.0"
Expand Down