camera: QR analysis sink republish fix (mode superseded next)
- Commit
4fe951775c05acdb093ba2e7278f3b0fd33a3a27- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-23 20:21 UTC (12 days ago)
- Parents
3449d78
The QR restoration's remaining wiring: the analysis stream-active flag is republished at bind end and on session registration (it was cleared on mode-switch teardown and never restored, showing 'scanning paused' on a live stream - affected Photo mode too). Owner has since directed QR to live inside Photo mode rather than a dedicated mode; that conversion follows in the next change, reusing this scanner core. Verified with the QR change: 760 camera tests green.
Diff
camera/src/main/java/com/vayunmathur/camera/platform/Camera2StillCapture.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/platform/Camera2StillCapture.kt b/camera/src/main/java/com/vayunmathur/camera/platform/Camera2StillCapture.ktindex 31544efb55..f6c745da09 100644--- a/camera/src/main/java/com/vayunmathur/camera/platform/Camera2StillCapture.kt+++ b/camera/src/main/java/com/vayunmathur/camera/platform/Camera2StillCapture.kt@@ -47,6 +47,11 @@ import kotlinx.coroutines.withContext internal fun CameraViewModel.registerCamera2Session(session: Camera2Session?) { activeCamera2Session = session if (session != null) {+ // A live session is the honest moment to publish whether its+ // analysis stream is carrying the mode's sink (QR scanner,+ // PhotoAnalyzer, ...); teardown clears the flag, so without this+ // the "scanning paused" banner survives a successful bind.+ onSessionBound() viewModelScope.launch { refreshCapabilities(session.characteristics.cameraId) } } }
camera/src/main/java/com/vayunmathur/camera/ui/CameraScreenEffects.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/ui/CameraScreenEffects.kt b/camera/src/main/java/com/vayunmathur/camera/ui/CameraScreenEffects.ktindex 7c065b78b1..b71a5e2737 100644--- a/camera/src/main/java/com/vayunmathur/camera/ui/CameraScreenEffects.kt+++ b/camera/src/main/java/com/vayunmathur/camera/ui/CameraScreenEffects.kt@@ -25,6 +25,7 @@ import com.vayunmathur.camera.platform.clearCamera2NightFallback import com.vayunmathur.camera.platform.applyImageCaptureFlashMode import com.vayunmathur.camera.platform.enableTorch import com.vayunmathur.camera.platform.onLuminance+import com.vayunmathur.camera.platform.onSessionBound import com.vayunmathur.camera.platform.refreshNightExtensionUsable import com.vayunmathur.camera.platform.runSessionBindWithRetry import com.vayunmathur.camera.platform.setQrResult@@ -126,7 +127,12 @@ internal fun CameraScreenEffects( // re-applied to the freshly-bound ImageAnalysis after every (re)bind (mode switch / flip), and // on lensFacing + selectedLens to match the DisposableEffect below, which detaches on a // flip or lens switch.- LaunchedEffect(cameraMode, lensFacing, selectedLens) {+ // photoSessionActive joins the keys so the sink (and the+ // analysisStreamActive flag behind it) is re-applied after the bind+ // effect's teardown, which otherwise leaves the flag cleared โ and+ // the "QR scanning paused" banner up โ on every mode switch, even+ // though the Camera2 session (and its analysis stream) never died.+ LaunchedEffect(cameraMode, lensFacing, selectedLens, state.photoSessionActive) { when { cameraMode == CameraMode.SLOW_MO -> { state.maskBitmap = null@@ -285,6 +291,12 @@ internal fun CameraScreenEffects( viewModel.photoSessionActiveMutable.value = sessionKind == SessionKind.PHOTO || sessionKind == SessionKind.PORTRAIT || sessionKind == SessionKind.PANORAMA+ // teardownSession() above cleared analysisStreamActive;+ // the analyzer effect (composed earlier) has already+ // installed this mode's sink, so republish from it now โ+ // otherwise the "QR scanning paused" banner survives every+ // mode switch despite a live analysis stream.+ viewModel.onSessionBound() viewModel.videoSessionActiveMutable.value = sessionKind == SessionKind.VIDEO viewModel.highSpeedActiveMutable.value = sessionKind == SessionKind.HIGH_SPEED viewModel.nightPreviewActiveMutable.value = useCamera2NightPreview