diff --git a/core/camera/src/main/java/com/google/jetpackcamera/core/camera/FocusMetering.kt b/core/camera/src/main/java/com/google/jetpackcamera/core/camera/FocusMetering.kt index 1d305ea23..9253b8609 100644 --- a/core/camera/src/main/java/com/google/jetpackcamera/core/camera/FocusMetering.kt +++ b/core/camera/src/main/java/com/google/jetpackcamera/core/camera/FocusMetering.kt @@ -85,11 +85,17 @@ internal suspend fun CameraSessionContext.processFocusMeteringEvents( } } - updateFocusState(FocusState.Status.RUNNING) val meteringPoint = createPoint(event.x, event.y) val action = FocusMeteringAction.Builder(meteringPoint) .setAutoCancelDuration(AUTO_FOCUS_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS) .build() + + if (!cameraInfo.isFocusMeteringSupported(action)) { + Log.w(TAG, "Focus metering not supported for action: $action") + return@apply + } + + updateFocusState(FocusState.Status.RUNNING) val completionStatus: FocusState.Status = try { if (cameraControl.startFocusAndMetering(action).await().isFocusSuccessful) { FocusState.Status.SUCCESS @@ -98,6 +104,9 @@ internal suspend fun CameraSessionContext.processFocusMeteringEvents( } } catch (_: CameraControl.OperationCanceledException) { FocusState.Status.FAILURE + } catch (e: IllegalArgumentException) { + Log.w(TAG, "tapToFocus failed", e) + FocusState.Status.FAILURE } Log.d(