成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

HarmonyOS - HDC命令與ADB命令使用對比

系統 OpenHarmony
HDC,即HarmonyOS Device Connector,是HarmonyOS為開發人員提供的用于調試的命令行工具,通過該工具可以在windows/linux/mac系統上與真實設備或者模擬器進行交互。

??想了解更多關于開源的內容,請訪問:??

??51CTO 開源基礎軟件社區??

??https://ost.51cto.com??

前言

作為多年Android習慣使用ADB命令,對于HarmonyOS HDC命令如何使用?兩者之間區別及原子化服務開發過程中HDC命令與ADB命令使用技巧,請移步下文講解。

一、HDC與ADB介紹

HDC介紹

HDC,即HarmonyOS Device Connector,是HarmonyOS為開發人員提供的用于調試的命令行工具,通過該工具可以在windows/linux/mac系統上與真實設備或者模擬器進行交互。

HDC通過HarmonyOS SDK獲取,存放于sdk的toolchains目錄下,使用時將sdk的toolchains目錄添加到環境變量。

  • 通過hdc -help查看hdc命令總表。
C:\Users\lsyt>hdc -help
Usage: hdc [options] <command> [arguments]
Options:
-t UTID Specify the target device with UTID(unique target id)
-s SOCKSPEC Specify the socket to bind for server
-h Display this usage info
-v Display the version info
Commands:
list targets [-v] List the connected targets, use -v option to get
more details
help Display this usage info
version Display the version info
tmode <usb|port PORT> Set the daemon working mode to usb or tcp port
tconn HOST[:PORT] [-remove] Connect to the target which is working under tcp port mode.
Remove the connection if the -remove option is specified.
fport list [-b] List the relayed connections, use -b option for backward mode.
fport LOCAL REMOTE [-b] Relay socket LOCAL to REMOTE
socket can be specified as the list below:
tcp:PORT use tcp port
jdwp:<process pid> (for REMOTE only)
fport rm [LOCAL] [-b] Remove the given LOCAL socket connection,
remove all if no LOCAL argument
file send LOCAL... REMOTE
Copy LOCAL files to target under REMOTE directory
file recv REMOTE... LOCAL
Copy REMOTE files to LOCAL directory
file sync [all|data|...|system|vendor]
Sync files from local location to the target.
shell [-nTtx] [COMMAND...]
Start a shell and run COMMAND under the target
-n: do not read from stdin
-T: disable pseudo-terminal utiity(PTY) allocation
-t: force PTY allocation
-x: disable remote exit codes and stdout/stderr separation
app install [-rdg] PACKAGE
Install the given application PACKAGE to the target
-r: Replace existing application
-d: Allow version downgrade (debug compatible only)
-g: Grant all the permissions
app install-multiple [-rdg] PACKAGE1 [...PACKAGEn]
app install-multiple --hap HAP-PATH (for HAPs only)
Install multiple HAPs(/APKs) of one PACKAGE to the target.
the following options are for APKs only:
-r: Replace existing application
-d: Allow version downgrade (debug compatible only)
-g: Grant all the permissions
the option --hap is for HAPs only:
--hap: Indicate the .hap files to be installed are located under HAP-PATH dir.
app uninstall [-k] PACKAGE
Uninstall the PACKAGE app from the target
-k: Do not remove user data
listpid Display debuggable application processes list
hilog Tail the logs from the target
target mount
Mount the partitions in read-write mode
target boot
Boot the target; to see the targets list, try list targets command
smode [off] Grant the daemon root permissions, to revoke with the off argument
kill Kill the buddy process
reset Reset the connections to target

ADB介紹

ADB,即 Android Debug Bridge,是一種功能多樣的命令行工具,可讓您與設備進行通信。adb 命令可用于執行各種設備操作(例如安裝和調試應用),并提供對 Unix shell(可用來在設備上運行各種命令)的訪問權限。它是一種客戶端-服務器程序,包括以下三個組件:

  • 客戶端:用于發送命令。客戶端在開發機器上運行。您可以通過發出 adb 命令從命令行終端調用客戶端。
  • 守護程序 (adbd):用于在設備上運行命令。守護程序在每個設備上作為后臺進程運行。
  • 服務器:用于管理客戶端與守護程序之間的通信。服務器在開發機器上作為后臺進程運行。

