
版本信息:Installedasc:\tmp\fastboot\一、globaloptions:(全局选项)-alistenonallnetworkinterfaces,notjustlocalhos......
版本信息:
Installedasc:\tmp\fastboot\
一、globaloptions:(全局选项)
-alistenonallnetworkinterfaces,notjustlocalhost
-duseUSBdevice(errorifmultipledevicesconnected)
-euseTCP/IPdevice(errorifmultipleTCP/IPdevicesavailable)
-sSERIALusedevicewithgivenserial(overrides$ANDROID_SERIAL)
-tIDusedevicewithgiventransportid
-Hnameofadbserverhost[default=localhost]有多台设备时指定连哪一台
-Pportofadbserver[default=5037]指定连接端口
-LSOCKETlistenongivensocketforadbserver[default=tcp:localhost:5037]
二、generalcommands:(常用命令)
devices[-l]listconnecteddevices(-lforlongoutput)
查看连接的设备,显示出设备号和状态。当设备处于正常连接、bootloader、recovery、sideload时,状态对应为:device/fastboot/recovery/sideload。unauthorized是设备端未授权。
c:\tmp\fastbootadbdevicesListofdevicesattachedZHP7UCQCFUKNEMBQdevice
helpshowthishelpmessage
versionshowversionnum显示当前adb的版本
c:\tmp\:\tmp\fastboot\
三、networking:(网络功能)
connectHOST[:PORT]connecttoadeviceviaTCP/IP(设备与电脑同一局域网)
通过网络连接设备,默认端口是:5555
c:\tmp\:5555:由于目标计算机积极拒绝,无法连接。(10061)
disconnect[[HOST]:PORT]disconnectfromgivenTCP/IPdevice,orall
forward--listlistallforwardsocketconnections
forward[--no-rebind]LOCALREMOTE
forwardsocketconnectionusing:
tcp:port(localmaybe"tcp:0"topickanyopenport)
localabstract:unixdomainsocketname
localreserved:unixdomainsocketname
localfilesystem:unixdomainsocketname
dev:characterdevicename
jdwp:processpid(remoteonly)
forward--removeLOCALremovespecificforwardsocketconnection
forward--remove-allremoveallforwardsocketconnections
pppTTY[PARAMETER]runPPPoverUSB
reverse--listlistallreversesocketconnectionsfromdevice
reverse[--no-rebind]REMOTELOCAL
reversesocketconnectionusing:
tcp:port(remotemaybe"tcp:0"topickanyopenport)
localabstract:unixdomainsocketname
localreserved:unixdomainsocketname
localfilesystem:unixdomainsocketname
reverse--removeREMOTEremovespecificreversesocketconnection
reverse--remove-allremoveallreversesocketconnectionsfromdevice
四、filetransfer:(文件传输功能)
push[--sync]LOCALREMOTE将电脑上的文件传到设备上
copylocalfiles/directoriestodevice
--sync:onlypushfilesthatareneweronthehostthanthedevice
c:\tmp\fastbootadbpushc:/tmp//sdcard/c:/tmp/:1/s(752250)
pull[-a]REMOTELOCAL将设备上的文件下载到电脑上
copyfiles/dirsfromdevice
-a:preservefiletimestampandmode
adbpull/sdcard/:/tmp/
sync[all|data|odm|oem|product|system|system_ext|vor]
syncalocalbuildfrom$ANDROID_PRODUCT_OUTtothedevice(defaultall)
-l:listfilesthatwouldbecopied,butdon'tcopythem
五、shell:(shell功能)
shell[-eESCAPE][-n][-Tt][-x][COMMAND]
runremoteshellcommand(interactiveshellifnocommandgiven)
-e:chooseescapecharacter,or"none";default'~'
-n:don'treadfromstdin
-T:disablePTYallocation
-t:forcePTYallocation
-x:disableremoteexitcodesandstdout/stderrseparation
进入shell命令模式或直接执行sh命令:
c:\tmp\fastbootadbshellshell@bbk82_wet_jb5:/$c:\tmp\fastbootadbshellls-l/system/drwxrwxrwxrootroot2022-02-1920:07appdrwxr-xr-xrootshell2022-02-2409:53bin-rw-r--r--rootroot42892015-03-1011:55:00:00etcdrwxr-xr-xrootroot2008-08-0120:00fonts
emuCOMMANDrunemulatorconsolecommand
六、appinstallation(seealso`adbshellcmdpackagehelp`):(应用安装)
install[-lrtsdg][--instant]PACKAGE安装本地(电脑端)的APP到设备上
pushasinglepackagetothedeviceandinstallit
c:\tmp\fastbootadbinstallc:/tmp/:/tmp/:1/s(752250)pkg:/data/local/tmp/[INSTALL_FAILED_ALREADY_EXISTS]
install-multiple[-lrtsdpg][--instant]PACKAGE
pushmultipleAPKstothedeviceforasinglepackageandinstallthem
install-multi-package[-lrtsdpg][--instant]PACKAGE
pushoneormorepackagestothedeviceandinstallthematomically
-r:replaceexistingapplication
-t:allowtestpackages
-d:allowversioncodedowngrade(debuggablepackagesonly)
-p:partialapplicationinstall(install-multipleonly)
-g:grantallruntimepermissions
--abiABI:overrideplatform'sdefaultABI
--instant:causetheapptobeinstalledasanephemeralinstallapp
--no-streaming:alwayspushAPKtodeviceandinvokePackageManagerasseparatesteps
--streaming:forcestreamingAPKdirectlyintoPackageManager
--fastdeploy:usefastdeploy
--no-fastdeploy:preventuseoffastdeploy
--force-agent:forceupdateofdeploymentagentwhenusingfastdeploy
--date-check-agent:updatedeploymentagentwhenlocalversionisnewerandusingfastdeploy
--version-check-agent:updatedeploymentagentwhenlocalversionhasdifferentversioncodeandusingfastdeploy
(Seealso`adbshellpmhelp`formoreoptions.)
uninstall[-k]PACKAGE
removethisapppackagefromthedevice
'-k':keepthedataandcachedirectories
七、debugging:(调试功能)
bugreport[PATH]
writebugreporttogivenPATH[default=];
ifPATHisadirectory,thebugreportissavedinthatdirectory.
devicesthatdon'tsupportzippedbugreportsoutputtostdout.
jdwplistpidsofprocesseshostingaJDWPtransport
logcatshowdevicelog(logcat--helpformore)
八、security:
disable-veritydisabledm-veritycheckingonuserdebugbuilds
enable-verityre-enabledm-veritycheckingonuserdebugbuilds
keygenFILEgenerateadbpublic/privatekey;privatekeystoredinFILE
九、scripting:
wait-for[-TRANSPORT]-STATE
waitfordevicetobeinthegivenstate
STATE:device,recovery,rescue,sideload,bootloader,ordisconnect
TRANSPORT:usb,local,orany[default=any]
get-stateprintoffline|bootloader|device取得设备的状态
c:\tmp\fastbootadbget-statedevice
get-serialnoprintserial-number取得设备号
c:\tmp\fastbootadbget-serialnoZHP7UCQCFUKNEMBQ
get-devpathprintdevice-path
remount[-R]将分区挂载为可读写
,-Rwillautomaticallyrebootthedevice.
reboot[bootloader|recovery|sideload|sideload-auto-reboot]重启到各种模式
rebootthedevice;,sideload-auto-rebootisthesamebutrebootsaftersideloading.
默认是正常启动
adbreboot重启设备adbrebootbootloader启动到fastboot模式adbrebootrecovery启动到recovery模式adbrebootsideload启动到sideload传输模式
sideloadOTAPACKAGEsideloadthegivenfullOTApackage
rootrestartadbdwithrootpermissions以root的权限来运行adb
adbroot
unrootrestartadbdwithoutrootpermissions
usbrestartadbdlisteningonUSB
tcpipPORTrestartadbdlisteningonTCPonPORT修改设备端的网络侦听端口
adbtcpip9999(默认是5555)
十、internaldebugging:
start-serverensurethatthereisaserverrunning重启adb服务
kill-serverkilltheserverifitisrunning关闭adb服务
reconnectkickconnectionfromhostsidetoforcereconnect
reconnectdevicekickconnectionfromdevicesidetoforcereconnect
reconnectofflineresetoffline/unauthorizeddevicestoforcereconnect
c:\tmp\fastbootadbkill-serverc:\tmp\fastbootadbstart-server*daemonnotrunning;startingnowattcp:5037*daemonstartedsuccessfully
十一、environmentvariables:
$ADB_TRACEcomma-separatedlistofdebuginfotolog:all,adb,sockets,packets,rwx,usb,sync,sysdeps,transport,jdwp
$ADB_VENDOR_KEYScolon-separatedlistofkeys(filesordirectories)
$ANDROID_SERIALserialnumbertoconnectto(see-s)
$ANDROID_LOG_TAGStagstobeusedbylogcat(seelogcat--help)
$ADB_LOCAL_TRANSPORT_MAX_PORTmaxemulatorscanport(default5585,16emus)
特殊功能:备份和恢复
adbbackup
adbrestore
详细用法在另一篇文章中说明。