fix: Fix minFocusDistance being NaN on some emulators

This commit is contained in:
Marc Rousavy 2024-02-02 09:54:17 +01:00
parent 8c66d36d8f
commit e95264f782
No known key found for this signature in database
GPG Key ID: 83BEF0F19E8F5321

View File

@ -102,6 +102,7 @@ class CameraDeviceDetails(val cameraManager: CameraManager, val cameraId: String
private fun getMinFocusDistanceCm(): Double {
val distance = characteristics.get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE)
if (distance == null || distance == 0f) return 0.0
if (distance.isNaN() || distance.isInfinite()) return 0.0
// distance is in "diopters", meaning 1/meter. Convert to meters, then centi-meters
return 1.0 / distance * 100.0
}