feat: add Android to Android phone sharing

This commit is contained in:
zhy200308
2026-08-12 15:17:34 +08:00
parent f248deac17
commit d3e840ff0a
15 changed files with 953 additions and 44 deletions
+35
View File
@@ -0,0 +1,35 @@
# Android → Android 真机验收(v0.5.0-dev1)
## 构建约束
在 Windows 的 Android 开发环境构建。本仓库的 macOS 封版流程不会安装或调用 Android SDK。
```powershell
cd android
.\gradlew.bat :app:testDebugUnitTest :app:assembleDebug
```
## 首轮验收
1. 两台 Android 安装同一个 `v0.5.0-dev1` APK。
2. 发送手机进入“手机 → 手机”,选择至少两个文件并调整一次顺序。
3. 点击“创建发送二维码”,允许附近 Wi-Fi/位置权限。
4. 接收手机进入“扫码直传”,扫描发送手机二维码并确认系统连接提示。
5. 核对接收顺序与发送队列一致,文件位于 `Downloads/QFT`,大小与 SHA-256 一致。
建议首轮文件组合:空文件、100 KiB 文档、20 MiB 视频、100 MiB 压缩包。
## 必测网络组合
- Android 13+ → Android 13+:`NEARBY_WIFI_DEVICES` 权限与临时热点。
- Android 8–12 → Android 10+:位置权限与 WPA2 临时热点。
- Android 7 发送端:两机先连接同一 Wi-Fi,验证自动 LAN 回落。
- 手动停止发送端热点:接收端应报连接中断,而不是无限等待。
- 传输中返回发送端首页:服务和临时热点应立即关闭。
## 当前边界
- 仅文件,不包含文件夹。
- 发送与接收页面需保持前台;尚未引入前台服务。
- LocalOnlyHotspot 没有互联网是预期行为,文件只在本地链路传输。
- Android ↔ iOS 不在本开发版本范围内。
+24
View File
@@ -98,3 +98,27 @@ Range: bytes=<start>-<end>
The sender returns `206 Partial Content`, the matching `Content-Range`, and the exact requested body length. Android splits the file toward 8 workers with **64 KiB–16 MiB** chunks, stores each completed chunk in a `.qftpart.map` ledger, and resumes only missing chunks after a reconnect. Each range retries with the currently available `Network`; the complete partial file must pass SHA-256 before it is published to `Downloads/QFT`.
For both direct-transfer directions, the Windows listener may accept connections non-blockingly for shutdown responsiveness, but each accepted file socket is switched to blocking I/O with explicit timeouts before reading or writing request bodies. This prevents `WSAEWOULDBLOCK (10035)` from turning an in-progress parallel transfer into an HTTP 500 failure.
## 6. Android → Android (`QFTPHONE2`, v0.5.0-dev1)
The sender starts an authenticated local HTTP service and encodes only session,
port, sender identity and optional LocalOnlyHotspot credentials in the QR. The
file queue is fetched after pairing so QR density is independent of queue size:
```text
GET /qft/ping
GET /qft/phone/manifest
GET /qft/phone/download/<queue-index>
Range: bytes=<start>-<end>
X-QFT-Token: <one-time session>
```
The manifest contains a bounded ordered list of `name`, `size`, `sha256` and a
server-generated fixed download path. The receiver does not accept arbitrary
paths from the QR or manifest: entry `N` must use `/qft/phone/download/N`.
Android 8+ prefers a system LocalOnlyHotspot. Android 7, or a hotspot failure,
falls back to literal private IPv4 endpoints on the current LAN. WPA2/WPA3
credentials are distinguished in `w[2]`. The receiver then reuses the existing
parallel Range ledger, retries and SHA-256-before-publish behavior for every
file, processing items in manifest order.