"Android Debug Bridge"
ADB lets you communicate with an emulator instance or connected android-powered device. ADB is a client-server program, includes three components:
- A client, which runs on your development machines (running on the 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 machines (running on the 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 <sdk>/platform-tools/ in.
When you start a 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 is starts, it binds to local TCP ports 5037 and listens for commands sent from ADB clients-all ADB clients Use port 5037 to communicate with the ADB server.
Adb-server uses 5037 as the interface to receive all client requests.
The server then sets up connections to all running Emulator/device instances. It locates Emulator/device instances by scanning odd-numberedports 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 all Emulator/device instance acquires a pair of sequential Ports-an even-numbered port for console Connec tions 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 ...
even for console connections, odd for ADB connections .
As shown, the emulator instance connected to ADB on port 5555 are the same as the instance whose console listens on port 55 54.
Once the server has a set up connections to all emulator instances and 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 CA N Control any Emulator/device instance from any client (or from a script).
"enabling ADB debugging"
In order to use ADB with a device connected over USB, you must enable USB debugging in the device system settings , under Developer options.
" Command Orientation "
The-s parameter is obtained using the Devices command.
"querying for Emulator/device Instances"
After you enter ADB devices, in response, ADB prints this status information for each instance:
- Serial number-a string created by ADB to uniquely identify a Emulator/device instance by its console port num ber. The format of the serial number is
<type>-<consoleport> . Here's an example serial number: , emulator-5554
- state-the connection State of the instance Ma Y be one of the following:
-
offline -the instance are not connected to ADB or are not respon Ding.
-
Device -the instance is now connected to the ADB server. Note that this state does not imply that the Android system is fully booted and operational, since the instance connects T o adb while the system is still booting. However, after boot-up, this is the normal operational state of an Emulator/device instance.
-
No device -there is no emulator/device connected.
Here's an example showing the command and its devices output:
"Installing an application"
Reference: http://developer.android.com/tools/help/adb.html
Android Debug Bridge