adb 包含在 Android SDK 平臺工具軟件包中。您可以使用 ??SDK 管理器??下載此軟件包,該管理器會將其安裝在 android_sdk/platform-tools/ 下。或者,如果您需要獨立的 Android SDK 平臺工具軟件包,也可以??點擊此處進行下載??。

  • 通過adb -help查看hdc命令總表。
C:\Users\lsyt>adb --help
Android Debug Bridge version 1.0.41
Version 31.0.3-7562133
Installed as C:\DATA\AndroidSdk\platform-tools_r31.0.3-windows\platform-tools\adb.exe
global options:
-a listen on all network interfaces, not just localhost
-d use USB device (error if multiple devices connected)
-e use TCP/IP device (error if multiple TCP/IP devices available)
-s SERIAL use device with given serial (overrides $ANDROID_SERIAL)
-t ID use device with given transport id
-H name of adb server host [default=localhost]
-P port of adb server [default=5037]
-L SOCKET listen on given socket for adb server [default=tcp:localhost:5037]
general commands:
devices [-l] list connected devices (-l for long output)
help show this help message
version show version num
networking:
connect HOST[:PORT] connect to a device via TCP/IP [default port=5555]
disconnect [HOST[:PORT]]
disconnect from given TCP/IP device [default port=5555], or all
pair HOST[:PORT] [PAIRING CODE]
pair with a device for secure TCP/IP communication
forward --list list all forward socket connections
forward [--no-rebind] LOCAL REMOTE
forward socket connection using:
tcp:<port> (<local> may be "tcp:0" to pick any open port)
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
dev:<character device name>
jdwp:<process pid> (remote only)
vsock:<CID>:<port> (remote only)
acceptfd:<fd> (listen only)
forward --remove LOCAL remove specific forward socket connection
forward --remove-all remove all forward socket connections
ppp TTY [PARAMETER...] run PPP over USB
reverse --list list all reverse socket connections from device
reverse [--no-rebind] REMOTE LOCAL
reverse socket connection using:
tcp:<port> (<remote> may be "tcp:0" to pick any open port)
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
reverse --remove REMOTE remove specific reverse socket connection
reverse --remove-all remove all reverse socket connections from device
mdns check check if mdns discovery is available
mdns services list all discovered services
file transfer:
push [--sync] [-z ALGORITHM] [-Z] LOCAL... REMOTE
copy local files/directories to device
--sync: only push files that are newer on the host than the device
-n: dry run: push files to device without storing to the filesystem
-z: enable compression with a specified algorithm (any, none, brotli)
-Z: disable compression
pull [-a] [-z ALGORITHM] [-Z] REMOTE... LOCAL
copy files/dirs from device
-a: preserve file timestamp and mode
-z: enable compression with a specified algorithm (any, none, brotli)
-Z: disable compression
sync [-l] [-z ALGORITHM] [-Z] [all|data|odm|oem|product|system|system_ext|vendor]
sync a local build from $ANDROID_PRODUCT_OUT to the device (default all)
-n: dry run: push files to device without storing to the filesystem
-l: list files that would be copied, but don't copy them
-z: enable compression with a specified algorithm (any, none, brotli)
-Z: disable compression
shell:
shell [-e ESCAPE] [-n] [-Tt] [-x] [COMMAND...]
run remote shell command (interactive shell if no command given)
-e: choose escape character, or "none"; default '~'
-n: don't read from stdin
-T: disable pty allocation
-t: allocate a pty if on a tty (-tt: force pty allocation)
-x: disable remote exit codes and stdout/stderr separation
emu COMMAND run emulator console command
app installation (see also `adb shell cmd package help`):
install [-lrtsdg] [--instant] PACKAGE
push a single package to the device and install it
install-multiple [-lrtsdpg] [--instant] PACKAGE...
push multiple APKs to the device for a single package and install them
install-multi-package [-lrtsdpg] [--instant] PACKAGE...
push one or more packages to the device and install them atomically
-r: replace existing application
-t: allow test packages
-d: allow version code downgrade (debuggable packages only)
-p: partial application install (install-multiple only)
-g: grant all runtime permissions
--abi ABI: override platform's default ABI
--instant: cause the app to be installed as an ephemeral install app
--no-streaming: always push APK to device and invoke Package Manager as separate steps
--streaming: force streaming APK directly into Package Manager
--fastdeploy: use fast deploy
--no-fastdeploy: prevent use of fast deploy
--force-agent: force update of deployment agent when using fast deploy
--date-check-agent: update deployment agent when local version is newer and using fast deploy
--version-check-agent: update deployment agent when local version has different version code and using fast deploy
(See also `adb shell pm help` for more options.)
uninstall [-k] PACKAGE
remove this app package from the device
'-k': keep the data and cache directories
debugging:
bugreport [PATH]
write bugreport to given PATH [default=bugreport.zip];
if PATH is a directory, the bug report is saved in that directory.
devices that don't support zipped bug reports output to stdout.
jdwp list pids of processes hosting a JDWP transport
logcat show device log (logcat --help for more)
security:
disable-verity disable dm-verity checking on userdebug builds
enable-verity re-enable dm-verity checking on userdebug builds
keygen FILE
generate adb public/private key; private key stored in FILE,
scripting:
wait-for[-TRANSPORT]-STATE...
wait for device to be in a given state
STATE: device, recovery, rescue, sideload, bootloader, or disconnect
TRANSPORT: usb, local, or any [default=any]
get-state print offline | bootloader | device
get-serialno print <serial-number>
get-devpath print <device-path>
remount [-R]
remount partitions read-write. if a reboot is required, -R will
will automatically reboot the device.
reboot [bootloader|recovery|sideload|sideload-auto-reboot]
reboot the device; defaults to booting system image but
supports bootloader and recovery too. sideload reboots
into recovery and automatically starts sideload mode,
sideload-auto-reboot is the same but reboots after sideloading.
sideload OTAPACKAGE sideload the given full OTA package
root restart adbd with root permissions
unroot restart adbd without root permissions
usb restart adbd listening on USB
tcpip PORT restart adbd listening on TCP on PORT
internal debugging:
start-server ensure that there is a server running
kill-server kill the server if it is running
reconnect kick connection from host side to force reconnect
reconnect device kick connection from device side to force reconnect
reconnect offline reset offline/unauthorized devices to force reconnect
usb:
attach attach a detached USB device
detach detach from a USB device to allow use by other processes
environment variables:
$ADB_TRACE
comma-separated list of debug info to log:
all,adb,sockets,packets,rwx,usb,sync,sysdeps,transport,jdwp
$ADB_VENDOR_KEYS colon-separated list of keys (files or directories)
$ANDROID_SERIAL serial number to connect to (see -s)
$ANDROID_LOG_TAGS tags to be used by logcat (see logcat --help)
$ADB_LOCAL_TRANSPORT_MAX_PORT max emulator scan port (default 5585, 16 emus)
$ADB_MDNS_AUTO_CONNECT comma-separated list of mdns services to allow auto-connect (default adb-tls-connect)

