👉 Overview
👀 What ?
Android Debug Bridge (ADB) is a versatile command-line tool that enables communication between a computer and an Android device. It facilitates a variety of device actions, such as installing and debugging apps, and provides access to a Unix shell to run various commands on an Android device.
🧐 Why ?
Understanding ADB commands is essential for Android developers, testers, and security professionals. It allows for efficient debugging, app installation, file transfer, and overall device management. Furthermore, it aids in performing various tasks that are not possible with the standard user interface.
⛏️ How ?
To use ADB, you first need to install Android SDK on your computer. Then, enable 'USB debugging' on your Android device in the 'Developer Options' section. Connect your device to the computer and navigate to the 'platform-tools' directory in the SDK folder. Open the command prompt here and type 'adb' to start using the commands. Some common ADB commands include 'adb devices' to list all connected devices, 'adb install' to install an app, and 'adb push' to copy files to the device.
⏳ When ?
ADB commands have been in use since the early days of Android. They are continuously updated and expanded with each new Android version to address evolving needs and challenges.
⚙️ Technical Explanations
ADB operates in a client-server model. The client sends commands, the daemon (adbd) runs commands on a device, and the server manages communication between client and daemon. 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 devices. It locates emulators 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, an emulator that uses ports 5554 and 5555 is visible to adb as emulator-5554. To ensure that the emulators/devices instances are running on an IP address and port number that adb can connect to, the instances periodically send an announcement to a well-known multicast address (224.0.0.1).