Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android KitCat 4.4.2 ADB 官方所支持的所有Services格式翻譯

Android KitCat 4.4.2 ADB 官方所支持的所有Services格式翻譯

編輯:關於Android編程

在之前的文章中有轉帖網上同行制作的ADB協議表格<>,但不夠詳盡,所以這裡自己另外基於Android 4.4.2的技術文檔重新做一次翻譯。

HOST SERVICES:

主機服務:

host:version

Ask the ADB server for its internal version number. As a special exception, the server will respond with a 4-byte hex string corresponding to its internal version number, without any OKAY or FAIL.

向ADB服務器請求其內部版本號。作為一個協議中的例外(請查看OVERVIEW.txt來查看ADB具體協議規則),服務器會返回一個代表其內部版本號的4字節的十六進制字符串,而不會像標准協議中會返回OKAY或者FAIL

host:kill

Ask the ADB server to quit immediately. This is used when the ADB client detects that an obsolete server is running after an upgrade.
請求ADB服務器立刻退出。當ADB升級完成後,如果ADB客戶端檢測到之前已經過時的ADB服務器還在運行的時候會發送這個請求。

host:devices
host:devices-l

Ask to return the list of available Android devices and their state. devices-l includes the device paths in the state. After the OKAY, this is followed by a 4-byte hex len, and a string that will be dumped as-is by the client, then the connection is closed

這兩個服務請求是類似的,都是請求ADB服務器返回一系列有效的安卓設備以及對應的狀態信息,只是devices -l會在狀態信息中包含該設備更多的信息,比如產品型號等。在正常返回OKAY之後,會緊跟著一個代表數據長度的4字節長的十六進制數,以及對應的如我們通過命令adb devices -l命令能看到的輸出,然後連接請求就會關閉。

host:track-devices

This is a variant of host:devices which doesn't close the connection. Instead, a new device list description is sent each time a device is added/removed or the state of a given device changes (hex4 + content). This allows tools like DDMS to track the state of connected devices in real-time without polling the server repeatedly.

這個服務是以上的host:devices的一個變種,客戶端和ADB服務器的連接會一致保持,當有增加/移除設備或者設備狀態改變的時候會主動的往連接上的客戶端發送新的設備列表信息(4字節16進制長度+內容)。這樣做的話就可以允許DDMS這些工具來實時跟蹤所有連接上來的設備的狀態,而不需要客戶端每次都去連接ADB服務器獲取對應信息。

host:emulator:

This is a special query that is sent to the ADB server when a new emulator starts up. is a decimal number corresponding to the emulator's ADB control port, i.e. the TCP port that the emulator will forward automatically to the adbd daemon running in the emulator system. This mechanism allows the ADB server to know when new emulator instances start.

這是一個特殊的請求,當一個新的模擬器啟動的時候這個請求將會發送到ADB服務器。對應的是模擬器的控制端口的一個十進制數字,例如本機轉發到正在運行的模擬器的adbd的對應的那個TCP轉發端口。這個機制讓ADB服務器可以清楚知道有哪個模擬器被啟動起來了。


host:transport:

Ask to switch the connection to the device/emulator identified by . After the OKAY response, every client request will be sent directly to the adbd daemon running on the device. (Used to implement the -s option)

請求ADB服務器切換當前連接到指定的設備/模擬器。在OKAY應答之後,客戶端的所有請求都會重定向到該設備的adbd這個守護進程。(用來實現ADB命令行客戶端的-s選項)


host:transport-usb

Ask to switch the connection to one device connected through USB to the host machine. This will fail if there are more than one such devices. (Used to implement the -d convenience option)

請求ADB服務器切換當前連接到通過USB連接到主機的設備。如果多於一個設備通過USB連接到主機,調用將會失敗。(用來實現ADB命令行客戶端的-d這個方便使用的選項)

host:transport-local

Ask to switch the connection to one emulator connected through TCP. This will fail if there is more than one such emulator instance running. (Used to implement the -e convenience option)

請求ADB服務器切換當前連接到一個通過TCP協議連接上來的模擬器。如果多於一個模擬器在運行的話,調用將會失敗。(用來實現-e這個方便使用的選項)

host:transport-any

Another host:transport variant. Ask to switch the connection to either the device or emulator connect to/running on the host. Will fail if there is more than one such device/emulator available. (Used when neither -s, -d or -e are provided)

另外一個host:transport的變種。請求ADB服務器切換當前連接到已經連接上主機的設備或者正在主機中運行的中模擬器。如果有多於一個這類設備存在,調用將會失敗。(在-s,-d或-e選項都沒有提供的時候使用)

host-serial::

This is a special form of query, where the 'host-serial::' prefix can be used to indicate that the client is asking the ADB server for information related to a specific device. can be in one of the format described below.

這是一個特殊的請求,前綴"host-serial: :"是用來指定客戶端請求信息時的目標ADB服務器所在的一個特定設備。可以是以下描述的任一方法。

host-usb:

A variant of host-serial used to target the single USB device connected to the host. This will fail if there is none or more than one.

