Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 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.6

* Provides a default exposure point if null

## 0.10.5

* Allows camera to be switched while video recording.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class ExposurePointFeature extends CameraFeature<Point> {

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

Expand Down Expand Up @@ -72,9 +73,15 @@ public void updateBuilder(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)) {
requestBuilder.set(CaptureRequest.CONTROL_AE_REGIONS, defaultExposureRectangle);
}
}

private void buildExposureRectangle() {
Expand All @@ -96,4 +103,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));
}
}
2 changes: 1 addition & 1 deletion packages/camera/camera_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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.5
version: 0.10.6

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