Modern Apps git

← Modern-Apps.git

camera: keep flash shots off the night long-exposure path (#721)

Commit
e6ed5569500980151e4d2564717c5aa15632c480
Author
vayun-mathur <[email protected]>
When
2026-10-14 00:03 UTC (1 month ago)
Parents
a6b9ae6

Diff

camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoCapture.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoCapture.kt b/camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoCapture.ktindex c7d0c680c2..91ebfd91b3 100644--- a/camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoCapture.kt+++ b/camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoCapture.kt@@ -49,8 +49,12 @@ internal fun CameraViewModel.capturePhoto() {         // extension, so a plain single capture through that ImageCapture lets the vendor pipeline         // produce the multi-frame night image.         nightPreviewActiveMutable.value -> captureSinglePhoto()-        // Multi-frame night capture only when night mode is active and exposure is fully auto.-        nightModeActive.value && isExposureAuto() -> captureNightPhoto()+        // Multi-frame night capture only when night mode is active, exposure is fully auto,+        // and flash is off: the night paths lock AE off (CONTROL_AE_MODE_OFF) with a forced+        // long exposure, which breaks flash metering/timing and double-exposes (issue #721).+        // With flash on, fall through to the plain single capture so the shot is an instant+        // flash photo with no long-exposure countdown overlay.+        nightModeActive.value && isExposureAuto() && flashModeMutable.value == FlashMode.OFF -> captureNightPhoto()         // Motion Photo for plain PHOTO captures (no warmth/shadows bake, not capturing for a         // caller). Only at the native 4:3 ratio: the motion still is saved as raw JPEG bytes         // (to preserve the Ultra HDR gain map + motion trailer), which can't carry CameraX's
camera/src/main/java/com/vayunmathur/camera/util/CameraSingleCapture.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/util/CameraSingleCapture.kt b/camera/src/main/java/com/vayunmathur/camera/util/CameraSingleCapture.ktindex 8d0d682ee7..601fd7b832 100644--- a/camera/src/main/java/com/vayunmathur/camera/util/CameraSingleCapture.kt+++ b/camera/src/main/java/com/vayunmathur/camera/util/CameraSingleCapture.kt@@ -65,7 +65,12 @@ private fun CameraViewModel.buildSingleCapturePlan(pending: PendingStill): Singl     // Skip it when the vendor NIGHT extension preview is bound: that session runs its own     // multi-frame AE and rejects Camera2-interop AE_MODE_OFF/manual-exposure options, which makes     // the capture fail. In that case a plain takePicture() lets the extension produce the shot.-    val nightExposure = if (nightModeActive.value && isExposureAuto() && !nightPreviewActiveMutable.value) {+    // Also skip it when flash is on: the night override locks AE off with a forced long+    // exposure, which breaks flash metering/timing and double-exposes (issue #721). The+    // capturePhoto() router already keeps flash shots on the plain path; this guard covers+    // any direct captureSinglePhoto() entry (e.g. night-burst fallback) the same way.+    val nightExposure = if (nightModeActive.value && isExposureAuto() && !nightPreviewActiveMutable.value &&+        flashModeMutable.value == FlashMode.OFF) {         computeNightExposure()     } else {         null