Skip to content

Ensure media projection guards and correct display import#2

Open
jalpesh wants to merge 9 commits into
mainfrom
codex/create-high-speed-usb-c-screen-mirroring-app-rtk93q
Open

Ensure media projection guards and correct display import#2
jalpesh wants to merge 9 commits into
mainfrom
codex/create-high-speed-usb-c-screen-mirroring-app-rtk93q

Conversation

@jalpesh
Copy link
Copy Markdown
Owner

@jalpesh jalpesh commented Nov 7, 2025

Summary

  • guard against null MediaProjectionManager and MediaProjection instances when starting the mirroring service
  • fix the MirroringSession display import so the module compiles with the Android SDK classes

Testing

  • not run (Android tooling unavailable in container)

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +85 to +92
private fun buildVirtualDisplayFlags(option: ConnectionOption): Int {
var flags = DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR or DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION
if (option != ConnectionOption.USB_C) {
flags = flags or DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY
}
if (lowLatency && Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
flags = flags or DisplayManager.VIRTUAL_DISPLAY_FLAG_TRUSTED
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove privileged TRUSTED flag from virtual display

When buildVirtualDisplayFlags adds DisplayManager.VIRTUAL_DISPLAY_FLAG_TRUSTED whenever low-latency mode is on (the default), createVirtualDisplay will throw SecurityException on Android 13+ because normal apps do not hold android.permission.ADD_TRUSTED_DISPLAY. As a result the mirroring service crashes immediately on start for modern devices unless users manually disable low latency. Consider omitting this flag or gating it behind the privileged permission.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant