handle currently uncaught exception in startAutoFocus

pull/59/merge^2
Tim H 7 years ago
parent c253c4dc2b
commit 910f4da42c
  1. 11
      cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java

@ -768,6 +768,8 @@ class Camera1 extends CameraController {
boolean startAutoFocus(@Nullable final Gesture gesture, PointF point) {
if (!isCameraAvailable()) return false;
if (!mOptions.isAutoFocusSupported()) return false;
try {
final PointF p = new PointF(point.x, point.y); // copy.
List<Camera.Area> meteringAreas2 = computeMeteringAreas(p.x, p.y);
List<Camera.Area> meteringAreas1 = meteringAreas2.subList(0, 1);
@ -794,6 +796,15 @@ class Camera1 extends CameraController {
}
return true;
}
catch (Exception e) {
// at least setParameters may fail.
// TODO why does it fail and is it possible to prevent such errors?
CameraException cameraException = new CameraConfigurationFailedException("Failed to " +
"start auto focus.", e);
mCameraCallbacks.onError(cameraException);
return false;
}
}
private List<Camera.Area> computeMeteringAreas(double viewClickX, double viewClickY) {

Loading…
Cancel
Save