host-serial的一個變種,指定的是一個連接上主機的USB設備。如果沒有或者有多於一個這種設備的話調用將會失敗。

host-local:

A variant of host-serial used to target the single emulator instance running on the host. This will fail if there is none or more than one.

另一個host-serial的變種,這次指定的是一個在主機運行的模擬器。如果沒有或者有多於一個這種設備的話調用將會失敗。相當於直接執行" adb get-product"或者“adb get-serilano"等

host:

When asking for information related to a device, 'host:' can also be interpreted as 'any single device or emulator connected to/running on
the host'.

當通過ADB服務器向一個相關設備請求信息的時候,'host:' 在這種情況下也可以指‘任意一個連接上主機的的設備或者正在主機上運行的模擬器'。


:get-product

XXX

作官方就提供了上面的XXX,沒有更多的信息。本人在嘗試"adb get-product"時發現並沒有支持。


:get-serialno

Returns the serial number of the corresponding device/emulator. Note that emulator serial numbers are of the form "emulator-5554"

返回對應的設備/模擬器的序列號。":"指的是上面三種特殊信息請求命令。注意模擬器的序列號的格式形如"emulator-5554"。類似於命令行執行"adb get-serialno"


:get-devpath

Returns the device path of the corresponding device/emulator.

返回對應設備/模擬器的設備路徑,這裡的設備路徑指的是"adb device -l"列出的最後一部分,如"device product:OPPO_12025 model:X909 device:X909"。 ":"指的是上面三種特殊信息請求命令。類似於命令行執行"adb get-devpath"。


:get-state

Returns the state of a given device as a string.

返回一個代表指定設備狀態的字串,":"指的是上面三種特殊信息請求命令。類似於命令行執行"adb get-stat"。

:forward:;

Asks the ADB server to forward local connections from to the address on a given device.There, can be one of the host-serial/host-usb/host-local/host prefixes as described previously and indicates which device/emulator to target.
請求ADB服務器把本地指定的連接重定向到指定設備的地址。在這裡,""可以是以上描述的用來指定目標設備/模擬器的host-serial/host-usb/host-local/host。


the format of is one of:

其中的格式可以是以下任一種:

tcp: -> TCP connection on localhost:tcp: -> 本地主機的端口的TCP連接local: -> Unix local domain socket on local: -> 基於地址的本地主機的Unix域套接字連接(UNIX Domain Socket的地址是一個socket類型的文件在文件系統中的路徑) the format of is one of:

的格式如下:

tcp: -> TCP localhost: on devicetcp ->目標設備的localhost:local: -> Unix local domain socket on devicelocal: -> 目標設備的本地Unix Domain Socketjdwp: -> JDWP thread on VM process jdwp: -> 目標設備中進程號指定的JAVA虛擬機內部的JDWP線程 or even any one of the local services described below.

甚至還支持下面描述的任一個本地服務


:forward:norebind:;

Same as :forward:; except that it will fail it there is already a forward connection from . Used to implement 'adb forward --no-rebind '

類似:forward:; ,有一點區別是如果已經存在的一個轉發的話調用會失敗。用來實現"adb forward --no-rebind "

:killforward:

Remove any existing forward local connection from . This is used to implement 'adb forward --remove '

移除所有指定的本地重定向連接。用來實現"adb forward --remove

:killforward-all

Remove all forward network connections. This is used to implement 'adb forward --remove-all'.

移除所有的重定向連接。用來實現"adb forward --remove-all"命令

:list-forward

List all existing forward connections from this server. This returns something that looks like the following:

列出本機所有存在的轉發連接。返回格式如下:

: The length of the payload, as 4 hexadecimal chars.: 返回結果長度,由4字節16進制字符組成 : A series of lines of the following format: " " " " "\n" :Where is a device serial number. is the host-specific endpoint (e.g. tcp:9000). is the device-specific endpoint. : 一連串以下格式的行: " " " " "\n":代表設備序列號。代表主機端的的連接點(比如tcp:90000)。代表設備端的連接點。

Used to implement 'adb forward --list'.

這是用來實現"adb forward --list"命令的。


LOCAL SERVICES:

本地服務:

All the queries below assumed that you already switched the transport to a real device, or that you have used a query prefix as described above.

下面的所有請求是建立在你已經把傳輸切換到一個真實設備上,或者你使用了以上描述的一個query前綴的服務請求

shell:command arg1 arg2 ...

Run 'command arg1 arg2 ...' in a shell on the device, and return its output and error streams.

在設備的shell中運行'command arg1 arg2 ...',並且返回對應輸出和錯誤流。

Note that arguments must be separated by spaces. If an argument contains a space, it must be quoted with double-quotes. Arguments cannot contain double quotes or things will go very wrong.

注意參數必須空格隔開。如果一個參數本身包含空格,那麼它必須要用雙引號引起來。參數內部不能包含雙引號,否則命令執行結果將無法控制。

Note that this is the non-interactive version of "adb shell"

注意這是"adb shell"的一個非交互式版本

shell:

Start an interactive shell session on the device. Redirect stdin/stdout/stderr as appropriate.

