Skip to content

feature(wireless-discovery): Rewrite Pairing device with pairing code using mDNS like Android Studio#23

Merged
dungngminh merged 4 commits into
mainfrom
feature/wireless-discovery
May 2, 2026
Merged

feature(wireless-discovery): Rewrite Pairing device with pairing code using mDNS like Android Studio#23
dungngminh merged 4 commits into
mainfrom
feature/wireless-discovery

Conversation

@dungngminh
Copy link
Copy Markdown
Owner

@dungngminh dungngminh commented May 2, 2026

Description

Refactor Wi-Fi wireless pairing flow to match Android Studio behavior:

  • mDNS device discovery: New WifiDiscoveryService (backed by multicast_dns) continuously scans for _adb-tls-pairing._tcp endpoints and streams discovered devices in real time.
  • Rewritten pairing dialog: Replaced old wireless_pairing_dialog.dart (205 lines) with new wireless_pairing/wireless_pairing_dialog.dart (716 lines). New flow — discover devices → select → enter 6-digit PIN → resolve connect endpoint → connect. Mirrors Android Studio pairing UX.
  • New shared components: LoadingState, PinCodeFields added for reuse across dialogs.
  • New models: WifiPairingDevice, WirelessPairingInfo, WirelessConnectRequest, AdbConnectResult.
  • Bug fix: Fixed text color in dialogs/panels causing wrong overlay color effect.
  • Version bump: 0.5.0.

