feat: scan the pairing QR code with the camera

The pairing dialog gained a "扫码" button: a full-screen scanner points the
back camera at the QR that OpenChamber's connect-a-device dialog shows, and a
decoded pairing link connects straight away.

Frames are decoded with zxing2 (pure Dart, no ML Kit or Play services): the
YUV420 Y plane is already luminance, BGRA frames are converted green-weighted,
and each frame is decoded in a background isolate so camera frames never block
the UI. Only an openchamber://connect payload ends the scan; any other QR code
shows a short hint and scanning continues. A torch button, a denied-permission
message with retry, and camera-less devices are handled.

The recorder audio permission the camera plugin declares for video is removed
from the merged manifest: the scanner reads frames only.

0.4.5 (405).
This commit is contained in:
blumia committed 2026-11-22 17:52:47 +08:00
1 parent 902f1e18bb
commit 8f6fd99103
10 files changed
+634 -13

No files matched your search

+13
View File
@@ -5,6 +5,19 @@
---
## 0.4.5 扫码配对(分支 `flutter`)
| 项 | 结果 |
| --- | --- |
| 扫码入口 | 「配对链接」对话框新增「扫码」:全屏相机 + 取景框 + 手电筒;扫到配对链接直接开始配对,不再要求按第二个按钮 |
| 解码 | 用 `camera` 0.12 + `zxing2` 0.2(纯 Dart,不依赖 ML Kit / Google Play 服务)。Android 取 YUV420 的 Y 平面直接作为亮度;BGRA(iOS/部分相机)按绿加权转亮度。解码放在 `compute` isolate,每帧不阻塞 UI,同一时间只解一帧 |
| 取景 | 后置相机优先、480p 预览、覆盖率/圆角遮罩 + 四角标记;非配对二维码提示「这不是 OpenChamber 配对二维码」并继续扫;无相机/权限被拒给出说明与重试 |
| 权限 | AndroidManifest 增加 CAMERA 权限;camera 硬件声明为非必需,没相机的设备仍可安装 |
| 测试 | `test/qr_scan_test.dart`:用 `qr` 生成配对链接二维码,渲染成 Y 平面(含 rowStride 内边距)后由 `decodeQrLuminance` 解出原文;空白帧、过短/非法尺寸返回 null |
| 版本 | **0.4.5(code 405)** |
---
## 0.4.4 通过 OpenChamber 私有 Relay 连接(分支 `flutter`)
| 项 | 结果 |