Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,14 @@ public void onOpened(@NonNull CameraDevice device) {
cameraFeatures.getFocusPoint().checkIsSupported());
}
} catch (Exception e) {
String message =
(e.getMessage() == null)
? (e.getClass().getName() + " occurred while opening camera.")
: e.getMessage();
if (BuildConfig.DEBUG) {
Log.i(TAG, "open | onOpened error: " + e.getMessage());
Log.i(TAG, "open | onOpened error: " + message);
}
dartMessenger.sendCameraErrorEvent(e.getMessage());
dartMessenger.sendCameraErrorEvent(message);
close();
}
}
Expand Down Expand Up @@ -792,7 +796,11 @@ private void lockAutoFocus() {
try {
captureSession.capture(previewRequestBuilder.build(), null, backgroundHandler);
} catch (CameraAccessException e) {
dartMessenger.sendCameraErrorEvent(e.getMessage());
String message =
(e.getMessage() == null)
? "CameraAccessException occurred while locking autofocus."
: e.getMessage();
dartMessenger.sendCameraErrorEvent(message);
}
}

Expand All @@ -815,7 +823,11 @@ void unlockAutoFocus() {

captureSession.capture(previewRequestBuilder.build(), null, backgroundHandler);
} catch (CameraAccessException e) {
dartMessenger.sendCameraErrorEvent(e.getMessage());
String message =
(e.getMessage() == null)
? "CameraAccessException occurred while unlocking autofocus."
: e.getMessage();
dartMessenger.sendCameraErrorEvent(message);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,14 @@ void sendCameraClosingEvent() {
handler.post(() -> eventApi.closed(new NoOpVoidResult()));
}

// TODO(schectman): Make `description` non-null, see
// https://github.com/flutter/flutter/issues/156729
/**
* Sends a message to the Flutter client informing that an error occurred while interacting with
* the camera.
*
* @param description contains details regarding the error that occurred.
*/
void sendCameraErrorEvent(@Nullable String description) {
String errorMessage = (description == null) ? "" : description;
handler.post(() -> eventApi.error(errorMessage, new NoOpVoidResult()));
void sendCameraErrorEvent(@NonNull String description) {
handler.post(() -> eventApi.error(description, new NoOpVoidResult()));
}

/**
Expand Down