Skip to content
Merged
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 @@ -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
Expand All @@ -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(
Expand Down
Loading