Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b6729ac
Start implementation of setting points + offset
camsim99 Feb 2, 2024
14d1024
Finish adding intial impls
camsim99 Feb 5, 2024
975806b
Fix crashes
camsim99 Feb 5, 2024
a7181b2
Cleanup pt1
camsim99 Feb 6, 2024
ea5f15f
Cleanup pt2
camsim99 Feb 6, 2024
5fe2976
Self review
camsim99 Feb 6, 2024
e41a825
Add tests
camsim99 Feb 7, 2024
9736287
Merge remote-tracking branch 'upstream/main' into camx_fe
camsim99 Feb 7, 2024
38e88a8
Format
camsim99 Feb 7, 2024
2843626
Update readme + bump version
camsim99 Feb 7, 2024
35ebf13
Improve docs
camsim99 Feb 7, 2024
c2f75ec
Change metering point factory
camsim99 Feb 8, 2024
b8526e1
Self review
camsim99 Feb 8, 2024
928b4cd
Nits + lints
camsim99 Feb 8, 2024
3527d9e
Merge remote-tracking branch 'upstream/main' into camx_fe
camsim99 Feb 9, 2024
1d4d37e
Update video cap test
camsim99 Feb 9, 2024
35ab369
Fix nit
camsim99 Feb 12, 2024
0de865a
Update packages/camera/camera_android_camerax/lib/src/android_camera_…
camsim99 Feb 14, 2024
bb13a35
Address review
camsim99 Feb 14, 2024
1a601a4
Merge remote-tracking branch 'refs/remotes/origin/camx_fe' into camx_fe
camsim99 Feb 14, 2024
2c3c9ab
Update packages/camera/camera_android_camerax/test/android_camera_cam…
camsim99 Feb 20, 2024
6652171
Use absolute paths
camsim99 Feb 20, 2024
a08eed6
Merge remote-tracking branch 'refs/remotes/origin/camx_fe' into camx_fe
camsim99 Feb 20, 2024
c35fa15
Address nit + change getExposureOffsetStepSize to return 0
camsim99 Feb 21, 2024
fac3ff6
Merge remote-tracking branch 'upstream/main' into camx_fe
camsim99 Feb 21, 2024
077ee37
Change to -1
camsim99 Feb 21, 2024
ff3fc39
Update wording
camsim99 Feb 21, 2024
fc60e77
Undo platform interface changes
camsim99 Feb 21, 2024
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
Prev Previous commit
Next Next commit
Address nit + change getExposureOffsetStepSize to return 0
  • Loading branch information
camsim99 committed Feb 21, 2024
commit c35fa157d326738e16ce0b5cf34ac63ba93c9073
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class AndroidCameraCameraX extends CameraPlatform {
CameraInfo? cameraInfo;

/// The [CameraControl] instance that corresponds to the [camera] instance.
CameraControl? cameraControl;
late CameraControl cameraControl;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to save this whenever the related camera is updated versus making async calls to retrieve it every time that it's needed.

/// The [LiveData] of the [CameraState] that represents the state of the
/// [camera] instance.
Expand Down Expand Up @@ -481,18 +481,14 @@ class AndroidCameraCameraX extends CameraPlatform {

/// Gets the supported step size for exposure offset for the selected camera in EV units.
///
/// Returns 0 if exposure compensation is not supported for the device.
///
/// [cameraId] not used.
@override
Future<double> getExposureOffsetStepSize(int cameraId) async {
final ExposureState exposureState = await cameraInfo!.getExposureState();
final double exposureOffsetStepSize =
exposureState.exposureCompensationStep;
if (exposureOffsetStepSize == 0) {
// CameraX returns a step size of 0 if exposure compensation is not
// supported for the device.
throw CameraException(exposureCompensationNotSupported,
'Exposure compensation not supported for the device.');
}
return exposureOffsetStepSize;
}

Expand Down Expand Up @@ -524,7 +520,7 @@ class AndroidCameraCameraX extends CameraPlatform {
(offset / exposureOffsetStepSize).round();

try {
await cameraControl!
await cameraControl
.setExposureCompensationIndex(roundedExposureCompensationIndex);
} on PlatformException catch (e) {
throw CameraException(
Expand Down Expand Up @@ -588,7 +584,7 @@ class AndroidCameraCameraX extends CameraPlatform {
/// Throws a `CameraException` when an illegal zoom level is supplied.
@override
Future<void> setZoomLevel(int cameraId, double zoom) async {
await cameraControl!.setZoomRatio(zoom);
await cameraControl.setZoomRatio(zoom);
}

/// The ui orientation changed.
Expand Down Expand Up @@ -674,7 +670,7 @@ class AndroidCameraCameraX extends CameraPlatform {
Future<void> setFlashMode(int cameraId, FlashMode mode) async {
// Turn off torch mode if it is enabled and not being redundantly set.
if (mode != FlashMode.torch && torchEnabled) {
await cameraControl!.enableTorch(false);
await cameraControl.enableTorch(false);
torchEnabled = false;
}

Expand All @@ -691,7 +687,7 @@ class AndroidCameraCameraX extends CameraPlatform {
// Torch mode enabled already.
return;
}
await cameraControl!.enableTorch(true);
await cameraControl.enableTorch(true);
torchEnabled = true;
}
}
Expand Down Expand Up @@ -1112,7 +1108,7 @@ class AndroidCameraCameraX extends CameraPlatform {
if (newMeteringPointInfos.isEmpty) {
// If no other metering points were specified, cancel any previously
// started focus and metering actions.
await cameraControl!.cancelFocusAndMetering();
await cameraControl.cancelFocusAndMetering();
currentFocusMeteringAction = null;
return;
}
Expand Down Expand Up @@ -1145,6 +1141,6 @@ class AndroidCameraCameraX extends CameraPlatform {
proxy.createFocusMeteringAction(newMeteringPointInfos);
}

await cameraControl!.startFocusAndMetering(currentFocusMeteringAction!);
await cameraControl.startFocusAndMetering(currentFocusMeteringAction!);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1630,26 +1630,6 @@ void main() {
expect(await camera.getExposureOffsetStepSize(55), 0.2);
});

test(
'getExposureOffsetStepSize throws exception when exposure compensation not supported on device',
() async {
final AndroidCameraCameraX camera = AndroidCameraCameraX();
final MockCameraInfo mockCameraInfo = MockCameraInfo();
final ExposureState exposureState = ExposureState.detached(
exposureCompensationRange:
ExposureCompensationRange(minCompensation: 0, maxCompensation: 0),
exposureCompensationStep: 0);

// Set directly for test versus calling createCamera.
camera.cameraInfo = mockCameraInfo;

when(mockCameraInfo.getExposureState())
.thenAnswer((_) async => exposureState);

expect(() => camera.getExposureOffsetStepSize(25),
throwsA(isA<CameraException>()));
});

test('getMaxZoomLevel returns expected exposure offset', () async {
final AndroidCameraCameraX camera = AndroidCameraCameraX();
final MockCameraInfo mockCameraInfo = MockCameraInfo();
Expand Down