鸿蒙-HDC 常用命令

DevEco Studio 版本:DevEco Studio NEXT Developer Preview2(4.1.3.700)
HarmonyOS API 版本:4.1.0(11)

HDC 常用命令

0x01 全局相关命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 显示hdc相关的帮助信息
hdc -h

# 显示hdc的版本信息
hdc -v

# 获取OTA系统版本号
hdc shell param get const.product.software.version

# 获取序列号(获取设备信息)
# 查询已连接的所有目标设备,添加-v选项,则会打印设备详细信息。
hdc list targets

# 交互命令,COMMAND表示需要执行的单次命令。不同类型或版本的系统支持的COMMAND命令有所差异,可以通过hdc shell ls /system/bin查阅支持的命令列表。
hdc shell
hdc shell ps -ef
hdc shell help -a // 查询全部可用命令

0x02 服务进程相关命令

1
2
3
4
5
6
7
8
# 重启目标设备,查看目标列表可用list targets命令。
hdc target boot

# 终止hdc服务进程,使用-r参数触发服务进程重新启动。
hdc kill [-r]

# 启动hdc服务进程,使用-r参数触发服务进程重新启动。
hdc start [-r]

0x03 文件相关命令

1
2
3
4
5
6
# 从本地发送文件至远端设备。
hdc file send E:\example.txt /data/local/tmp/example.txt

# 从远端设备发送文件至本地。
hdc file recv /data/local/tmp/a.txt ./a.txt

0x04 应用相关命令

1
2
3
4
5
6
7
8
9
# 安装指定的应用package文件。
hdc install -r E:\com.example.hello.hap

# 卸载指定的应用包package包名。
hdc uninstall com.example.hello

# 显示可调试应用列表。
hdc jpid

hdc help

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
                        OpenHarmony device connector(HDC) ...

---------------------------------global commands:----------------------------------
-h/help [verbose] - Print hdc help, 'verbose' for more other cmds
-v/version - Print hdc version
-t connectkey - Use device with given connect key

---------------------------------component commands:-------------------------------
session commands(on server):
list targets [-v] - List all devices status, -v for detail
start [-r] - Start server. If with '-r', will be restart server
kill [-r] - Kill server. If with '-r', will be restart server

service commands(on daemon):
target mount - Set /system /vendor partition read-write
target boot [-bootloader|-recovery] - Reboot the device or boot into bootloader\recovery.
target boot [MODE] - Reboot the into MODE.
smode [-r] - Restart daemon with root permissions, '-r' to cancel root
permissions
tmode usb - Reboot the device, listening on USB
tmode port [port] - Reboot the device, listening on TCP port

---------------------------------task commands:-------------------------------------
file commands:
file send [option] local remote - Send file to device
file recv [option] remote local - Recv file from device
option is -a|-s|-z
-a: hold target file timestamp
-sync: just update newer file
-z: compress transfer
-m: mode sync

forward commands:
fport localnode remotenode - Forward local traffic to remote device
rport remotenode localnode - Reserve remote traffic to local host
node config name format 'schema:content'
examples are below:
tcp:<port>
localfilesystem:<unix domain socket name>
localreserved:<unix domain socket name>
localabstract:<unix domain socket name>
dev:<device name>
jdwp:<pid> (remote only)
fport ls - Display forward/reverse tasks
fport rm taskstr - Remove forward/reverse task by taskstring

app commands:
install [-r|-s] src - Send package(s) to device and install them
src examples: single or multiple packages and directories
(.hap .hsp)
-r: replace existing application
-s: install shared bundle for multi-apps
uninstall [-k] [-s] package - Remove application package from device
-k: keep the data and cache directories
-s: remove shared bundle

debug commands:
hilog [-h] - Show device log, -h for detail
shell [COMMAND...] - Run shell command (interactive shell if no command given)
bugreport [FILE] - Return all information from the device, stored in file if FILE is specified
jpid - List pids of processes hosting a JDWP transport

security commands:
keygen FILE - Generate public/private key; key stored in FILE and FILE.pub

参考

HarmonyOS NEXT Developer:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/hdc-V5

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×