Skip to content

Fix unsupported focus metering crash#490

Merged
davidjiagoogle merged 13 commits intomainfrom
david/zoomTestFail
Apr 14, 2026
Merged

Fix unsupported focus metering crash#490
davidjiagoogle merged 13 commits intomainfrom
david/zoomTestFail

Conversation

@davidjiagoogle
Copy link
Copy Markdown
Collaborator

@davidjiagoogle davidjiagoogle commented Apr 1, 2026

This PR catches an IllegalArgumentException thrown during tap-to-focus on devices that do not support AF/AE/AWB metering points. Instead of crashing, the tap now gracefully fails and acts as a no-op, instead of crashing the app

Copy link
Copy Markdown
Contributor

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

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 adds error handling for IllegalArgumentException during focus metering operations to prevent potential crashes, returning a failure status when the exception is caught. The review feedback suggests improving the logging by using a warning level and including the full exception stack trace for better diagnostics. Additionally, the reviewer noted that unit tests should be added to verify this new logic, in accordance with the repository's style guide for logic changes.

Comment thread core/camera/src/main/java/com/google/jetpackcamera/core/camera/FocusMetering.kt Outdated
@davidjiagoogle davidjiagoogle requested a review from temcguir April 14, 2026 16:39
@temcguir
Copy link
Copy Markdown
Collaborator

/gemini review

Copy link
Copy Markdown
Contributor

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

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 enhances the focus and metering logic by adding a check for device support before initiating the action and improving error handling for IllegalArgumentException. To ensure these changes are robust, it is recommended to add a test case to FocusMeteringTest.kt that simulates a device where focus metering is unsupported. Additionally, the nested logic in the focus metering check could be simplified using a guard clause to improve readability.

Comment thread core/camera/src/main/java/com/google/jetpackcamera/core/camera/FocusMetering.kt Outdated
Comment thread core/camera/src/main/java/com/google/jetpackcamera/core/camera/FocusMetering.kt Outdated
@davidjiagoogle davidjiagoogle enabled auto-merge (squash) April 14, 2026 20:12
@davidjiagoogle davidjiagoogle merged commit ce7c614 into main Apr 14, 2026
8 checks passed
@davidjiagoogle davidjiagoogle deleted the david/zoomTestFail branch April 14, 2026 20:53
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.

2 participants