Skip to content

fix: fall back to an available CarPlay control port - #54

Merged
fython merged 1 commit into
fython:mainfrom
xiwangly2:fix/airplay-port-collision
Oct 29, 2026
Merged

fython merged 1 commit into
fython:mainfrom
xiwangly2:fix/airplay-port-collision

Conversation

@xiwangly2

Copy link
Copy Markdown
Contributor

当其他服务占用 AirPlay 首选端口(默认 7000)时,原实现直接绑定失败。无线流程会在 RFCOMM/iAP2 启动前退出,有线流程也无法继续发送 CarPlayStartSession,可能表现为 iPhone 无法进入 CarPlay 授权或后续连接。

保留配置端口为首选;遇到 BindException 时,在同一绑定地址上通过端口 0 申请一次系统分配的端口,并保留成功绑定的 socket。失败的候选 socket 会关闭,其他类型错误直接传播。实际监听端口通过 Started.port 返回,统一用于会话配置、Bonjour 及有线/无线 iAP2 StartSession,避免监听与发布端口不一致,也不进行存在竞态的空闲端口预探测。

验证:

  • 新增 15 项回归,覆盖 IPv4/IPv6 实际占用、回退后 TCP 连接、端口 0、发布端口、重连结果隔离、异常与资源清理。修复前,真实占用用例在绑定阶段失败;修复后全部通过,无跳过。
  • shared 全量 502 项、相关 common 服务生命周期 14 项通过;mobile:lintDebug、mobile:assembleDebug 和 git diff --check 通过。
  • Android 13 / RK3562 设备无线实测:保持独立 TCP 进程占用 7000,AirPlay 分别使用系统分配的 38597、39407,浏览器获得真实 CarPlay 画面并响应触控。用户在 iPhone 忽略车辆、重新配对后,确认再次看到并允许 CarPlay 授权,浏览器恢复画面。验证结束后已移除占用进程。

实机验证范围为无线 CarPlay;有线 NCM/VPN 连接尚未实机验证。协议编码和 IPv6 监听已由回归覆盖。

@fython
fython merged commit 7a82bcb into fython:main Oct 29, 2026
3 checks passed
@fython

fython commented Oct 29, 2026

Copy link
Copy Markdown
Owner

@xiwangly2 感谢贡献!

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