Skip to content

Commit 6989136

Browse files
committed
Fix emulator license agreement launch handling
Fixes #17
1 parent 833178a commit 6989136

6 files changed

Lines changed: 207 additions & 10 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
语言:中文 | [English](./README_en.md)
66

7-
[![release](https://img.shields.io/badge/release-v1.3.7-1f6feb?style=flat-square)](https://github.com/linhay/harmony-next.skills/releases/tag/v1.3.7)
7+
[![release](https://img.shields.io/badge/release-v1.3.22-1f6feb?style=flat-square)](https://github.com/linhay/harmony-next.skills/releases/tag/v1.3.22)
88
[![readme](https://img.shields.io/badge/readme-English-0f766e?style=flat-square)](./README_en.md)
99
![docs](https://img.shields.io/badge/docs-3,693%20markdown%20files-7c3aed?style=flat-square)
1010
![js-ets](https://img.shields.io/badge/JsEtsAPIReference-3,666%20files-b45309?style=flat-square)
@@ -109,7 +109,7 @@ SKILL.md
109109
- 真实截图、layout、日志包、安装卸载、端口转发、HVD 创建/删除等动作按非交互流程执行;缺少 target、artifact 目录、脱敏策略或 timeout 时才返回 machine-readable blocked 结果。
110110
- 本仓库提供 `python3 harmony-next/scripts/hvd_manager.py`:支持 `doctor` 环境探测、`list``create``delete``launch-preflight``launch`
111111
- HVD 启动适配:`--root` / `HARMONY_HVD_ROOT` 指定 HVD root,`--emulator` / `HARMONY_EMULATOR` 指定 Emulator,`--image-root` / `HARMONY_EMULATOR_IMAGE_ROOT` 指定模拟器镜像根,`--hdc` / `HARMONY_HDC` 指定 HDC。`--sdk-root` / `DEVECO_SDK_HOME` 只表示 DevEco build SDK root,不等同于模拟器镜像根。
112-
- macOS 常见镜像根是 `~/Library/Huawei/Sdk`;脚本会用 HVD `imageSubPath` 校验系统镜像。当前 `launch` 会 detach Emulator 与 trace holder,等待 HDC、boot 和稳定性检查;后续生命周期模型应补齐 attached 终端托管模式,让终端结束时通过 `Emulator -stop` 回收模拟器,并保留 detached 兼容模式。`download-image` 当前只返回 blocked,因为镜像下载仅确认到 IDE SDK Manager UI 入口。
112+
- macOS 常见镜像根是 `~/Library/Huawei/Sdk`;脚本会用 HVD `imageSubPath` 校验系统镜像。当前 `launch` 会 detach Emulator 与 trace holder,等待 HDC、boot 和稳定性检查;首次运行 Emulator 遇到华为许可协议确认时返回 `result=license-agreement-required` / `missingConfig=["emulatorLicenseAgreement"]`,只有显式传入 `--accept-license` 才会向 Emulator stdin 写入 `y`后续生命周期模型应补齐 attached 终端托管模式,让终端结束时通过 `Emulator -stop` 回收模拟器,并保留 detached 兼容模式。`download-image` 当前只返回 blocked,因为镜像下载仅确认到 IDE SDK Manager UI 入口。
113113
- 模拟器抓包与代理诊断:Charles、mitmproxy、Proxyman 等抓包工具都需要确认模拟器 NAT、宿主机可达地址和应用级代理。常见调试入口是让目标应用显式走 `10.0.2.2:9090`,例如 `setAppHttpProxy` 配合 `usingProxy: true`;Mac 侧中转脚本不能被描述为通用透明抓包方案。
114114

115115
### DevEco Studio IDE 私有接口
@@ -188,7 +188,7 @@ ln -s "$(pwd)/harmony-next.skills/harmony-next" "$HOME/.agents/skills/harmony-ne
188188
| 版本 | 重点变化 |
189189
| --- | --- |
190190
| `v1.3.7` | 新增可复制 HarmonyOS NEXT Empty Ability 最小测试工程模板:`references/templates/empty-ability-app`;默认 `com.example.emptyability` / `EntryAbility` / `5.0.0(12)`,补充 SDK 版本适配验证(含 `6.0.2(22)` / `DEVECO_SDK_HOME=/Applications/DevEco-Studio.app/Contents/sdk`)、`ohpm install``hvigorw --mode module`、HDC 启动、`uitest dumpLayout``uitest uiInput click` smoke 能力 |
191-
| `Unreleased` | DevEco Emulator CLI 启动补充 trace socket 守护入口:`hvd_manager.py launch-preflight` 只输出带 `-t <trace-name>` 的命令计划,`hvd_manager.py launch` 创建 trace socket、detach Emulator 与 trace holder 后启动;启动前按 HVD `imageSubPath` 校验 emulator image root,区分 build SDK root 与 `~/Library/Huawei/Sdk`;启动失败/超时时返回退出码、日志路径、HDC 快照、HVD 运行态和稳定性检查等 machine-readable 诊断;文档新增 attached 终端托管生命周期核查表,指导后续将终端结束与 `Emulator -stop` 清理绑定 |
191+
| `Unreleased` | DevEco Emulator CLI 启动补充 trace socket 守护入口:`hvd_manager.py launch-preflight` 只输出带 `-t <trace-name>` 的命令计划,`hvd_manager.py launch` 创建 trace socket、detach Emulator 与 trace holder 后启动;启动前按 HVD `imageSubPath` 校验 emulator image root,区分 build SDK root 与 `~/Library/Huawei/Sdk`;启动失败/超时时返回退出码、日志路径、HDC 快照、HVD 运行态和稳定性检查等 machine-readable 诊断;首次运行许可协议提示会分类为 `license-agreement-required`,并提供显式 `--accept-license` opt-in;文档新增 attached 终端托管生命周期核查表,指导后续将终端结束与 `Emulator -stop` 清理绑定 |
192192
| `Unreleased` | Release 产物改为 `harmony-next.skill.zip`,包内新增 `BUILD_INFO.json` 记录版本、release tag 与 git commit,并新增 `ISSUE_GUIDE.md` 指导 agent 复现、脱敏、分类和提交仓库 issue |
193193
| `v1.3.6` | DevEco 模拟器 playbook 新增非交互自动化策略:用户默认拥有完整权限,`policy` 仅表示执行模式;支持 `readonly/evidence/automation/diagnostic/break-glass`、artifact 目录、脱敏元数据与 machine-readable blocked 输出 |
194194
| `v1.3.5` | 新增 DevEco Studio IDE 私有未公开能力参考:CodeGenie 本地 RAG/MCP/LanceDB、`devecostudio://`、Previewer、ArkUI Inspector、Profiler、Doctor、UxTestService、插件入口索引与隐私风险门禁;更新 README 与触发词 |

README_en.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ An offline HarmonyOS NEXT reference skill for coding agents such as Gemini CLI,
44

55
Language: English | [中文](./README.md)
66

7-
[![release](https://img.shields.io/badge/release-v1.3.7-1f6feb?style=flat-square)](https://github.com/linhay/harmony-next.skills/releases/tag/v1.3.7)
7+
[![release](https://img.shields.io/badge/release-v1.3.22-1f6feb?style=flat-square)](https://github.com/linhay/harmony-next.skills/releases/tag/v1.3.22)
88
[![readme](https://img.shields.io/badge/readme-%E4%B8%AD%E6%96%87-0f766e?style=flat-square)](./README.md)
99
![docs](https://img.shields.io/badge/docs-3,693%20markdown%20files-7c3aed?style=flat-square)
1010
![js-ets](https://img.shields.io/badge/JsEtsAPIReference-3,666%20files-b45309?style=flat-square)
@@ -109,7 +109,7 @@ Usage rules:
109109
- Real screenshots, layouts, log bundles, installs/uninstalls, port forwarding, and HVD create/delete flows run non-interactively; missing target, artifact directory, redaction policy, or timeout returns a machine-readable blocked result.
110110
- This repo provides `python3 harmony-next/scripts/hvd_manager.py`: `doctor` environment probing, `list`, `create`, `delete`, `launch-preflight`, and `launch` are supported.
111111
- HVD launch adaptation: use `--root` / `HARMONY_HVD_ROOT` for the HVD root, `--emulator` / `HARMONY_EMULATOR` for Emulator, `--image-root` / `HARMONY_EMULATOR_IMAGE_ROOT` for the emulator image root, and `--hdc` / `HARMONY_HDC` for HDC. `--sdk-root` / `DEVECO_SDK_HOME` means the DevEco build SDK root, not necessarily the emulator image root.
112-
- On macOS the emulator image root is commonly `~/Library/Huawei/Sdk`; the script validates it against the HVD `imageSubPath`. The current `launch` command detaches Emulator and the trace holder, then waits for HDC, boot, and stability checks. The next lifecycle model should add an attached terminal-scoped mode that runs cleanup through `Emulator -stop` when the terminal session ends, while keeping detached mode for compatibility. `download-image` currently returns blocked because image downloads have only been verified through the IDE SDK Manager UI.
112+
- On macOS the emulator image root is commonly `~/Library/Huawei/Sdk`; the script validates it against the HVD `imageSubPath`. The current `launch` command detaches Emulator and the trace holder, then waits for HDC, boot, and stability checks. A first-run Huawei Emulator license/agreement prompt returns `result=license-agreement-required` / `missingConfig=["emulatorLicenseAgreement"]`; the script only writes `y` to Emulator stdin when `--accept-license` is passed explicitly. The next lifecycle model should add an attached terminal-scoped mode that runs cleanup through `Emulator -stop` when the terminal session ends, while keeping detached mode for compatibility. `download-image` currently returns blocked because image downloads have only been verified through the IDE SDK Manager UI.
113113
- For emulator traffic capture and proxy diagnostics, HTTP proxy capture tools such as Charles, mitmproxy, and Proxyman require checking the emulator NAT, a host address reachable from the emulator, and app-level proxy settings. The usual debugging path is to make the target app explicitly use `10.0.2.2:9090`, for example `setAppHttpProxy` plus `usingProxy: true`; a macOS forwarding script should not be documented as a general transparent interception solution.
114114

115115
### DevEco Studio IDE Private Interfaces
@@ -188,7 +188,7 @@ Entry files:
188188
| Version | Highlights |
189189
| --- | --- |
190190
| `v1.3.7` | Added a copyable HarmonyOS NEXT Empty Ability minimal test project template: `references/templates/empty-ability-app`; defaults to `com.example.emptyability` / `EntryAbility` / `5.0.0(12)` and documents SDK override validation including `6.0.2(22)` / `DEVECO_SDK_HOME=/Applications/DevEco-Studio.app/Contents/sdk`, `ohpm install`, `hvigorw --mode module`, HDC launch, `uitest dumpLayout`, and `uitest uiInput click` smoke capabilities |
191-
| `Unreleased` | Added guarded DevEco Emulator CLI launch entries: `hvd_manager.py launch-preflight` only prints a command plan with `-t <trace-name>`, while `hvd_manager.py launch` creates the trace socket, detaches Emulator and the trace holder, then starts the runtime; launch now validates the emulator image root against the HVD `imageSubPath`, distinguishes the build SDK root from `~/Library/Huawei/Sdk`, and returns machine-readable diagnostics such as process exit code, log path, HDC snapshot, HVD runtime state, and stability checks on failures/timeouts; docs now include an attached terminal-scoped lifecycle checklist for binding terminal exit to `Emulator -stop` cleanup |
191+
| `Unreleased` | Added guarded DevEco Emulator CLI launch entries: `hvd_manager.py launch-preflight` only prints a command plan with `-t <trace-name>`, while `hvd_manager.py launch` creates the trace socket, detaches Emulator and the trace holder, then starts the runtime; launch now validates the emulator image root against the HVD `imageSubPath`, distinguishes the build SDK root from `~/Library/Huawei/Sdk`, and returns machine-readable diagnostics such as process exit code, log path, HDC snapshot, HVD runtime state, and stability checks on failures/timeouts; first-run license prompts are classified as `license-agreement-required` with an explicit `--accept-license` opt-in; docs now include an attached terminal-scoped lifecycle checklist for binding terminal exit to `Emulator -stop` cleanup |
192192
| `Unreleased` | Release assets now use `harmony-next.skill.zip`; the package includes `BUILD_INFO.json` with version, release tag, and git commit metadata, plus `ISSUE_GUIDE.md` for agent-led reproduction, redaction, classification, and issue filing |
193193
| `v1.3.6` | Added a non-interactive automation policy for the DevEco emulator playbook: users are assumed to have full authority and `policy` only means execution mode; supports `readonly/evidence/automation/diagnostic/break-glass`, artifact directories, redaction metadata, and machine-readable blocked output |
194194
| `v1.3.5` | Added a private, undocumented DevEco Studio IDE capability reference covering CodeGenie local RAG/MCP/LanceDB, `devecostudio://`, Previewer, ArkUI Inspector, Profiler, Doctor, UxTestService, plugin entry indexes, and privacy risk gates; updated README and trigger terms |
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Issue 17: Emulator first-run license agreement classification
2+
3+
GitHub issue #17 反馈:重装 DevEco Studio 后,`hvd_manager.py doctor --json` 可以报告环境健康,但首次执行 `hvd_manager.py launch` 时,HarmonyOS Emulator 会在 stdin 上要求确认华为许可协议。
4+
5+
原有实现会把该场景落到通用 `trace-timeout` / startup failure 诊断,agent 容易误判成 trace pipe、HDC 或镜像路径问题。
6+
7+
实现:
8+
9+
- `hvd_manager.py launch` 默认不自动同意协议。
10+
- Emulator stdout/stderr 日志尾部包含协议确认提示时,返回:
11+
12+
```json
13+
{
14+
"decision": "blocked",
15+
"result": "license-agreement-required",
16+
"missingConfig": ["emulatorLicenseAgreement"]
17+
}
18+
```
19+
20+
- 新增显式 opt-in 参数 `--accept-license`,只有传入该参数时才向 Emulator stdin 写入 `y\n`
21+
- `recommendations` 明确提示可以先交互式启动一次,或在阅读协议后显式传入 `--accept-license`
22+
23+
验证:
24+
25+
```bash
26+
python3 -m unittest harmony-next/tests/test_hvd_manager.py
27+
```
28+
29+
结果:
30+
31+
- `hvd_manager` 专项 21 个测试通过。
32+
- 新增 fake Emulator 覆盖默认分类和 `--accept-license` 显式确认两个分支。

harmony-next/SKILL.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: harmony-next
33
description: Use for HarmonyOS NEXT development help and local DevEco automation. Covers ArkTS/ArkUI/NDK API lookup, offline guide navigation, DevEco Studio and HarmonyOS Emulator tasks, hdc/uitest/aa/bm/hilog/hidumper diagnostics, and private DevEco interfaces such as CodeGenie, MCP, LanceDB, devecostudio://, ArkUI Inspector, Previewer, Profiler, Doctor, and UxTestService.
44
metadata:
5-
version: "1.3.7"
5+
version: "1.3.22"
66
---
77

88
# HarmonyOS NEXT Agent Guide
@@ -13,7 +13,7 @@ Paths like `references/...` are relative to this skill directory (`harmony-next/
1313

1414
## Version
1515

16-
Current local skill version: `v1.3.7`.
16+
Current local skill version: `v1.3.22`.
1717

1818
Reference snapshot: bundled `references/` are an offline HarmonyOS API 12-23 snapshot, not live web docs.
1919

@@ -126,13 +126,15 @@ HVD manager command map:
126126
| `list --json` | List registered HVDs without exposing UUIDs | `name`, `device_type`, `api_version`, `hdc_port`, `image_sub_path`, `exists` |
127127
| `launch-preflight --name <hvd> --image-root <dir> --trace-name <name> --trace-helper-ready-file <file> --json` | Validate trace helper readiness and image root without starting Emulator | `decision`, `missingConfig`, `emulatorCommand` |
128128
| `launch --name <hvd> --image-root <dir> --trace-name <name> --json` | Current implementation: create trace socket, detach Emulator and trace holder, then wait for HDC, boot, and stability | `traceHolder`, `hdcWait`, `bootWait`, `stabilityWait`, `logPath` |
129+
| `launch --accept-license ... --json` | Explicitly answer yes to the first-run Huawei Emulator agreement prompt after the operator has reviewed it | `result=started` or `result=license-agreement-required` |
129130

130131
HVD launch rules:
131132

132133
- `--sdk-root` / `DEVECO_SDK_HOME` is the DevEco build SDK root. Do not treat it as the emulator image root.
133134
- `--image-root` / `HARMONY_EMULATOR_IMAGE_ROOT` is the emulator image root. On macOS this is commonly `~/Library/Huawei/Sdk`.
134135
- `launch` and `launch-preflight` validate `<image-root>/<imageSubPath>` from HVD `config.ini`; failures return `missingConfig=["imageRootSystemImage"]`.
135136
- Current `launch` defaults: trace holder stays alive for 1800 seconds, and the post-boot stability check runs for 60 seconds.
137+
- First-run Emulator license/agreement prompts are classified as `result="license-agreement-required"` with `missingConfig=["emulatorLicenseAgreement"]`; do not silently accept them. Use `--accept-license` only as an explicit opt-in after the agreement has been reviewed.
136138
- If another process needs to install HAPs, deep link, screenshot, or dump layout after current detached `launch`, use the returned `hdcWait.target` and keep the trace holder alive long enough with `--trace-hold-seconds`.
137139
- Attached lifecycle checklist: the runner must stay foreground, keep the trace socket in-process, trap `SIGINT` / `SIGTERM` / `SIGHUP`, call `Emulator -stop`, close the socket, remove only its own trace path, and verify `hdc list targets -v` no longer reports the selected target.
138140
- Failure/timeout diagnostics should include `logPath`, `processExitCode`, `hvdRuntime`, `hdcSnapshot`, `hdcWait`, `bootWait`, and `stabilityWait` when present.
@@ -160,4 +162,4 @@ CodeGenie、MCP、LanceDB、HTTP forwarding、Application Agent、Operation Anal
160162
- **ArkUI 优先声明式**:示例优先使用 `@Entry` / `@Component` / `build()`(除非文档明确是 NDK 或系统服务)。
161163
- **遇到高频在线 guide 外链**:先查 `references/JsEtsAPIReference/guides/` 是否已有离线页;没有时优先按官方 `getDocumentById` 正文整理离线入口页,再接入映射,不要把链接硬改到不等价的 API 页。
162164

163-
<!-- version: 1.3.7 -->
165+
<!-- version: 1.3.22 -->

0 commit comments

Comments
 (0)