Type of Change

  • 🔥 New feature (non-breaking change which adds functionality)
  • ✨ Enhancement (non-breaking change which improves existing functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • 🧹 Code refactor
  • 📝 Documentation
  • 🗑️ Chore
  • 📦 Build configuration change
  • ✅ Test

Summary by CodeRabbit

Release Notes – Version 0.5.0

  • New Features

    • Added device discovery for wireless pairing, with fallback manual entry option
    • Enhanced wireless pairing flow with two-step process: discover device, then enter code
    • Improved dialog styling and text color consistency
    • Added Windows PowerShell installer support
  • Bug Fixes

    • Fixed dialog text color overlay rendering issues

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 2, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cbe1d36e-4227-4de3-bdd6-1bfa46ad06b1

📥 Commits

Reviewing files that changed from the base of the PR and between b18c1f9 and 25edaef.

⛔ Files ignored due to path filters (1)
  • pubspec.lock is excluded by !**/*.lock
📒 Files selected for processing (22)
  • AGENTS.md
  • CHANGELOG.md
  • docs/ai/contributing.md
  • lib/components/error_dialog.dart
  • lib/components/input_dialog.dart
  • lib/components/loading_state.dart
  • lib/components/pin_code_fields.dart
  • lib/components/simutil_theme.dart
  • lib/models/adb_connect_result.dart
  • lib/models/wifi_pairing_device.dart
  • lib/models/wireless_connect_request.dart
  • lib/models/wireless_pairing_info.dart
  • lib/plugins/adb_tools/adb_tools_dialog.dart
  • lib/plugins/adb_tools/qr_connect_dialog.dart
  • lib/plugins/adb_tools/wireless_pairing/wireless_pairing_dialog.dart
  • lib/plugins/adb_tools/wireless_pairing_dialog.dart
  • lib/services/android_device_service.dart
  • lib/services/service_locator.dart
  • lib/services/settings_service.dart
  • lib/services/wifi_discovery_service.dart
  • lib/simutil_app.dart
  • pubspec.yaml

📝 Walkthrough

Walkthrough

This PR refactors Android device wireless pairing from a single-dialog approach (host+code entry) to a multi-phase flow featuring device discovery via mDNS, device selection, and optional manual entry. New UI components (LoadingState, PinCodeFields) are introduced, service models are extracted, SettingsService is refactored to an interface, and the app version is bumped to 0.5.0.

Changes

Wireless Pairing and Device Discovery Flow

Layer / File(s) Summary
Data Models
lib/models/wifi_pairing_device.dart, lib/models/adb_connect_result.dart, lib/models/wireless_connect_request.dart, lib/models/wireless_pairing_info.dart
New immutable model classes represent discovered Wi-Fi pairing devices, connection results, pairing requests, and device capabilities.
Service Extraction & Refactoring
lib/services/android_device_service.dart, lib/services/service_locator.dart, lib/services/settings_service.dart
AdbConnectResult and WirelessPairingInfo are moved from android_device_service.dart to standalone model files. SettingsService is refactored from a concrete class to an abstract interface with SettingsServiceImpl as the implementation. ServiceLocator wires the new WifiDiscoveryService.
mDNS Device Discovery
lib/services/wifi_discovery_service.dart
New WifiDiscoveryService interface and MdnsWifiDiscoveryService implementation perform mDNS scanning for _adb-tls-pairing._tcp services, resolving PTR/SRV/A records to enumerate available pairing devices as a stream.
UI Components & Theming
lib/components/loading_state.dart, lib/components/pin_code_fields.dart, lib/components/simutil_theme.dart, lib/components/error_dialog.dart, lib/components/input_dialog.dart
New LoadingState (animated spinner) and PinCodeFields (multi-cell PIN entry) components follow small-component architecture. Theme gains errorDialogPanel() and color updates; existing dialogs use new theme helpers and width constraints.
Multi-Phase Pairing Dialog
lib/plugins/adb_tools/wireless_pairing/wireless_pairing_dialog.dart (new), lib/plugins/adb_tools/wireless_pairing_dialog.dart (removed)
New WirelessConnectDialog replaces the old WirelessPairingDialog, implementing three phases: device discovery (with error/loading states), pairing-code entry (with 6-digit PIN validation and paste distribution), and manual host+code entry. Includes keyboard navigation, escape handling, and multi-slot PIN input. Old single-dialog implementation is deleted.
Tool Options & Integration
lib/plugins/adb_tools/adb_tools_dialog.dart, lib/plugins/adb_tools/qr_connect_dialog.dart, lib/simutil_app.dart
AdbToolOption enum options renamed to "Pair using Pairing Code" and "Pair using QR Code". Main app's _handleWirelessPairing rewired to use showWirelessConnectDialog, pair only when a code is provided, and refresh devices on success. Old post-pairing connection flow removed.
Documentation & Release
AGENTS.md, CHANGELOG.md, docs/ai/contributing.md, pubspec.yaml
Changelog documents the two-step discover-then-code pairing flow, Windows PowerShell installer addition, and text-color fix. Contributing guide emphasizes splitting large widget trees into components. Pubspec version bumped to 0.5.0.

Sequence Diagram

sequenceDiagram
    actor User
    participant WCD as WirelessConnectDialog
    participant WDS as WifiDiscoveryService
    participant ADB as AndroidDeviceService
    participant Device as Android Device

    User->>WCD: Open pairing dialog
    WCD->>WDS: watchPairingDevices()
    WDS->>WDS: Scan mDNS for _adb-tls-pairing._tcp
    WDS-->>WCD: Stream discovered WifiPairingDevice
    
    User->>WCD: Select device from list
    WCD->>WCD: Show enter-code phase
    User->>WCD: Enter 6-digit pairing code
    User->>WCD: Submit (press Enter)
    
    WCD->>ADB: pairDevice(host, pairingCode)
    ADB->>Device: ADB pairing request with code
    Device-->>ADB: Pairing success/failure
    ADB-->>WCD: AdbConnectResult
    
    alt Pairing Success
        WCD->>WCD: Show success dialog
        WCD->>WCD: Refresh device list
    else Pairing Failed
        WCD->>WCD: Show error dialog
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~65 minutes

Suggested labels

feature

Poem

🐰 Whiskers twitch with delight,
Device discovery, smooth and bright,
Code slots filled with digit cheer,
Pairing flows now crystal clear,
No more clunky single-phase,
Multi-step dance sets the pace!

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/wireless-discovery

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@dungngminh dungngminh merged commit 6d525d6 into main May 2, 2026
5 of 6 checks passed
@dungngminh dungngminh deleted the feature/wireless-discovery branch May 2, 2026 07:07
@dungngminh dungngminh added the feature Features ✨ label May 2, 2026
dungngminh added a commit that referenced this pull request May 2, 2026
@dungngminh dungngminh self-assigned this May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Features ✨

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant