Skip to content

Catch camera error states and display CameraErrorDialog in PreviewLayout - #577

Merged
davidjiagoogle merged 7 commits into
mainfrom
david/errorStates
Oct 6, 2026
Merged

davidjiagoogle merged 7 commits into
mainfrom
david/errorStates

Conversation

@davidjiagoogle

Copy link
Copy Markdown
Collaborator

Summary

  • Define CameraError in :core:model and add cameraError: CameraError? to CameraState in :core:camera.
  • Catch CameraX StateError codes (ERROR_CAMERA_IN_USE, ERROR_MAX_CAMERAS_IN_USE, ERROR_OTHER_RECOVERABLE_ERROR, ERROR_STREAM_CONFIG, ERROR_CAMERA_DISABLED disambiguated via DevicePolicyManager.getCameraDisabled, ERROR_CAMERA_FATAL_ERROR, ERROR_DO_NOT_DISTURB_MODE_ENABLED, ERROR_CAMERA_REMOVED), synchronous IllegalArgumentException from bindToLifecycle, zero available lenses at startup, critical thermal status (PowerManager.THERMAL_STATUS_CRITICAL), and insufficient storage (StatFs, ImageCapture.ERROR_FILE_IO, VideoRecordEvent.Finalize.ERROR_INSUFFICIENT_STORAGE).
  • Define CameraErrorUiState in :ui:uistate:capture and CameraErrorUiStateAdapter + Photo Picker error string resources in :ui:uistateadapter:capture.
  • Create stateless CameraErrorDialog in :ui:components:capture and wire it into PreviewLayout (CaptureLayout.kt) and PreviewScreen.kt.

Test Plan

  • ./gradlew spotlessCheck --init-script gradle/init.gradle.kts
  • ./gradlew :ui:uistateadapter:capture:testStableDebugUnitTest
  • ./gradlew :app:assembleStableDebug

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive camera error handling system, defining a domain-level CameraError sealed interface to represent various CameraX and environmental errors (such as thermal overheat and insufficient storage), mapping them to UI states, and displaying them via a new CameraErrorDialog. The feedback highlights several areas for improvement: addressing a potential UninitializedPropertyAccessException if cameraProvider initialization fails, correcting test tag names to adhere to the repository's style guide (Rule 10), adding mandatory KDoc documentation to the internal toCameraError function (Rule 11), ensuring thread safety by performing the thermal status check inside the atomic update block, and improving the storage check accuracy by verifying the actual destination directory rather than relying solely on Environment.getDataDirectory().

davidjiagoogle added a commit that referenced this pull request Sep 28, 2026
Comment thread core/camera/src/main/java/com/google/jetpackcamera/core/camera/CameraSystem.kt Outdated
Comment thread ui/uistateadapter/capture/src/main/res/values/strings.xml Outdated
davidjiagoogle added a commit that referenced this pull request Oct 1, 2026
davidjiagoogle added a commit that referenced this pull request Oct 1, 2026
davidjiagoogle added a commit that referenced this pull request Oct 4, 2026
@davidjiagoogle
davidjiagoogle merged commit e1f35ce into main Oct 6, 2026
12 checks passed
@davidjiagoogle
davidjiagoogle deleted the david/errorStates branch October 6, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants