mcpField
H
harmony-hdc

harmony-hdc

github.com/httprunnerテスト・品質236 回インストール35 週間前に更新
リポジトリ

harmony-hdc について

Harmony HDCは、HarmonyOSデバイスをraw hdcコマンドで操作するためのリファレンススキルで、デバイスのテストやデバッグに向けたものです。接続、アプリ管理、入力、スクリーンショット、UIツリー取得、ファイル転送を扱い、対象選択と実行前確認も示します。

主な機能

  1. 01デバイスへの接続と状態確認
  2. 02アプリの起動と管理
  3. 03タップ、長押し、テキスト入力
  4. 04スクリーンショットとUIツリーの取得
  5. 05デバイスとのファイル転送

活用シーン

  1. 01HarmonyOSデバイス情報と画面サイズの確認
  2. 02アプリを起動して画面を操作
  3. 03確認用スクリーンショットとUIレイアウトの取得
  4. 04デバイスとローカル間のファイル転送

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/httprunner/skills --skill harmony-hdc

インストール後、Claude Code で/harmony-hdcを入力して読み込まれたか確認します。

詳細

Harmony HDC

HarmonyOS デバイスを生の hdc コマンドで制御するためのリファレンスです。

実行時の制約

  • 複数のデバイスが接続されている場合は、hdc -t <device_id> を使用してください。
  • 座標を指定する操作の前に、画面解像度を確認してください:hdc -t DEVICE shell wm size。
  • 実行に必要な情報(デバイス ID、バンドル/アビリティ、座標、ファイルパス)が不足している場合は、実行前に確認してください。
  • 失敗した場合は、対処に役立つ stderr の内容を提示してください(認証、ケーブル/ネットワーク、tcp モード)。

デバイスとサーバー

# Start HDC server
hdc start

# Stop HDC server
hdc kill

# List targets
hdc list targets

# Target a specific device
hdc -t DEVICE <command>

接続

# Connect over TCP
hdc tconn <ip>:<port>

# Disconnect target
hdc -t DEVICE tdis

デバイスの状態

# Device model/system info
hdc -t DEVICE shell param get const.product.model
hdc -t DEVICE shell param get const.ohos.fullname

# Screen size
hdc -t DEVICE shell wm size

# Foreground focus window
hdc -t DEVICE shell hidumper -s WindowManagerService -a '-a'

# Run raw shell command
hdc -t DEVICE shell <command>

アプリのライフサイクル

# List installed bundles
hdc -t DEVICE shell bm dump -a

# Start an ability
hdc -t DEVICE shell aa start -a <ability_name> -b <bundle_name>

# Start by URI
hdc -t DEVICE shell aa start -U <uri>

# Force-stop app by bundle
hdc -t DEVICE shell aa force-stop <bundle_name>

入力操作

# Tap
hdc -t DEVICE shell uitest uiInput click X Y

# Double tap
hdc -t DEVICE shell uitest uiInput click X Y && sleep 0.1 && hdc -t DEVICE shell uitest uiInput click X Y

# Long press
hdc -t DEVICE shell uitest uiInput longClick X Y

# Swipe
hdc -t DEVICE shell uitest uiInput swipe X1 Y1 X2 Y2 [duration_ms]

# Key event
hdc -t DEVICE shell uitest uiInput keyEvent Back
hdc -t DEVICE shell uitest uiInput keyEvent Home
hdc -t DEVICE shell uitest uiInput keyEvent Enter

テキスト入力

# Text input (Harmony text input supports UTF-8)
hdc -t DEVICE shell uitest uiInput inputText "hello world"

スクリーンショットと UI ダンプ

# Capture screenshot on device
hdc -t DEVICE shell snapshot_display -f /data/local/tmp/screen.jpeg

# Pull screenshot to local
hdc -t DEVICE file recv /data/local/tmp/screen.jpeg ./screen.jpeg

# Dump UI tree (JSON)
hdc -t DEVICE shell uitest dumpLayout -p /data/local/tmp/layout.json
hdc -t DEVICE file recv /data/local/tmp/layout.json ./layout.json

ファイル転送

# Push file to device
hdc -t DEVICE file send ./local.file /data/local/tmp/remote.file

# Pull file from device
hdc -t DEVICE file recv /data/local/tmp/remote.file ./remote.file

アプリのインストールとアンインストール

# Install HAP
hdc -t DEVICE install /path/to/app.hap

# Install with replace
hdc -t DEVICE install -r /path/to/app.hap

# Uninstall by bundle
hdc -t DEVICE uninstall <bundle_name>

一般的な KeyEvent

KeyEvent説明
Back戻るボタン
Homeホームボタン
Enter入力/確定
Power電源ボタン
VolumeUp音量を上げる
VolumeDown音量を下げる

コメント