|
| 1 | +# 20260605 Android Emulator Support Plan v01 |
| 2 | + |
| 3 | +## 成功标准 |
| 4 | + |
| 5 | +1. Android Emulator 进入 `triton device --platform android` 的统一 host device contract。 |
| 6 | +2. Android Debug APK 可通过 `triton app --platform android` 完成安装、启动、终止和 deep link smoke。 |
| 7 | +3. 所有新能力都可被 `triton schema --json`、`triton capabilities --json`、`triton doctor --json` 发现。 |
| 8 | +4. fake adb 测试先红后绿,真实 emulator smoke 至少覆盖 list、wait-ready、screenshot、install、open-url、evidence。 |
| 9 | +5. 不新增 Web/Wails UI,不支持真机或远端 agent。 |
| 10 | + |
| 11 | +## M0. 契约设计和红灯测试 |
| 12 | + |
| 13 | +- 定义 `HostDevicePlatform.android`、`android:<serial>` target id、Android 附加字段和统一 error code。 |
| 14 | +- 新增 fake adb fixture,覆盖 `adb devices -l`、`getprop sys.boot_completed`、`screencap`、`install`、`am start`、`uiautomator dump`。 |
| 15 | +- 先补测试: |
| 16 | + - `DeviceCrossPlatformTests` 覆盖 `doctor/list/use/wait-ready/screenshot --platform android` schema。 |
| 17 | + - `TKHostAdapterModelsTests` 覆盖 adb devices parser、boot completed parser、package / activity parser。 |
| 18 | + - `AppOpenURLFlowTests` 覆盖 Android deep link source command 与 unverified warning。 |
| 19 | +- 红灯预期:schema 不认识 android、platform enum 不接受 android、fake adb parser 不存在。 |
| 20 | + |
| 21 | +## M1. Device P0 |
| 22 | + |
| 23 | +- 实现 `AndroidHostDeviceAdapter`: |
| 24 | + - `doctor`: 探测 `adb`、可选 `emulator`、Android SDK 路径提示。 |
| 25 | + - `list`: 解析 `adb devices -l`,过滤/表达 `device/offline/unauthorized`。 |
| 26 | + - `use/current/resolve`: 复用统一 selector resolver,支持 alias、`android:<serial>`、raw serial、`current`。 |
| 27 | + - `wait-ready`: 轮询 `sys.boot_completed=1`,必要时验证 package manager 可响应。 |
| 28 | + - `screenshot`: `adb exec-out screencap -p` 写本地 PNG。 |
| 29 | +- 输出统一 `HostDeviceTarget` / `HostDeviceArtifactOutput`,平台差异放进 Android-specific metadata。 |
| 30 | +- 错误码:`android_adb_not_found`、`android_target_offline`、`android_target_unauthorized`、`device_not_ready`、`android_screenshot_failed`、`host_command_timeout`。 |
| 31 | + |
| 32 | +## M2. App P1 |
| 33 | + |
| 34 | +- `triton app list/info/install/uninstall/launch/terminate/open-url --platform android`: |
| 35 | + - install: `adb install -r <apk>` |
| 36 | + - uninstall: `adb uninstall <package>` |
| 37 | + - launch: `monkey -p <package> 1` 或 schema 明确要求 package/activity 时用 `am start` |
| 38 | + - terminate: `am force-stop <package>` |
| 39 | + - open-url: `am start -a android.intent.action.VIEW -d <url> <package>` |
| 40 | + - info/list: `pm list packages`、`dumpsys package <package>` 的 bounded summary |
| 41 | +- app action 返回 host action envelope,不能把 adb 成功当作业务 pass。 |
| 42 | +- 补 `triton plan open-url --platform android` 或在现有 open-url plan 中支持 `--device <android-alias>` 的推荐链路。 |
| 43 | + |
| 44 | +## M3. Observe / Action P1.5 |
| 45 | + |
| 46 | +- `triton ax --platform android --output <path.json>`: |
| 47 | + - 执行 `uiautomator dump /sdcard/window.xml` |
| 48 | + - `adb exec-out cat /sdcard/window.xml` 或 `adb pull` |
| 49 | + - 转为轻量 JSON artifact,不内联敏感完整 UI 到 stdout |
| 50 | +- `triton wait --platform android --text <text>` 轮询 UIAutomator tree。 |
| 51 | +- `triton tap --platform android <text>` 从 bounds 取中心点后 `adb shell input tap x y`。 |
| 52 | +- `triton type/paste/press/swipe --platform android` 只接稳定 host input,所有输入动作标记 `runtimeScope=host-android`。 |
| 53 | + |
| 54 | +## M4. Smoke / Evidence P2 |
| 55 | + |
| 56 | +- 新增 `triton smoke android`: |
| 57 | + - device wait-ready |
| 58 | + - app install 可选 |
| 59 | + - app open-url 或 launch |
| 60 | + - wait text |
| 61 | + - 可选 tap text |
| 62 | + - screenshot |
| 63 | + - evidence manifest |
| 64 | +- evidence artifact taxonomy 新增或复用: |
| 65 | + - `android.screenshot` |
| 66 | + - `android.layout` |
| 67 | + - `android.logcat` |
| 68 | + - `host.android-action` |
| 69 | + - `host.android-device-list` |
| 70 | +- `triton capture/evidence/replay` 读取 Android command ledger,保留 source command、elapsed、target、artifact path、redaction hint。 |
| 71 | + |
| 72 | +## M5. 真实 Emulator 验收 |
| 73 | + |
| 74 | +- 准备一个最小 Android Debug APK fixture 或使用现有可公开示例 APK。 |
| 75 | +- 真实命令链: |
| 76 | + |
| 77 | +```bash |
| 78 | +triton device doctor --platform android --json |
| 79 | +triton device list --platform android --json |
| 80 | +triton device alias set android-a --platform android --target <adb-serial> --json |
| 81 | +triton device wait-ready --device android-a --timeout 60 --jsonl |
| 82 | +triton device screenshot --device android-a --output /tmp/triton-android-smoke.png --json |
| 83 | +triton app install --platform android --device android-a --apk <path.apk> --json |
| 84 | +triton app open-url --platform android --device android-a "example://smoke" --bundle <package> --json |
| 85 | +triton wait --platform android --device android-a --text "<expected-text>" --timeout 20 --json |
| 86 | +triton smoke android --device android-a --bundle <package> --open-url "example://smoke" --wait-text "<expected-text>" --screenshot /tmp/triton-android-smoke.png --evidence /tmp/triton-android.tritonevidence --json |
| 87 | +``` |
| 88 | + |
| 89 | +- 截图按规范归档到 `docs-linhay/spaces/20260605-android-emulator-support/screenshots/<YYYYMMDD>/android/`。 |
| 90 | + |
| 91 | +## M6. 文档、public skill 和门禁 |
| 92 | + |
| 93 | +- 更新: |
| 94 | + - `README.md` |
| 95 | + - `docs-linhay/dev/ai-cli-readable-control.md` |
| 96 | + - `docs-linhay/dev/20260520-simulator-takeover-architecture.md` |
| 97 | + - `TritonKit.skills/tritonkit-emulator-cli-takeover/SKILL.md` |
| 98 | + - `docs-linhay/memory/YYYY-MM-DD.md` |
| 99 | +- 门禁: |
| 100 | + |
| 101 | +```bash |
| 102 | +swift test --package-path CLI --scratch-path .build/cli --filter DeviceCrossPlatformTests |
| 103 | +swift test --package-path CLI --scratch-path .build/cli --filter TKHostAdapterModelsTests |
| 104 | +swift test --package-path CLI --scratch-path .build/cli --filter AppOpenURLFlowTests |
| 105 | +docs-linhay/scripts/check-docs.sh |
| 106 | +docs-linhay/scripts/verify.sh --local |
| 107 | +``` |
| 108 | + |
| 109 | +## 拆分建议 |
| 110 | + |
| 111 | +1. 第一 PR:M0 + M1,只做 device P0 和 fake adb。 |
| 112 | +2. 第二 PR:M2,app lifecycle 与 deep link。 |
| 113 | +3. 第三 PR:M3 + M4,UIAutomator observe/action、smoke、evidence。 |
| 114 | +4. 第四 PR:真实 emulator fixture、README / public skill 对外使用口径、release 门禁补齐。 |
| 115 | + |
| 116 | +## 暂不沉淀为 AGENTS 规则 |
| 117 | + |
| 118 | +本计划是 Android adapter 的 feature-level 规划,不新增 repo-wide 长期规则。当前 AGENTS 已包含 emulator takeover 边界和 Android Emulator 范围,暂不需要修改。 |
0 commit comments