Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[camera] Ensure setExposureOffset returns new value on Android #4301

Merged
merged 1 commit into from
Sep 2, 2021
Merged
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/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.9.2+2

* Ensure that setting the exposure offset returns the new offset value on Android.

## 0.9.2+1

* Fixed camera controller throwing an exception when being replaced in the preview widget.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ public void setExposureOffset(@NonNull final Result result, double offset) {
exposureOffsetFeature.updateBuilder(previewRequestBuilder);

refreshPreviewCaptureSession(
() -> result.success(null),
() -> result.success(exposureOffsetFeature.getValue()),
(code, message) ->
result.error("setExposureOffsetFailed", "Could not set exposure offset.", null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,11 +687,13 @@ public void setExposureOffset_shouldUpdateExposureOffsetFeature() {
mockCameraFeatureFactory.createExposureOffsetFeature(mockCameraProperties);
MethodChannel.Result mockResult = mock(MethodChannel.Result.class);

when(mockExposureOffsetFeature.getValue()).thenReturn(1.0);

camera.setExposureOffset(mockResult, 1.0);

verify(mockExposureOffsetFeature, times(1)).setValue(1.0);
verify(mockResult, never()).error(any(), any(), any());
verify(mockResult, times(1)).success(null);
verify(mockResult, times(1)).success(1.0);
}

@Test
Expand Down
7 changes: 7 additions & 0 deletions packages/camera/camera/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,13 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
onSetExposureModeButtonPressed(ExposureMode.locked)
: null,
),
TextButton(
child: Text('RESET OFFSET'),
style: styleLocked,
onPressed: controller != null
? () => controller!.setExposureOffset(0.0)
: null,
),
],
),
Center(
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: A Flutter plugin for getting information about and controlling the
and streaming image buffers to dart.
repository: https://github.com/flutter/plugins/tree/master/packages/camera/camera
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.9.2+1
version: 0.9.2+2

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down