Skip to content

DevFlow: correct Android ADB port forwarding guidance - #3630

Open
jfversluis wants to merge 1 commit into
mainfrom
jfversluis-devflow-android-port-forwarding
Open

jfversluis wants to merge 1 commit into
mainfrom
jfversluis-devflow-android-port-forwarding

Conversation

@jfversluis

@jfversluis jfversluis commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: dcee7702214e16f6fa9fbbb8e1257707e63c01ae

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ Every claim checked against maui-labs source at 8f53402 (AndroidDevFlowPortForwarder.cs, AgentManagementOperations.cs, DevFlowCommands.cs).
↑ Shipped CLI 0.1.0-preview.14 help shows --device on maui devflow diagnose; PR merge commit is contained in v0.1.0-preview.10.
↑ markdownlint clean; technical and reader-persona reviews by two models, findings addressed.
↓ No end-to-end runtime run: a hung local emulator blocked DevFlow device enumeration, and repairing commands were not run on shared emulators.
↓ Docs build (xref/moniker warnings) not run locally; relies on PR build.

Fixes #3352

Summary

Documents the Android DevFlow port-forwarding changes from dotnet/maui-labs#273 and corrects wrong guidance that said adb reverse for both connections.

  • Direction fix: the app's agent reaches the host broker with adb reverse tcp:19223 tcp:19223; the host CLI reaches the in-app agent with adb forward tcp:{port} tcp:{port}.
  • Automatic forwarding: with exactly one online Android device, maui devflow wait adds the broker reverse mapping before waiting and the agent forward after registration; maui devflow list and commands that connect to an Android agent add missing mappings.
  • Device selection: --device <serial> on wait, list, and diagnose; ANDROID_SERIAL as fallback (and the only selector for auto-resolved agent commands, which pass no device). Multiple devices produce an error with candidate serials instead of guessing.
  • maui devflow diagnose: documents the Android forwarding section / android JSON property and clarifies that it reports only and doesn't repair (DiagnoseAsync calls EnsureForwardingForPortsAsync(..., repair: false, ...)). The issue text claimed diagnose repairs; the source and upstream docs/DevFlow/broker.md say otherwise.

Files

  • docs/developer-tools/devflow/setup-android.md: rewrote the ADB port forwarding section (automatic, multiple devices, status check, manual), updated troubleshooting, broadened intro.
  • docs/developer-tools/devflow/broker.md: corrected the platform connectivity table, command block, and troubleshooting row.
  • docs/developer-tools/devflow/index.md: corrected the Android platform-support note.

Not included

  • No standalone maui devflow CLI reference page exists in this repo, so the issue's suggested option-table row wasn't added.

Verification sources

  • Improve Android DevFlow port forwarding maui-labs#273 (merged 2026-05-21, included in v0.1.0-preview.10)
  • src/Cli/Microsoft.Maui.Cli/DevFlow/Android/AndroidDevFlowPortForwarder.cs
  • src/Cli/Microsoft.Maui.Cli/DevFlow/Operations/AgentManagementOperations.cs
  • src/DevFlow/Microsoft.Maui.DevFlow.Agent.Abstractions/BrokerRegistration.cs (agent retries broker connection in the background)

Internal previews

File Preview link
docs/developer-tools/devflow/broker.md Learn preview
docs/developer-tools/devflow/index.md Learn preview
docs/developer-tools/devflow/setup-android.md Learn preview

Build report

Agent-to-broker uses adb reverse on the broker port; CLI-to-agent uses
adb forward on the agent port. Document automatic forwarding in
maui devflow wait/list, device selection with --device and ANDROID_SERIAL,
and that maui devflow diagnose reports forwarding state without repairing it.

Fixes #3352

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jfversluis
jfversluis requested a review from a team as a code owner November 27, 2026 12:43
Copilot AI balanced review requested due to automatic review settings November 27, 2026 12:43
@learn-build-service-prod

Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit dcee770:

✅ Validation status: passed

File Status Preview URL Details
docs/developer-tools/devflow/broker.md ✅Succeeded View (>=net-maui-8.0)
docs/developer-tools/devflow/index.md ✅Succeeded View (>=net-maui-8.0)
docs/developer-tools/devflow/setup-android.md ✅Succeeded View (>=net-maui-8.0)

For more details, please refer to the build report.

Copilot AI 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.

🟡 Changes recommended

The Android setup guide gives inaccurate forwarding-recovery advice: cdp status cannot restore missing mappings, and list cannot recover the broker reverse mapping after an emulator restart before agent registration.

2 open issues
What changed in this PR

This documentation update corrects Android DevFlow connectivity guidance, distinguishing the broker’s reverse mapping from the agent’s forward mapping.

Changes:

  • Corrects ADB forwarding directions across setup, architecture, and platform-support documentation.
  • Documents automatic forwarding, device selection, and manual recovery.
  • Clarifies that maui devflow diagnose reports forwarding status without repairing mappings.
File Description
docs/​developer-tools/​devflow/​setup-android.md Expands forwarding setup, device selection, diagnostics, and troubleshooting.
docs/​developer-tools/​devflow/​index.md Corrects the Android platform-support connectivity note.
docs/​developer-tools/​devflow/​broker.md Corrects connectivity directions, commands, and recovery guidance.

Review effort: Balanced

1. Deploy and run your app. When the agent registers, `maui devflow wait` adds the agent forward mapping.
1. Run `maui devflow list` to confirm that the agent appears. This command also adds any missing mappings for registered Android agents.

Other DevFlow commands that connect to an Android agent also add any missing mappings before they connect.

> [!NOTE]
> Run these commands each time the emulator restarts. For physical devices connected via USB, the same `adb reverse` commands apply.
> ADB removes the mappings when the emulator restarts or the device disconnects. Run `maui devflow list` or `maui devflow wait` again to restore them. The same mappings apply to physical devices connected through USB.
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.

[maui-labs docs] Document Android DevFlow port forwarding improvements (PR #273)

2 participants