二、HDC與ADB常用命令對比

HDC

ADB

說明

hdc -h

adb --help

查看幫助

hdc -v

adb --version

查看版本

hdc list targets

adb devices

查看連接設備

hdc kill

adb kill-server

結束服務

hdc kill -r

adb start-server

啟動服務

hdc app install [安裝包路徑]

adb install [安裝包路徑]

安裝應用

hdc app uninstall package

adb uninstall package

卸載應用

hdc hilog

adb logcat

抓取log

hdc shell hilogcat >log.log

adb shell logcat >log.log

抓取log并保存

hdc shell reboot

adb reboot

重啟設備

hdc shell bm get -u

adb shell bm get -u

獲取UUID

hdc file recv REMOTE… LOCAL

adb pull REMOTE… LOCAL

接收文件<br />REMOTE:手機<br />LOCAL:PC

hdc file send LOCAL… REMOTE

adb push LOCAL… REMOTE

發送文件

hdc shell screencap filename

adb shell screencap filename

截屏

hdc shell screenrecord filename

adb shell screenrecord filename

錄屏

三、日常開發常用命令

日常FA開發中以上命令的使用對于前端同學來說比較陌生,命令不容易記住。如:獲取UUID,命令記不住需要往期的賦能資料,最終才能獲取到UUID。針對命令記不住的問題可通過提供簡單腳本的方式,提供給前端使用。

