Skip to content

feat(pigeon): SAF 迁移到 channel 模式(异步 host) - #86

Merged
StillMisty merged 1 commit into
mainfrom
feat/pigeon-saf
Nov 20, 2026
Merged

StillMisty merged 1 commit into
mainfrom
feat/pigeon-saf

Conversation

@StillMisty

Copy link
Copy Markdown
Owner

Part of #70. Closes #85.

概要

SAF 从手写 MethodChannel 迁移到 Pigeon channel 模式(Android-only,@asyncCallback),旧 top.stillmisty.molia/saf 通道保留 fallback。

  • schema:tool/pigeon/saf.dart(stat / listTreeBegin / listTreeNext / listTreeClose / readHead / readRange;SafDocumentMessage / SafTreeEntryMessage / SafTreeBatchMessage)
  • 原生:抽出共享 SafHost(stat / 会话 begin-next-close / readHead / readRange / 错误码 / 分批 / 隐藏 / 深度语义);旧 channel 与 Pigeon SafApiImpl 共用同一实例;I/O 继续走 executor,平台线程只做校验与派发
  • MainActivity 注册 SafApi.setUp,cleanUpFlutterEngine 统一 SafHost.dispose();旧通道保留
  • Dart:saf_adapter.dart 封装 Pigeon transport;pigeon_saf_bridge.dart 映射 SafBridge;首批之前 transport 失败才回退旧桥,中途失败不重扫;createSafBridge() 工厂
  • CI drift 增加 SAF Pigeon 生成(channel 模式,Linux 可跑)

验证

  • flutter analyze --no-pub:0 issue
  • flutter test --no-pub:3565 通过
  • docs check:OK
  • Pigeon 重跑无 diff;build_runner 不删生成物
  • flutter build apk --debug / --release 成功;release 安装启动无 ClassNotFoundException / NoSuchMethodError,dex 保留 SafHost / SafApiImpl
  • 模拟器临时冒烟:Pigeon host 注册、业务错误码、旧 MethodChannelSafBridge fallback

限制

  • SAF tree URI 需要系统 picker 持久授权,当前环境无法取得,因此未做真实 stat/read 成功冒烟;分批 / 错误 / fallback 由单测覆盖。
  • 不改 Apple / Windows / Linux / release.yml;旧通道保留。
  • 本机 release --no-pub 的 GeneratedPluginRegistrant 缓存问题与本改动无关;发布 workflow 不带 --no-pub。

@StillMisty
StillMisty marked this pull request as ready for review November 20, 2026 11:56
@StillMisty
StillMisty merged commit fb7cbb9 into main Nov 20, 2026
5 checks passed
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.

Pigeon 契约:SAF(Android,channel 模式)

1 participant