Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch setDisplayOrientation() RuntimeException #126

Conversation

jpribble
Copy link
Contributor

@jpribble jpribble commented Oct 27, 2017

Catch setDisplayOrientation() RuntimeException in UpdateOrientationRoutine.

This fixes issue #105.

@jpribble jpribble force-pushed the catch_setDisplayOrientation_exception branch from 608bb75 to e016142 Compare October 27, 2017 15:54
Catch setDisplayOrientation() RuntimeException in UpdateOrientationRoutine and pass it to the CameraErrorCallback.
@jpribble jpribble force-pushed the catch_setDisplayOrientation_exception branch from e016142 to 65c67ca Compare October 27, 2017 17:18
try {
cameraDevice.setDisplayOrientation(degrees);
} catch (RuntimeException e) {
cameraErrorCallback.onError(new CameraException(e));
Copy link
Member

Choose a reason for hiding this comment

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

There is a problem with that - at the moment onError basically means "everything is super bad, camera is dead". However, it is very likely not the case here, since orientation events are constantly coming in.

I would instead do it like it is done in Camera1#autoFocus where we just log the failure in logFailedAutoFocus.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. I'll make that change.

verify(cameraDevice).setDisplayOrientation(90);
ArgumentCaptor<CameraException> argumentCaptor = ArgumentCaptor.forClass(CameraException.class);
verify(cameraErrorCallback).onError(argumentCaptor.capture());
Copy link
Member

Choose a reason for hiding this comment

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

Small thing - ArgumentCaptor is not really needed here. You can just do:

verify(cameraErrorCallback).onError(exception);

@jpribble jpribble force-pushed the catch_setDisplayOrientation_exception branch from 0aff624 to ba69cce Compare October 30, 2017 01:26
@dmitry-zaitsev dmitry-zaitsev merged commit 0708c79 into RedApparat:master Oct 30, 2017
@dmitry-zaitsev
Copy link
Member

Thanks for fixing the issue! This will into the next release.

@jpribble jpribble deleted the catch_setDisplayOrientation_exception branch October 30, 2017 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants