Android ADB command ~ Illustration

Source: Internet
Author: User
Tags unix domain socket

After such a long period of development and management, the command is always self-viewed, but the sharing process on the command is often ignored. So now I just need
Its command-related operations can be used for simple literacy, and the system also grants them fishing instead of fish in this way. Well, I will display it in graphic mode, of course, my habit is to read the help document or command first. The ADB command we want to explain here today can be detailed through command help in the command line, first:

The above is how to use help to display its related command instructions. Of course, if your English is good enough, these are actually very simple. Of course, if you are not used to reading these English descriptions, let me help you solve this problem. Well, I will translate and explain it in the most initial way. OK:

Android debug bridge version 1.0.29
This is about Android 1.0.29.

-D-directs command to the only connected USB device

The direct command is to connect the USB device.
Returns an error if more than one USB device is present.

If multiple USB devices appear at the same time, an error message is returned.
-E-directs command to the only running emulator.

Run the simulator directly using this command symbol
Returns an error if more than one emulator is running.

If multiple simulators run simultaneously, an error message is returned at the moment.
-S <serial number>-directs command to the USB device or emulator

The given serial number. Overrides android_serial
Environment variable.

Use this direct command to display the serial number of the USB device or simulator. If the serial number is overwritten, the environment variable is variable.
-P <product name or path>-simple product name like 'sooner', or
A relative/absolute path to a product
Out directory Like 'out/target/product/sooner '.
If-P is not specified, the android_product_out
Environment variable is used, which must
Be an absolute path.

Use this command to display the product name, such as "Sooner", or a relative and absolute product output path like "Out/target/product/sooner". If-P is not specified, the android_product_out environment variable will be used, but it must be an absolute path.
Devices-list all connected devices

Use this command to list all connected devices
Connect Port 5555 is used by default if no port number is specified.

