您的位置:首页 > 博客中心 > 数据库 >

adb概览及协议參考

时间:2022-03-14 18:40

原文:https://github.com/android/platform_system_core/blob/master/adb/OVERVIEW.TXT)

Implementation notes regarding ADB.

ADB实现注解

1. General Overview:

1概要

The Android Debug Bridge (ADB) is used to:

ADB在下面情况下使用:

  • keep track of all Android devices and emulators instances connected to or running on a given host developer machine
  • 对全部连接到开发机器上的android真机和模拟器进行跟踪管理
  • implement various control commands (e.g. "adb shell", "adb pull", etc..) for the benefit of clients (command-line users, or helper programs like DDMS). These commands are what is called a ‘service‘ in ADB.
  • 实现了大量的控制命令(比方: "adb shell", "adb pull",等等)来方便用户使用(包含命令行用户和助手类程序如ddms),这些命令往往被我们叫做adb中的一个‘服务’。

As a whole, everything works through the following components:

总而言之。全部的事情都是环绕着下面这几个模块进行的:

1.1 The ADB server

1.1 ADBserver

This is a background process that runs on the host machine. Its purpose if to sense the USB ports to know when devices are attached/removed,as well as when emulator instances start/stop.

这是在主机设备(PC/开发机器)上执行的一个后台进程。它的目的是嗅探何时有设备在主机的usb口上挂载/移除,以及模拟器何时开启/关闭。

It thus maintains a list of "connected devices" and assigns a ‘state‘ to each one of them: OFFLINE, BOOTLOADER, RECOVERY or ONLINE (more on this below).

因此它会维护着一个"已连接设备"列表,而且为每一个设备指定一个‘状态’:OFFLINE, BOOTLOADER, RECOVERY 或 ONLINE (下文会详述)。

The ADB server is really one giant multiplexing loop whose purpose is to orchestrate the exchange of data (packets, really) between clients, services and devices.

ADBserver确实能够称为是一个强大的多路路由。它的目的就是去协调组织client,各种服务和设备之间的数据交换(数据包,真实数据)。



1.2 The ADB daemon (adbd)

1.2 ADB守护进程(adbd)

The ‘adbd‘ program runs as a background process within an Android device or emulated system. Its purpose is to connect to the ADB server (through USB for devices, through TCP for emulators) and provide a few services for clients that run on the host.

adbd是一个在android真实机器或者模拟器上执行的后台伺服程序。

它的目的是为了连接pc端的adbserver(真实机器用usb,模拟器用tcp协议(译者注:事实上真实机器也能够用tcp来连接。这篇文章没有及时更新过来))而且为在主机pc上执行的adbclient应用提供一些服务。

The ADB server considers that a device is ONLINE when it has successfully connected to the adbd program within it. Otherwise, the device is OFFLINE, meaning that the ADB server detected a new device/emulator, but could not connect to the adbd daemon.

当adbserver成功连接上android机器上的adbd伺服程序的时候就会觉得该设备已经online,否者就会觉得该设备是offline,指的是adbserver有检測到一个新的设备连接上来,可是却没有成功连接上该设备的的adbd。

the BOOTLOADER and RECOVERY states correspond to alternate states of devices when they are in the bootloader or recovery mode.

BOOTLOADER和RECOVERY着两个状态分别代表android设备处于bootloader或者recovery模式下的相应的可选状态。


1.3. The ADB command-line client

1.3 ADB命令行client

The ‘adb‘ command-line program is used to run adb commands from a shell or a script. It first tries to locate the ADB server on the host machine, and will start one automatically if none is found.

adb命令行client是给shell或者脚本调用来跑各种adb命令的。它首先会尝试找到主机pc上执行的adbserver,假设没有找到的话就会自己主动启动一个adbserver。

then, the client sends its service requests to the ADB server. It doesn‘t need to know.

然后该adb命令行client会往adbserver发送服务请求。而这些对于adbserver来说是无需知道的。

Currently, a single ‘adb‘ binary is used for both the server and client. this makes distribution and starting the server easier.
就当前来说,adbserver和adbclient使用的事实上是同一个二进制文件。这样使得公布和启动server会更方便。



1.4. Services

1.4. 服务

There are essentially two kinds of services that a client can talk to.

本质上一个adb命令行client会和两类服务进行通信。

Host Services: these services run within the ADB Server and thus do not need to communicate with a device at all. A typical example is "adb devices" which is used to return the list of currently known devices and their state. They are a few couple other services though.

主机服务:这些服务是在adbserver自身内部执行的所以根本不须要和不论什么的android设备进行交互。一个典型的命令就是列出当前连接的全部android设备和状态的命令“adb devices”。

当然另一些其它的服务了。



热门排行

今日推荐

热门手游