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

在之前的文章中有转帖网上同行制作的ADB协议表格<<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:<port>

This is a special query that is sent to the ADB server when a new emulator starts up. <port> 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服务器。<port>对应的是模拟器的控制端口的一个十进制数字,例如本机转发到正在运行的模拟器的adbd的对应的那个TCP转发端口。这个机制让ADB服务器可以清楚知道有哪个模拟器被启动起来了。


host:transport:<serial-number>

Ask to switch the connection to the device/emulator identified by <serial-number>. 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服务器切换当前连接到<serial-number>指定的设备/模拟器。在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:<serial-number>:<request>

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

这是一个特殊的请求,前缀"host-serial:<serial-number> :"是用来指定客户端请求信息时的目标ADB服务器所在的一个特定设备。<request>可以是以下描述的任一方法。

host-usb:<request>

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:<request>

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:<request>

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:‘ 在这种情况下也可以指‘任意一个连接上主机的的设备或者正在主机上运行的模拟器‘。


<host-prefix>:get-product

XXX

作官方就提供了上面的XXX,没有更多的信息。本人在尝试"adb get-product"时发现并没有支持。


<host-prefix>:get-serialno

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

返回对应的设备/模拟器的序列号。"<host-prefix>:"指的是上面三种特殊信息请求命令。注意模拟器的序列号的格式形如"emulator-5554"。类似于命令行执行"adb get-serialno"


<host-prefix>:get-devpath

Returns the device path of the corresponding device/emulator.

返回对应设备/模拟器的设备路径,这里的设备路径指的是"adb device -l"列出的最后一部分,如"device product:OPPO_12025 model:X909 device:X909"。 "<host-prefix>:"指的是上面三种特殊信息请求命令。类似于命令行执行"adb  get-devpath"。


<host-prefix>:get-state

Returns the state of a given device as a string.

返回一个代表指定设备状态的字串,"<host-prefix>:"指的是上面三种特殊信息请求命令。类似于命令行执行"adb get-stat"。

<host-prefix>:forward:<local>;<remote>

Asks the ADB server to forward local connections from <local> to the <remote> address on a given device.There, <host-prefix> can be one of the host-serial/host-usb/host-local/host prefixes as described previously and indicates which device/emulator to target.
请求ADB服务器把本地<local>指定的连接重定向到指定设备的<remote>地址。在这里,"<host-prefix>"可以是以上描述的用来指定目标设备/模拟器的host-serial/host-usb/host-local/host。


the format of <local> is one of:

其中<local>的格式可以是以下任一种:

  • tcp:<port>      -> TCP connection on localhost:<port>
  • tcp:<port> -> 本地主机的<port>端口的TCP连接
  • local:<path>    -> Unix local domain socket on <path>
  • local:<path>   -> 基于地址<path>的本地主机的Unix域套接字连接(UNIX Domain Socket的地址是一个socket类型的文件在文件系统中的路径)
the format of <remote> is one of:

<remote>的格式如下:

  • tcp:<port>      -> TCP localhost:<port> on device
  • tcp<port> ->目标设备的localhost:<port>
  • local:<path>    -> Unix local domain socket on device
  • local:<path>   -> 目标设备的本地Unix Domain Socket
  • jdwp:<pid>      -> JDWP thread on VM process <pid>
  • jdwp:<pid>   -> 目标设备中进程号<PID>指定的JAVA虚拟机内部的JDWP线程
or even any one of the local services described below.

甚至还支持下面描述的任一个本地服务


<host-prefix>:forward:norebind:<local>;<remote>

Same as <host-prefix>:forward:<local>;<remote> except that it will fail it there is already a forward connection from <local>. Used to implement ‘adb forward --no-rebind <local> <remote>‘

类似<host-prefix>:forward:<local>;<remote> ,有一点区别是如果已经存在<local>的一个转发的话调用会失败。用来实现"adb forward --no-rebind <local> <remote>"

<host-prefix>:killforward:<local>

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

移除所有<local>指定的本地重定向连接。用来实现"adb forward --remove <local"命令

<host-prefix>:killforward-all

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

移除所有的重定向连接。用来实现"adb forward --remove-all"命令

<host-prefix>:list-forward

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

列出本机所有存在的转发连接。返回格式如下:

  •  <hex4>: The length of the payload, as 4 hexadecimal chars.
  • <hex4>:  返回结果长度,由4字节16进制字符组成
  •  <payload>: A series of lines of the following format: 
    • <serial> " " <local> " " <remote> "\n" :Where <serial> is a device serial number. <local>  is the host-specific endpoint (e.g. tcp:9000). <remote> is the device-specific endpoint. 
  • <payload>: 一连串以下格式的行:
    • <serial> " " <local> " " <remote> "\n":<serial>代表设备序列号。<local>代表主机端的的连接点(比如tcp:90000)。<remote>代表设备端的连接点。

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:<path>

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. <path> is a full path from the root of the filesystem.

打开一个设备文件并通过客户端连接上该设备来进行读写操作。通常这是用来调试用的,但可能不可以在所有设备上运行,因为它需要特殊的权限才能执行。<path>指的是从文件系统根开始的全路径。

tcp:<port>

Tries to connect to tcp port <port> on localhost.

尝试连接上本机的tcp端口<port>

tcp:<port>:<server-name>

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

尝试连接上<server-name>指定的设备的tecp端口<port>。这对调试只能在设备上显示的网络/代理问题很有用。

local:<path>

     Tries to connect to a Unix domain socket <path> on the device

尝试连接上设备上的<path>地址指定的Unix域套接字

localreserved:<path>
localabstract:<path>
localfilesystem:<path>

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

local:<path>的几个变种,用来访问安卓其他命名空间指定的套接字。

log:<name>

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

打开/dev/log/<name>指定的一个系统日记文件,并允许客户端去直接读取日记信息。用来实现"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 depth
  • depth: uint32_t:    framebuffer 深度
  • size:    uint32_t:    framebuffer size in bytes
  • size:    uint32_t:    framebuffer 大小(字节)
  • width:   uint32_t:    framebuffer width in pixels
  • width:   uint32_t:   framebuffer宽度(像素)
  •  height:  uint32_t:    framebuffer height in pixels
  • height: 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:<pid>

Connects to the JDWP thread running in the VM of process <pid>.

连接目标设备中进程号<PID>指定的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:

返回数据格式如下:

  • <hex4>:    the length of all content as a 4-char hexadecimal string
  • <hex4>: 代表返回数据长度的一个4字节16进制字串
  • <content>: a series of ASCII lines of the following format: <pid> "\n"
  • <content>: 一系列的ASCLL字串行,每行的格式如下: <pid> "\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



郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。