Use the default port 5555 of TCP/IP to connect to the device
Disconnect [Port 5555 is used by default if no port number is specified.
Using this command with no additional arguments
Will disconnect from all connected TCP/IP devices.

You can use this command to disconnect a device from a TCP/IP. The default value is 5555 if no port is specified, using this command, you do not need to add a parameter to disconnect all connected devices from TCP/IP.

Device commands:

Device command:
ADB push <local> <remote>-copy file/DIR to Device
Push command: copy a file or directory to the device.

ADB pull <remote> [<local>]-copy file/DIR from Device

Pull command: copy a file or directory to the device.
ADB sync [<directory>]-copy host-> device only if changed
(-L means list but don't copy)
(See 'adb help all ')

Sync: copy the host content to the device. It is only used to synchronize the content of the device when the device changes. The brackets indicate: I mean to list the content but do not need to copy it, refer to help all
ADB shell-run remote shell interactively

Shell: run a remote shell to interact with it
ADB shell <command>-run remote shell command

Shell: directly run the remote shell command
Adb emu <command>-run emulator Console Command

EMU: run the simulator monitoring information panel command
ADB logcat [<filter-spec>]-view device log

View device logs
ADB forward <local> <remote>-forward socket connections

Forward socket connection
Forward specs are one:

A standard for display of forward specifications is:
TCP: <port>

TCP port number
Localabstract: <Unix domain socket name>
Local Abstraction: socket name of Unix domain name

Localreserved: <Unix domain socket name>

Local Service: Unix domain name/socket name
Localfilesystem: <Unix domain socket name>

Local file system: Unix domain name/socket name
Dev: <character device name>

Device: character device name
Jdwp: <process pid> (Remote Only)

Remote process ID
ADB jdwp-list PIDs of processes hosting a jdwp transport

Lists the transmission of a Java-debugged wireless protocol with the relevant process ID as the host process.

Speaking of jdwp, I will explain it briefly. It means that it is jdwp. The full write of jdwp is: Java debug wire protocol, that is, the Java debugger wireless protocol, which defines the debugger (debugger) the communication protocol between the debugged Java Virtual Machine (target VM), here I want to explain more: debugger and target Vm, the target VM runs the program we want to debug, it is similar to
There is no difference between Java virtual machines, but the agent jdwp is loaded at startup to enable debugging. The debugger is a well-known debugger. It sends commands to the running target VM to obtain the status of the target Vm and control the execution of Java programs. Debugger and target VM run in their respective processes respectively. The communication protocol between them is jdwp. Jdwp
Unlike many other protocols, it only defines the data transmission format, but does not specify a specific transmission mode. This means that the implementation of a jdwp can work normally in different transmission modes without any modification (details will be given in the jdwp transmission interface ). Jdwp is language independent. Theoretically, we can use any language to implement jdwp. However, we note that the two ends of jdwp are target VM
And debugger. On the target VM end, the jdwp module must be loaded at the startup of the Java Virtual Machine in the form of Agent library, and it must implement various debug functions through the jvmti interface provided by the Java Virtual Machine, therefore, it must be written in C/C ++. The debugger end does not have such restrictions and can be written in any language, as long as it complies with the jdwp specifications. Jdi (Java debug Interface) includes a Java jdwp debugger implementation (jdi will be introduced in the next article in this series), JDK
The debugging tool jdb also uses jdi to complete its debugging function. The roles of the jdwp agent described above in debugging are as follows:


In fact, with a simple analysis of the protocol, we can learn the simple process of the handshake protocol:


Finally, let's take a look at its architecture:


Well, we have learned about jdwp from the above. For more details and operations, please refer to Google for details.

ADB install [-L] [-R] [-S] <File>-push this package file to the device and install it
('-L' means forward-lock the app)
('-R' means reinstall the app, keeping its data)
('-S' means install on SD card instead of internal storage)

Run this command to install the APK package to the device.-l means that the app is locked for a long time.-R means that the app needs to be re-installed and its data must be maintained, -s indicates that the device is installed in the SD card.
ADB uninstall [-K] <package>-Remove this app package from the device
('-K' means keep the data and cache Directories)

Run this command to uninstall the installed APK, that is, remove the package of the current app from the device.-K means to keep the data domain cache directory.
ADB bugreport-return all information from the device
That shoshould be added in a bug report.

You can use this command to output and display the debugging information (device information ).

ADB backup [-F <File>] [-APK |-noapk] [-shared |-noshared] [-all] [-system |-nosystem] [<packages... >]
-Write an archive of the device's data to <File>.
If no-F option is supplied then the data is written
To "backup. AB" in the current directory.
(-APK |-noapk enable/disable backup of the. apks themselves
In the archive; the default is noapk .)
(-Shared |-noshared enable/disable backup of the device's
Shared storage/SD card contents; the default is noshared .)
(-All means to back up all installed applications)
(-System |-nosystem toggles whether-all automatically between des
System Applications; the default is to include system Apps)
(<Packages...> is the list of applications to be backed up. If
The-all or-shared flags are passed, then the package
List is optional. Applications explicitly given on
Command line will be encoded ded even if-nosystem wocould
Ordinarily cause them to be omitted .)
You can use this command to back up its content,

ADB restore <File>-Restore device contents from the <File> Backup Archive

Archive files backed up by Alibaba Cloud can be re-stored on devices.
ADB help-show this help message

Show Help Information
ADB version-show version num

Show De-version number

Scripting:

Script
ADB wait-for-device-block until device is online

When the device is online
ADB start-server-ensure that there is a server running

Start its service
ADB kill-server-kill the server if it is running

Run this command to kill the service that it runs.
ADB get-state-prints: offline | bootloader | Device

Obtains the status of a device.
ADB get-serialno-prints: <serial-number>

Obtain a series of serial numbers
ADB status-window-continuously print device status for a specified device

Continuously print the specified device status
ADB remount-remounts the/system partition on the device read-write
Reinstalls the read/write operations on the devices.

ADB reboot [bootloader | recovery]-reboots the device, optionally into the bootloader or recovery program
Reload or restore the program.

ADB reboot-bootloader-reboots the device into the bootloader

Load the device that it restarts
ADB root-restarts the adbd daemon with root permissions

Get root permission after restart
Adb usb-restarts the adbd daemon listening on USB

Restart to listen to USB
Adb tcpip <port>-restarts the adbd daemon listening on TCP on the specified port

Restart TCP to listen to the specified TCP port
Networking:

Network
Adb ppp <tty> [parameters]-Run PPP over USB.
 

Note: You shoshould not automatically start a PPP connection.
<Tty> refers to the TTY for PPP stream. eg. Dev:/dev/omap_csmi_tty1
[Parameters]-eg. defaultroute debug dump local notty usepeerdns

ADB sync notes: ADB sync [<directory>]
<Localdir> can be interpreted in several ways:

-If <directory> is not specified, both/System and/Data partitions will be updated.

-If it is "system" or "data", only the corresponding Partition
Is updated.

Environmental variables:
Adb_trace-print debug information. A comma separated list of the following values
1 or all, ADB, sockets, packets, rwx, USB, sync, sysdeps, transport, jdwp
Android_serial-the serial number to connect to.-S takes priority over this if given.
Android_log_tags-when used with the logcat option, only these debug tags are printed.

The above part will not be translated or understood due to time issues. In fact, the last few sentences are quite understandable. Please try again,

The following is a simple example:

Show logs: ADB logcat | more

List devices: ADB Devices

OK. The above are two simple command columns. You can bring relevant parameters to verify the command according to the actual situation, I hope to give you some reference and learning .......

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.