DEV Community

HarmonyOS
HarmonyOS

Posted on

HDC Command Commands

Read the original article:HDC Command Commands

HDC Common Commands

Summary:

HDC (Huawei Device Connect) commands provide a comprehensive set of tools for managing Huawei devices, performing application testing, and troubleshooting. These commands enable developers and device managers to perform essential tasks such as checking device connections, installing or uninstalling apps, viewing and clearing logs, transferring files, and retrieving system information like power status and device model. Additionally, HDC commands facilitate debugging by allowing the viewing of process details, controlling device power settings, and simulating button presses. You can see the most common hdc commands below.

Question:

What are some common HDC (Huawei Device Connect) commands and their usage?

Short Answer:

  1. Check device connection: hdc list targets
  2. Specify connected device: hdc -t < device number >
  3. Install application: hdc app install
  4. Uninstall application: hdc app uninstall < application package name >
  5. Start application: hdc shell aa start -a -b < application package name >
  6. Stop application: hdc shell aa force-stop < application package name >
  7. Push file: hdc file send < file path ( PC ) > < target path >
  8. Pull file: hdc file recv < file path > < target path ( PC ) >
  9. Delete folder: hdc shell rm -rf < file path >
  10. Get read and write permissions: hdc shell mount -o rw,remount /
  11. Get device udid: hdc shell bm get -u
  12. View log: hdc hilog
  13. Clear cache log: hdc shell hilog -r
  14. Restart the device: hdc shell reboot (or hdc target boot )
  15. Clear application cache: hdc shell bm clean -n < application package name > -c
  16. Clear application data: hdc shell bm clean -n < application package name > -d
  17. Check the device system version (combination package version number): hdc shell param get const.product.software.version
  18. Check the device model: hdc shell param get const.product.model
  19. Check the device SN number: hdc shell param get ohos.boot.sn
  20. Check the device type (the folding screen will also display phone ): hdc shell param get const.product.devicetype
  21. Check the physical version number of the base package: hdc shell param get const.comp.hl.product_base_version.real
  22. Check the physical version number of the pre-installed package: hdc shell param get const.comp.hl.product_preload_version.real
  23. View the physical version number of the customized package: hdc shell param get const.comp.hl.product_cust_version.real
  24. View the application configuration information: hdc shell bm dump -n < application package name >
  25. View the package names of all applications on the device: hdc shell bm dump -a
  26. View vendor: hdc shell param get const.cust.vendor
  27. View region: hdc shell param get const.cust.region
  28. View the current task stack information: hdc shell aa dump -l
  29. View the process: hdc shell ps -ef | findstr
  30. Kill the process: hdc shell kill -9 < process id>
  31. Kill hdc: hdc kill
  32. Restart hdc: hdc start -r
  33. Wait for the device to connect: hdc wait-for-device
  34. Press the power button: hdc shell uinput -K -d 18 -u 18
  35. Press the home button: hdc shell uinput -K -d 1 -u 1
  36. Press the return key: hdc shell uinput -K -d 2 -u 2
  37. Turn on the border information switch of all components on the page: hdc shell param set persist.ace.debug.boundary.enabled true
  38. Turn off the border information switch of all components on the page: hdc shell param set persist.ace.debug.boundary.enabled false
  39. Click coordinates: hdc shell uinput -T -dx,y,-u,x,y
  40. Get the installation path according to the application package name: hdc shell "bm dump -n < application package name > | grep -i hapPath | tail -n 1"

  41. Get the version number according to the application package name: hdc shell "bm dump -n < application package name > | grep -i versionName | tail -n 1"

  42. Query the current power: hdc shell cat /sys/class/power_supply/Battery/capacity

  43. Get the current application package name: hdc shell "aa dump -l | grep bundle | tail -n 1"

  44. Set the device to never turn off the screen: hdc shell power-shell setmode 602

  45. Reboot to enter fastboot mode: hdc shell reboot bootloader

  46. Query all system application paths: hdc shell find /system/app/ -name *.hap

  47. Query all pre-installed application paths: hdc shell find /preload/app/ -name *.hap >>BundlePath.txt

  48. Export Hilog log: hdc file recv /data/log/hilog < target path >

  49. Get help: hdc help

Applicable Scenarios:

  • Device Management: Useful for managing connected Huawei devices, including checking connections, installing/uninstalling apps, or restarting devices.
  • Application Testing: For developers testing Huawei apps, commands for starting, stopping, and clearing app data or logs can be essential.
  • File Transfer: Commands for pushing and pulling files between a PC and the connected Huawei device.
  • Debugging: Viewing logs or checking system status (e.g., power, system version) to troubleshoot device issues.

Written by Merve Yonetci

Top comments (0)