前言:(时间紧迫就别看前言了)hdc_std是OpenHarmony 的命令行工具。因为我们的鸿蒙系统没有应用商店、没有浏览器、不能外接usb设备以及打不开文件资源管理器,所以接触了hdc_std。
环境:Windows10电脑 工具:usb连接线、鸿蒙系统测试机
一、环境安装配置
1.新建一个文件夹并命名,作为存放hdc_std的路径,把.exe文件放到新建的文件夹中。
2.回到桌面,右击“此电脑”->点“属性”,点击高级系统设置,然后点环境变量。
3.在系统变量中找到Path,然后点编辑按钮。
4.把hdc_std.exe的路径复制一下,在编辑环境变量页面点“新建”,把路径粘贴到左侧,如图。
5.打开命令提示符(cmd),输入:hdc_std -v,如下图有版本号则成功。
二、常用命令(电脑USB已连接设备)
hdc_std start #启动hdc_std
hdc_std kill #关闭hdc_std
hdc_std start -r #重新启动hdc服务进程
hdc_std target boot #重启设备
hdc_std -h #查看帮助
OpenHarmony device connector(HDC) ...
---------------------------------global commands:----------------------------------
-h/help - Print hdc help
-v/version - Print hdc version
-l 0-5 - Set runtime loglevel
-t connectkey - Use device with given connect key
---------------------------------component commands:-------------------------------
session commands(on server):
discover - Discover devices listening on TCP via LAN broadcast
list targets [-v] - List all devices status, -v for detail
tconn key - Connect device via key, TCP use ip:port
example:192.168.0.100:10178/192.168.0.100
USB connect automatic, TCP need to connect manually
start [-r] - Start server. If with '-r', will be restart server
kill [-r] - Kill server. If with '-r', will be restart server
-s [ip:]port - Set hdc server listen config
service commands(on daemon):
target mount - Set /system /vendor partition read-write
target boot [-bootloader|-recovery] - Reboot the device or boot into bootloader\recovery.
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
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:
localfilesystem:
localreserved:
localabstract:
dev:
jdwp: (remote only)
fport ls - Dispaly forward/reverse tasks
fport rm taskstr - Remove forward/reverse task by taskstring
app commands:
install [-rdg] src - Send package(s) to device and install them
src examples: single or multiple packages and directories
(.hap)
-r: replace existing application
-d: allow version code downgrade
-g: grant all the permissions
uninstall [-k] package - Remove application package from device
-k: keep the data and cache directories
debug commands:
hilog [-v] - Show device log, -v for detail
shell [COMMAND...] - Run shell command (interactive shell if no command given)
bugreport [PATH] - Return all information from the device, path will be save localpath
jpid - List pids of processes hosting a JDWP transport
sideload [PATH] - Sideload the given full OTA package
security commands:
keygen FILE - Generate public/private key; key stored in FILE and FILE.pub
hdc_std shell #进入命令行交互环境
hdc_std list targets #查看已连接设备
hdc_std list targets -v #查看连接设备的详细信息
hdc_std shell param get #查看设备信息
hdc_std target mount #获取读写权限
hdc_std shell param set persist.multimedia.audio.mediavolume = 1 #设置机器的声音大小,默认值是15
hdc_std file send [D:\本地路径] [/data/设备路径] #发送文件到设备
hdc_std file recv [/data/设备路径] [D:\本地路径] #获取文件到本地
hdc_std shell chromd *** #修改文件权限
hdc_std shell hilog #查看日志
hdc_std shell ps -ef #查看进程
hdc_std app install -r [HAP包路径] #递归当前目录安装HAP包(安装包在电脑上)
hdc_std shell bm install -p /data/entry-default-signed.hap #HAP包推送到手机中,手动安装HAP包(安装包在手机上)
hdc_std uninstall [安装包名称] #卸载HAP包
hdc_std shell bm uninstall -n [安装包名称] #卸载HAP包
hdc_std shell aa start ability -a InputMethod -b cn.openharmony.inputmethodchoosedialog #切换输入法。在屏幕上选择想要的输入法
ifconfig #查看设备的ip等信息
ifconfig eth0 up
ifconfig eth0 192.168.1.7 netmask 255.255.255.0 broadcast 192.168.1.255 #设置ip地址、网关和子网掩码
ping IP地址 #测试地址是否可用