注意:HDC服務和ADB服務不能共存。在執行腳本時,如果獲取的數據為空,則需要確認手機設備使用的是hdc命令還是ADB服務。
確認方式:通過hdc list targets命令獲取設備列表,如果獲取到設備列表則當前使用的為hdc服務,否則為adb服務。可通過adb kill-server結束adb服務,再通過usb連接設備,使用hdc list targets命令獲取設備列表,如果獲取到列表則表示當前服務使用的是hdc服務。如下圖操作:

#夏日挑戰賽# HarmonyOS - HDC命令與ADB命令使用對比-開源基礎軟件社區

(1)獲取UUID

腳本:uid.bat 已放置于下方資源處,如有需要自行下載。

hdc shell bm get -u > uuid.log

將該指令生成uuid.bat腳本,通過腳本獲取設備UUID。

#夏日挑戰賽# HarmonyOS - HDC命令與ADB命令使用對比-開源基礎軟件社區

(2)獲取hilog日志

腳本:hilog.bat 已放置于下方資源處,如有需要自行下載。

hdc hilog

#夏日挑戰賽# HarmonyOS - HDC命令與ADB命令使用對比-開源基礎軟件社區

(3)抓取log并保存

腳本:hilogs.bat 已放置于下方資源處,如有需要自行下載。

hdc shell hilogcat >log.log

總結

  • HDC命令及ADB命令都可以通過腳本方式獲取或查看對應數據。
  • 前端同學可按需自己編寫腳本獲取自己所需數據。

??想了解更多關于開源的內容,請訪問:??

??51CTO 開源基礎軟件社區??

??https://ost.51cto.com??。

責任編輯:jianghua 來源: 鴻蒙社區
相關推薦

2013-07-03 10:19:52

Android開發adb shell命令

2010-01-27 10:07:11

Android adb

2017-09-10 16:41:32

ADB命令程序員

2016-12-07 18:42:31

Androidadb shell命令

2012-05-10 08:55:11

Linuxuniq

2009-12-25 16:27:25

Linux命令

2024-03-26 15:21:43

2010-04-28 10:04:15

unixware

2009-08-03 12:02:13

linux at命令linux at命令詳使用案例

2023-04-05 08:33:10

2013-02-21 17:54:12

PowerShell入PowerShell命

2011-02-18 10:19:47

SELinux命令管理

2011-03-15 15:47:25

iptables安裝命令

2010-07-16 09:32:14

Telnet服務

2011-04-01 17:16:03

zabbix參數命令

2019-11-25 15:46:11

LinuxVim命令

2010-02-03 16:53:58

CentOS yum

2010-03-05 15:05:46

Ubuntu網絡配置

2012-05-09 10:52:37

Linux監控命令

2010-09-02 15:42:37

echo命令
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 成人午夜影院 | 黄色片免费看视频 | 91精品www | 久久精品中文字幕 | 国产精品久久久久久久久久 | 亚洲一区二区三区在线视频 | 国产精品一区二区在线免费观看 | 亚洲日本欧美日韩高观看 | 国产乱码精品一区二区三区五月婷 | 国产成人精品免费视频大全最热 | 国产成人叼嘿视频在线观看 | 国产传媒在线播放 | 久久亚洲天堂 | 久久免费电影 | 亚洲视频中文 | 天天看夜夜 | 亚洲不卡视频 | 日韩伦理一区二区 | 91久色 | 午夜在线精品偷拍 | 欧美色影院 | 国产精品久久久久久久免费大片 | 久久久久国产精品一区二区 | 天天干天天插天天 | 女同久久另类99精品国产 | 亚洲精品国产电影 | 国产一区二区三区在线视频 | 国产精品一区二区在线 | 最新中文字幕 | 青青久在线视频 | 欧美a∨| 欧美成人一区二免费视频软件 | 精品一区二区三区在线观看国产 | 欧美 日韩精品 | 亚洲成人动漫在线观看 | 综合久久久久 | 精品欧美一区二区三区免费观看 | 日韩欧美三级电影 | 在线日韩精品视频 | 午夜精品| 国产欧美日韩精品在线观看 |