Skip to content

Projected context refactor#983

Open
trambui09 wants to merge 2 commits into
android:mainfrom
trambui09:tb/projected-device-context-anti-pattern
Open

Projected context refactor#983
trambui09 wants to merge 2 commits into
android:mainfrom
trambui09:tb/projected-device-context-anti-pattern

Conversation

@trambui09

Copy link
Copy Markdown
Contributor

Clarify that you need to check for connection before creating a projected device context. Refactor mentions of AI glasses to audio and display glasses.

@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 updates terminology from 'AI Glasses' to 'Display Glasses' across the project and introduces a new monitorProjectedConnectivity function in ProjectedHardware.kt to better manage device connection states. I agree with the reviewer's suggestion to refactor the startCameraOnGlasses function to utilize this new connectivity monitoring pattern, which will improve robustness by proactively checking for device connectivity rather than relying solely on a try-catch block.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines 131 to 136
val projectedContext = try {
ProjectedContext.createProjectedDeviceContext(activity)
} catch (e: IllegalStateException) {
Log.e(TAG, "AI Glasses context could not be created", e)
Log.e(TAG, "Projected context could not be created", e)
return
}

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.

medium

This try-catch block for creating the projectedContext is less robust than the new pattern introduced in this PR with monitorProjectedConnectivity. To align with the PR's goal of clarifying connection checking, this function should be updated to proactively check for connectivity using ProjectedContext.isProjectedDeviceConnected before attempting to create the context. This would prevent an IllegalStateException when the device is not connected and make the example code more consistent.

@trambui09
trambui09 marked this pull request as ready for review July 17, 2026 17:28
@trambui09
trambui09 requested a review from a team as a code owner July 17, 2026 17:28
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

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.

1 participant