開啟設備的一個交互shell會話。合理的重定向了標准輸入/標准輸出/標注錯誤。

Note that the ADB server uses this to implement "adb shell", but will also cook the input before sending it to the device (see interactive_shell() in commandline.c)

注意ADB服務器就是使用這個協議來實現命令行客戶端的"adb shell"請求的,但當然它會先包裝整理好輸入的信息再發送到目標設備(請查看commandline.c的interactive_shell())

remount:

Ask adbd to remount the device's filesystem in read-write mode, instead of read-only. This is usually necessary before performing an "adb sync" or "adb push" request.
This request may not succeed on certain builds which do not allow that.

請求adbd去重新把設備只讀文件系統掛載成可讀寫模式的文件系統。這個在執行"adb sync"或者"adb push"請求之前通常是很有必要先執行的。這個請求在一些版本中也許因為不支持而會失敗

dev:

Opens a device file and connects the client directly to it for read/write purposes. Useful for debugging, but may require special privileges and thus may not run on all devices. is a full path from the root of the filesystem.

打開一個設備文件並通過客戶端連接上該設備來進行讀寫操作。通常這是用來調試用的,但可能不可以在所有設備上運行,因為它需要特殊的權限才能執行。指的是從文件系統根開始的全路徑。

tcp:

Tries to connect to tcp port on localhost.

嘗試連接上本機的tcp端口

tcp::

Tries to connect to tcp port on machine from the device. This can be useful to debug some networking/proxy issues that can only be revealed on the device itself.

嘗試連接上指定的設備的tecp端口。這對調試只能在設備上顯示的網絡/代理問題很有用。

local:

Tries to connect to a Unix domain socket on the device

嘗試連接上設備上的地址指定的Unix域套接字

localreserved:
localabstract:
localfilesystem:

Variants of local: that are used to access other Android socket namespaces.

local:的幾個變種,用來訪問安卓其他命名空間指定的套接字。

log:

Opens one of the system logs (/dev/log/) and allows the client to read them directly. Used to implement 'adb logcat'. The stream will be read-only for the client.

打開/dev/log/指定的一個系統日記文件,並允許客戶端去直接讀取日記信息。用來實現"adb logcat"這個命令。日記流對客戶端是只讀的。

framebuffer:

This service is used to send snapshots of the framebuffer to a client. It requires sufficient privileges but works as follow: After the OKAY, the service sends 16-byte binary structure containing the following fields (little-endian format):

這個服務是用來把framebuffer的截屏快照發送到客戶端的。它需要足夠的權限,且工作原理如下: 服務在返回OKAY之後會繼續發送16字節的二進制結構數據的以下內容到客戶端(小字節序格式)

depth: uint32_t: framebuffer depthdepth: uint32_t: framebuffer 深度size: uint32_t: framebuffer size in bytessize: uint32_t: framebuffer 大小(字節)width: uint32_t: framebuffer width in pixelswidth: uint32_t: framebuffer寬度(像素)
height: uint32_t: framebuffer height in pixelsheight: uint32_t: framebuffer 高度(像素)
With the current implementation, depth is always 16, and size is always width*height*2

在當前的實現中,寬度永遠是16,大小用永遠是寬度*高度*2

Then, each time the client wants a snapshot, it should send one byte through the channel, which will trigger the service to send it 'size' bytes of framebuffer data. If the adbd daemon doesn't have sufficient privileges to open the framebuffer device, the connection is simply closed immediately.

每次客戶端想要一個截屏快照時,它將會通過Socket通道發送一個字節,這會觸發本服務去把framebuffer數據按其大小指定的字節數發送給客戶端。如果adbd守護進程沒有足夠的權限打開framebuffer設備,那麼連接會立即關閉。

jdwp:

Connects to the JDWP thread running in the VM of process .

連接目標設備中由進程號指定的JAVA虛擬機進程內部的JDWP線程

track-jdwp

This is used to send the list of JDWP pids periodically to the client.

這個服務是用來周期性的往客戶端發送有啟用JDWP的進程的進程號列表。

The format of the returned data is the following:

返回數據格式如下:

: the length of all content as a 4-char hexadecimal string: 代表返回數據長度的一個4字節16進制字串: a series of ASCII lines of the following format: "\n": 一系列的ASCLL字串行,每行的格式如下: "\n" This service is used by DDMS to know which debuggable processes are running on the device/emulator.

這個服務被DDMS用來知悉有哪些可調式的進程正在真實設備/模擬器上運行。

Note that there is no single-shot service to retrieve the list only once.

注意並不存在另外一個服務來只獲取一次這個列表。

sync:

This starts the file synchronisation service, used to implement "adb push" and "adb pull". Since this service is pretty complex, it will be detailed in a companion document named SYNC.TXT

開啟文件同步服務,用來實現"adb push"和" adb pull" 這兩個命令。因為這個服務相當復雜,更詳細的信息請查看相關的SYNC.TXT文檔。


Item

Description

Warning

Author

天地會珠海分舵

轉載請注明出處!

Blog Address

http://blog.csdn.net/zhubaitian



  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved