"Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device."

ADB作为一个多功能命令行工具,为你与模拟器或者连接到电脑的安卓设备的通讯提供了可能。

"It is a client-server program that includes three components:

  • A client, which runs on your development machine. You can invoke a client from a shell by issuing an adb command. Other Android tools such as the ADT plugin and DDMS also create adb clients.
  • A server, which runs as a background process on your development machine. The server manages communication between the client and the adb daemon running on an emulator or device.
  • A daemon, which runs as a background process on each emulator or device instance.

You can find the adb tool in <sdk>/platform-tools/."

ADB是一个CS架构的程序,它包含三个部件:

  • 客户端,运行在你的开发机器上。通过发送adb命令,你可以从shell引用一个客户端。其他诸如ADT插件、DDMS也都会创建adb客户端
  • 服务器,该进程运行在开发机器的后台。服务器对客户端和adb后台驻留程序(adb daemon,在模拟器或设备上运行)之间的通讯进行管理
  • daemon,在每个模拟器或设备实例后台运行的进程

adb 工具可以在<sdk>/platform-tools/中找到

"When you start an adb client, the client first checks whether there is an adb server process already running. If there isn't, it starts the server process. When the server starts, it binds to local TCP port 5037 and listens for commands sent from adb clients—all adb clients use port 5037 to communicate with the adb server.

The server then sets up connections to all running emulator/device instances. It locates emulator/device instances by scanning odd-numbered ports in the range 5555 to 5585, the range used by emulators/devices. Where the server finds an adb daemon, it sets up a connection to that port. Note that each emulator/device instance acquires a pair of sequential ports — an even-numbered port for console connections and an odd-numbered port for adb connections. For example:

Emulator 1, console: 5554
Emulator 1, adb: 5555
Emulator 2, console: 5556
Emulator 2, adb: 5557
and so on...

As shown, the emulator instance connected to adb on port 5555 is the same as the instance whose console listens on port 5554.

Once the server has set up connections to all emulator instances, you can use adb commands to access those instances. Because the server manages connections to emulator/device instances and handles commands from multiple adb clients, you can control any emulator/device instance from any client (or from a script).

Note: When you connect a device running Android 4.2.2 or higher to your computer, the system shows a dialog asking whether to accept an RSA key that allows debugging through this computer. This security mechanism protects user devices because it ensures that USB debugging and other adb commands cannot be executed unless you're able to unlock the device and acknowledge the dialog. This requires that you have adb version 1.0.31 (available with SDK Platform-tools r16.0.1 and higher) in order to debug on a device running Android 4.2.2 or higher."

启动adb客户端后,客户端首先检查adb服务器是否在运行。如果没有,它会启动服务器进程。服务器启动后,其将会绑定本地TCP的5037端口,来监听来自adb客户端的命令。所有的adb客户端都使用5037端口来与adb服务器通信。

然后,服务器与所有正在运行的emulator/device实例建立连接。服务器通过扫描从5555到5585的奇数端口号来定位emulator/device(因此每台机器最多同时连接16台设备)。当服务器找到adb后台驻留程序的端口后,其通过那个端口进行连接。每个emulator/device实例都需要一对连续的端口号——一个控制台连接的偶数端口,和一个adb连接的奇数端口。例如:

模拟器1,控制台:5554

模拟器1,adb:5555

模拟器2,控制台:5556

模拟器2,adb:5557

……

如上所示,通过5555连接到adb的模拟器实例和监听5554端口控制台连接的实例是相同的。

一旦服务器与所有的模拟器实例建立了连接,你就能通过adb命令来访问哪些实例。因为服务器对所有连接到它的实例进行管理而且处理多个adb客户端发送来的命令,所以你可以通过任意的客户端或者脚本来操控任意一个emulator/device实例。

注意:当你连接到电脑的设备Android版本是或者高于4.2.2时,系统会询问是否允许在这台电脑上调试程序,具体是RSA key。增加了些安全性。

p.s.以上内容引用部分来自Google Android

[ADB]ADB(Android Debug Bridge)简介及基础(不包含命令)的更多相关文章

  1. 用ADB(Android Debug Bridge)实时监测Android程序的运行

      监控Android设备上程序的运行,需要ADB的配合,具体ADB工具的介绍以及命令选项可见博客: http://blog.csdn.net/mliubing2532/article/details ...

  2. adb ( Android Debug Bridge)

    adb ( Android Debug Bridge) 是一个通用命令行工具,其允许您与模拟器实例或连接的 Android 设备进行通信.它可为各种设备操作提供便利,如安装和调试应用. adb工具的工 ...

  3. adb(Android Debug Bridge)安装使用教程

    一.说明 adb的db是debug bridge而不是和gdb一样指debug,这意思是说adb不能像gdb那样能一步步调试代码,但可以启到一些类似调试的功能. 下面就针对这些功能进行介绍,本文根据官 ...

  4. adb(android debug bridge)命令

    adb(android debug bridge) adb devices --查看当前连接的模拟器/设备 adb remount --模拟器/设备重新启动,保证能用 adb push src des ...

  5. adb(Android Debug Bridge)(一)

    上一篇介绍的am,pm命令都是基于adb shell下的命令.这节来详细介绍下adb命令. Android Debug Bridge(adb)是一个让你跟模拟器或者android设备通信的多功能命令. ...

  6. [ADB Shell]Android Debug Bridge常用命令

    ADB用法 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important ...

  7. Android Debug Bridge

    Android Debug Bridge Introduction     Android Debug Bridge (adb) is a versatile command line tool th ...

  8. Android Debug Bridge命令介绍[转]

    Android Debug Bridge命令介绍 Android Debug Bridge的一些基本命令.这个工具直译过来就是Android调试桥的意思.它提供了强大的特性,例如复制文件到设备或从设备 ...

  9. 【Android应用开发技术:基础构建】命令行下的Android应用开发

    作者:郭孝星 微博:郭孝星的新浪微博 邮箱:allenwells@163.com 博客:http://blog.csdn.net/allenwells github:https://github.co ...

随机推荐

  1. python基础教程-第三章-使用字符串

    本章将会介绍如何使用字符串何世华其他的值(如打印特殊格式的字符串),并简单了解下利用字符串的分割.联接.搜索等方法能做些什么 3.1 基本字符串操作 所有标准的序列操作(索引.分片.乘法.判断成员资格 ...

  2. 日常小测:颜色 && Hackerrank Unique_colors

    题目传送门:https://www.hackerrank.com/challenges/unique-colors 感谢hzq大神找来的这道题. 考虑点分治(毕竟是路经统计),对于每一个颜色,它的贡献 ...

  3. sql 查询服务器硬盘剩余空间

    DECLARE @tb1 Table( drive varchar(20), [MB 可用空间] varchar(20)) INSERT INTO @tb1 Exec master.dbo.xp_fi ...

  4. Cogs 14. [网络流24题] 搭配飞行员

    这道题其实蛮好想的,因为分为正,副飞行员.所以就把正飞行员当作Boy,副飞行员当作Girl.然后做Hungry即可. #include<bits/stdc++.h> using names ...

  5. html图片预览

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  6. CPU与内存的那些事

    下面是网上看到的一些关于内存和CPU方面的一些很不错的文章. 整理如下: 转: CPU的等待有多久? 原文标题:What Your Computer Does While You Wait 原文地址: ...

  7. Eclipse中的一些快捷键的使用

    Eclipse是一款强大的编程工具,在使用的过程中,若能够有效的使用其快捷键,效率会得到很大的提升,下面是一些常用的eclipse快捷键,可谓是键键精彩. 1.成单词:Alt+/ 2 重构之重命名:S ...

  8. php ob_start()、ob_end_flush和ob_end_clean()多级缓冲

    ob_start() 和 ob_end_flush() 是一对很好的搭档,可以实现对输出的控制.当成一对出现理解起来就没什么问题,但是当他们两个各自出现次数增加时,就比较难理解了. <?php ...

  9. IOS框架和服务

    在iOS中框架是一个目录,包含了共享资源库,用于访问该资源库中储存的代码的头文件,以及图像.声音文件等其他资源.共享资源库定义应用程序可以调用的函数和方法. iOS为应用程序开发提供了许多可使用的框架 ...

  10. ucenter 新增用户后 自动登录discuz 不用激活

    uc_client models user.php function add_user($username, $password, $email, $uid = 0, $questionid = '' ...