|
|
#![Awesome Adb](./assets/title.png)
|
|
|
|
|
|
The [Android Debug Bridge](https://developer.android.com/studio/command-line/adb.html) (ADB) is a toolkit included in the Android SDK package, it is not only a powerful tool for Android developers and testers, but also a good toy for Android fans.
|
|
|
|
|
|
This repository renews continually, Pull Requests and Issues are welcomed. If you found [this](https://github.com/mzlogin/awesome-adb) is useful, you can star it and conveniently back here to view when necessary.
|
|
|
|
|
|
**Note:** Some commands may depending on the version of Android system or ROM.
|
|
|
|
|
|
Other languages: [:cn: Chinese](./README.md)
|
|
|
|
|
|
#![Table of Contents](./assets/toc.png)
|
|
|
|
|
|
<!-- vim-markdown-toc GFM -->
|
|
|
* [Basic Usage](#basic-usage)
|
|
|
* [Command syntax](#command-syntax)
|
|
|
* [Targeting equipment for command](#targeting-equipment-for-command)
|
|
|
* [Start/Stop](#startstop)
|
|
|
* [View adb version](#view-adb-version)
|
|
|
* [Run adbd as root](#run-adbd-as-root)
|
|
|
* [Designated adb server network port](#designated-adb-server-network-port)
|
|
|
* [Device connection management](#device-connection-management)
|
|
|
* [Inquiries connected device / simulator](#inquiries-connected-device--simulator)
|
|
|
* [USB connection](#usb-connection)
|
|
|
* [Wireless connection (need to use the USB cable)](#wireless-connection-need-to-use-the-usb-cable)
|
|
|
* [Wireless connection (without using the USB cable)](#wireless-connection-without-using-the-usb-cable)
|
|
|
* [Application Management](#application-management)
|
|
|
* [Check the list of](#check-the-list-of)
|
|
|
* [All applications](#all-applications)
|
|
|
* [system applications](#system-applications)
|
|
|
* [third-party usage](#third-party-usage)
|
|
|
* [Application package name contains a string](#application-package-name-contains-a-string)
|
|
|
* [Install APK](#install-apk)
|
|
|
* [Uninstalling](#uninstalling)
|
|
|
* [Clear app cache data](#clear-app-cache-data)
|
|
|
* [View Reception Activity](#view-reception-activity)
|
|
|
* [Applications to interact with](#applications-to-interact-with)
|
|
|
* [Transferred from Activity](#transferred-from-activity)
|
|
|
* [Transferred from the Service](#transferred-from-the-service)
|
|
|
* [Transmits broadcast](#transmits-broadcast)
|
|
|
* [Forcibly stop the application](#forcibly-stop-the-application)
|
|
|
* [File Management](#file-management)
|
|
|
* [Copy files to the computer equipment in](#copy-files-to-the-computer-equipment-in)
|
|
|
* [Copy computer files to the device](#copy-computer-files-to-the-device)
|
|
|
* [Analog Keys / inputs](#analog-keys--inputs)
|
|
|
* [Power button](#power-button)
|
|
|
* [menu](#menu)
|
|
|
* [HOME key](#home-key)
|
|
|
* [return key](#return-key)
|
|
|
* [volume control](#volume-control)
|
|
|
* [Media Control](#media-control)
|
|
|
* [On / Off screen](#on--off-screen)
|
|
|
* [Slide to unlock](#slide-to-unlock)
|
|
|
* [Enter text](#enter-text)
|
|
|
* [View Log](#view-log)
|
|
|
* [Android log](#android-log)
|
|
|
* [Filter the log by level](#filter-the-log-by-level)
|
|
|
* [Filter by tag and log level](#filter-by-tag-and-log-level)
|
|
|
* [Log format](#log-format)
|
|
|
* [Clear log](#clear-log)
|
|
|
* [Kernel log](#kernel-log)
|
|
|
* [View device information](#view-device-information)
|
|
|
* [Model](#model)
|
|
|
* [Battery Status](#battery-status)
|
|
|
* [Screen Resolution](#screen-resolution)
|
|
|
* [Screen density](#screen-density)
|
|
|
* [Display Parameters](#display-parameters)
|
|
|
* [android\_id](#android_id)
|
|
|
* [IMEI](#imei)
|
|
|
* [Android system version](#android-system-version)
|
|
|
* [IP address](#ip-address)
|
|
|
* [Mac Address](#mac-address)
|
|
|
* [CPU Information](#cpu-information)
|
|
|
* [Memory Information](#memory-information)
|
|
|
* [More hardware and system properties](#more-hardware-and-system-properties)
|
|
|
* [Utility functions](#utility-functions)
|
|
|
* [Screenshots](#screenshots)
|
|
|
* [Recording Screen](#recording-screen)
|
|
|
* [Remount system partition as writable](#remount-system-partition-as-writable)
|
|
|
* [Check connection over WiFi password](#check-connection-over-wifi-password)
|
|
|
* [To set the system date and time](#to-set-the-system-date-and-time)
|
|
|
* [restart cellphone](#restart-cellphone)
|
|
|
* [Detect whether the device is root](#detect-whether-the-device-is-root)
|
|
|
* [Monkey use stress testing](#monkey-use-stress-testing)
|
|
|
* [On / off WiFi](#on--off-wifi)
|
|
|
* [Brush related commands](#brush-related-commands)
|
|
|
* [Restart to Recovery mode](#restart-to-recovery-mode)
|
|
|
* [To restart from the Recovery Android](#to-restart-from-the-recovery-android)
|
|
|
* [Restart to Fastboot mode](#restart-to-fastboot-mode)
|
|
|
* [Through sideload system update](#through-sideload-system-update)
|
|
|
* [More adb shell command](#more-adb-shell-command)
|
|
|
* [See process](#see-process)
|
|
|
* [View real-time resource consumption](#view-real-time-resource-consumption)
|
|
|
* [Other](#other)
|
|
|
* [common problem](#common-problem)
|
|
|
* [Start adb server failure](#start-adb-server-failure)
|
|
|
* [adb unofficial implementation](#adb-unofficial-implementation)
|
|
|
* [Acknowledgements](#acknowledgements)
|
|
|
* [Reference Links](#reference-links)
|
|
|
|
|
|
<!-- vim-markdown-toc -->
|
|
|
|
|
|
## Basic Usage
|
|
|
|
|
|
### Command syntax
|
|
|
|
|
|
adb basic syntax of the command is as follows:
|
|
|
|
|
|
```sh
|
|
|
adb [-d|-e|-s <serialNumber>] <command>
|
|
|
```
|
|
|
|
|
|
If only one device / emulator connection, you can omit the `[-d | -e | -s <serialNumber>]` this part, the direct use `adb <command>`.
|
|
|
|
|
|
### Targeting equipment for command
|
|
|
|
|
|
If you have more than one device / emulator connection, you need to specify the target device for the command.
|
|
|
|
|
|
| Parameter | Meaning |
|
|
|
|---------------------|-----------------------------------------------------------------------------------|
|
|
|
| -d | Specifies currently the only Android device USB connector as the command target |
|
|
|
| -e | Specify currently the only goal for the command to run the simulator |
|
|
|
| `-s <SerialNumber>` | Specifies the device number corresponding serialNumber / simulator command target |
|
|
|
|
|
|
In the case of multiple devices / simulators are connected to the more common `-s <serialNumber>` parameters, serialNumber can be obtained through `adb devices` command. Such as:
|
|
|
|
|
|
```sh
|
|
|
$ adb devices
|
|
|
|
|
|
List of devices attached
|
|
|
cf264b8f device
|
|
|
emulator-5554 device
|
|
|
```
|
|
|
|
|
|
Output in the `cf264b8f` and` emulator-5554` is serialNumber. For example, this time I want to specify `cf264b8f` this equipment to run the adb command to take a screen resolution:
|
|
|
|
|
|
```sh
|
|
|
adb -s cf264b8f shell wm size
|
|
|
```
|
|
|
|
|
|
Encountered multiple devices / simulators use the case of these parameters for the command to specify the target device, hereinafter to simplify the description will not be repeated.
|
|
|
|
|
|
### Start/Stop
|
|
|
|
|
|
Start adb server command:
|
|
|
|
|
|
```sh
|
|
|
adb start-server
|
|
|
```
|
|
|
|
|
|
(Generally no need to manually execute this command, when you run the command adb adb server if found does not start automatically from the transfer.)
|
|
|
|
|
|
Stop adb server command:
|
|
|
|
|
|
```sh
|
|
|
adb kill-server
|
|
|
```
|
|
|
|
|
|
### View adb version
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb version
|
|
|
```
|
|
|
|
|
|
Sample output:
|
|
|
|
|
|
```sh
|
|
|
Android Debug Bridge version 1.0.36
|
|
|
Revision 8f855a3d9b35-android
|
|
|
```
|
|
|
|
|
|
### Run adbd as root
|
|
|
|
|
|
The operating principle is adb adb server daemon and the phone side PC side adbd establish a connection, then the PC side adb client via adb server forward command parsing after running adbd receive commands.
|
|
|
|
|
|
So if adbd ordinary rights to perform some require root privileges to execute the command can not be directly used `adb xxx` execution. Then you can then execute the command `adb shell` after` su`, but also allows adbd root privileges to perform this high privilege can execute arbitrary commands.
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb root
|
|
|
```
|
|
|
|
|
|
Normal output:
|
|
|
|
|
|
```sh
|
|
|
restarting adbd as root
|
|
|
```
|
|
|
|
|
|
Now run `adb shell`, take a look at the command line prompt is not turned into a` `#?
|
|
|
|
|
|
After some phone root can not let adbd by `adb root` execute commands with root privileges, some models such as Samsung, will be prompted to` adbd can not run as root in production builds`, then you can install adbd Insecure, then `adb root` try.
|
|
|
|
|
|
Accordingly, if you want to restore adbd non-root privileges, you can use `adb unroot` command.
|
|
|
|
|
|
### Designated adb server network port
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb -P <port> start-server
|
|
|
```
|
|
|
|
|
|
The default port is 5037.
|
|
|
|
|
|
## Device connection management
|
|
|
|
|
|
### Inquiries connected device / simulator
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb devices
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
List of devices attached
|
|
|
cf264b8f device
|
|
|
emulator-5554 device
|
|
|
```
|
|
|
|
|
|
Output format is `[serialNumber] [state]`, serialNumber that is, we often say that the SN, state the following categories:
|
|
|
|
|
|
* `Offline` - indicates that the device is not connected to the success or unresponsive.
|
|
|
|
|
|
* `Device` - device is connected. Note that this state does not identify the Android system has been fully activated and operational in the device during startup device instance can be connected to the adb, but after boot the system before it becomes operational.
|
|
|
|
|
|
* `No device` - no device / emulator connection.
|
|
|
|
|
|
The output shows the current connected the two devices / simulators, `cf264b8f` and` emulator-5554` are they SN. As can be seen from the `emulator-5554` name it is an Android emulator.
|
|
|
|
|
|
Common alarm output:
|
|
|
|
|
|
1. No device / emulator connection is successful.
|
|
|
|
|
|
```sh
|
|
|
List of devices attached
|
|
|
```
|
|
|
|
|
|
2. The device / emulator is not connected to adb or unresponsive.
|
|
|
|
|
|
```sh
|
|
|
List of devices attached
|
|
|
cf264b8f offline
|
|
|
```
|
|
|
|
|
|
### USB connection
|
|
|
|
|
|
USB connection normal use adb by the need to ensure that:
|
|
|
|
|
|
1. Hardware status is normal.
|
|
|
|
|
|
Including Android devices in the normal power state, USB cable and interface intact.
|
|
|
|
|
|
Developer Options 2. Android devices and USB debugging mode is on.
|
|
|
|
|
|
You can go to the "Settings" - "Developer options" - "Android Debug" view.
|
|
|
|
|
|
If you can not find the developer options in the settings, it needs to make it through an egg is displayed: In the "Settings" - "About phone" continuous click "version number" 7 times.
|
|
|
|
|
|
3. The device driver is normal.
|
|
|
|
|
|
It seems to worry about the Linux and Mac OS X, the Windows likely to be encountered in the case of the need to install drivers, this can be confirmed right "Computer" - "Properties", the "Device Manager" in view on related equipment Is there a yellow exclamation point or question mark, if not explain the driving state has been good. Otherwise, you can download a mobile assistant class program to install the driver first.
|
|
|
|
|
|
4. Status after confirmation via USB cable connected computers and devices.
|
|
|
|
|
|
```sh
|
|
|
adb devices
|
|
|
```
|
|
|
|
|
|
If you can see
|
|
|
|
|
|
```sh
|
|
|
xxxxxx device
|
|
|
```
|
|
|
|
|
|
Description Connection successful.
|
|
|
|
|
|
### Wireless connection (need to use the USB cable)
|
|
|
|
|
|
In addition to the USB connection to the computer to use adb, can also be a wireless connection - although the connection process is also step using USB needs, but after a successful connection to your device can get rid of the limit of the USB cable within a certain range it !
|
|
|
|
|
|
Steps:
|
|
|
|
|
|
1. Connect Android device to run adb computer connected to the same local area network, such as connected to the same WiFi.
|
|
|
|
|
|
2. The device connected to the computer via a USB cable.
|
|
|
|
|
|
Make sure the connection is successful (you can run `adb devices` see if you can list the device).
|
|
|
|
|
|
3. Allow the device listens on port 5555 TCP / IP connections:
|
|
|
|
|
|
```sh
|
|
|
adb tcpip 5555
|
|
|
```
|
|
|
|
|
|
4. Disconnect the USB connection.
|
|
|
|
|
|
5. Find the IP address of the device.
|
|
|
|
|
|
Generally the 'Settings' in - "About phone" - "state information" - "IP address" is found, you can also use the following in the [View device information - IP address][1] a Lane method adb command.
|
|
|
|
|
|
6. Connect the device via IP address.
|
|
|
|
|
|
```sh
|
|
|
adb connect <device-ip-address>
|
|
|
```
|
|
|
|
|
|
Here `<device-ip-address>` is the IP address of the device found in the previous step.
|
|
|
|
|
|
7. Confirm the connection status.
|
|
|
|
|
|
```sh
|
|
|
adb devices
|
|
|
```
|
|
|
|
|
|
If you can see
|
|
|
|
|
|
```sh
|
|
|
<device-ip-address>:5555 device
|
|
|
```
|
|
|
|
|
|
Description Connection successful.
|
|
|
|
|
|
If you can not connect, verify that Android devices and the computer is connected to the same WiFi, then execute `adb connect <device-ip-address>` that step again;
|
|
|
|
|
|
If that does not work, by `adb kill-server` restart the adb and then try it all over again.
|
|
|
|
|
|
**The wireless connection**
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb disconnect <device-ip-address>
|
|
|
```
|
|
|
|
|
|
### Wireless connection (without using the USB cable)
|
|
|
|
|
|
**Note: You need root privileges.**
|
|
|
|
|
|
On a "wireless connection (need to use USB cable)" method is described in official documents, need the help of a USB cable to enable the wireless connection.
|
|
|
|
|
|
Since we want to achieve a wireless connection, it can all step down are wireless it? The answer is energy.
|
|
|
|
|
|
1. Install a terminal emulator on the Android device.
|
|
|
|
|
|
Equipment already installed you can skip this step. Terminal emulator download address I use is: [Terminal Emulator for Android Downloads](https://jackpal.github.io/Android-Terminal-Emulator/)
|
|
|
|
|
|
2. To run the Android device and computer adb is connected to the same local area network, such as connected to the same WiFi.
|
|
|
|
|
|
3. Open a terminal emulator on your Android device, in which run the command sequence:
|
|
|
|
|
|
```sh
|
|
|
su
|
|
|
setprop service.adb.tcp.port 5555
|
|
|
```
|
|
|
|
|
|
4. Find the IP address of the Android device.
|
|
|
|
|
|
Generally the 'Settings' in - "About phone" - "state information" - "IP address" is found, you can also use the following in the [View device information - IP address][1] a Lane method adb command.
|
|
|
|
|
|
5. Connect Android device on a computer via adb and IP addresses.
|
|
|
|
|
|
```sh
|
|
|
adb connect <device-ip-address>
|
|
|
```
|
|
|
|
|
|
Here `<device-ip-address>` is the IP address of the device found in the previous step.
|
|
|
|
|
|
If you can see `connected to <device-ip-address>: 5555` such output indicates a successful connection.
|
|
|
|
|
|
## Application Management
|
|
|
|
|
|
### Check the list of
|
|
|
|
|
|
Check the list of basic commands format
|
|
|
|
|
|
```sh
|
|
|
adb shell pm list packages [-f] [-d] [-e] [-s] [-3] [-i] [-u] [--user USER_ID] [FILTER]
|
|
|
```
|
|
|
|
|
|
That is the basis of `adb shell pm list packages` can add some parameters on the filter to view different lists, supports filtering parameters are as follows:
|
|
|
|
|
|
| Parameter | display list |
|
|
|
|------------|------------------------------------------|
|
|
|
| No | all applications |
|
|
|
| -f | Display apk file application association |
|
|
|
| -d | Show only applications disabled |
|
|
|
| -e | Show only enabled applications |
|
|
|
| -s | Display only System |
|
|
|
| -3 | Show only third-party application |
|
|
|
| -i | Display applications installer |
|
|
|
| -u | Contains uninstall applications |
|
|
|
| `<FILTER>` | package name contains `<FILTER>` strings |
|
|
|
|
|
|
#### All applications
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell pm list packages
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
package:com.android.smoketest
|
|
|
package:com.example.android.livecubes
|
|
|
package:com.android.providers.telephony
|
|
|
package:com.google.android.googlequicksearchbox
|
|
|
package:com.android.providers.calendar
|
|
|
package:com.android.providers.media
|
|
|
package:com.android.protips
|
|
|
package:com.android.documentsui
|
|
|
package:com.android.gallery
|
|
|
package:com.android.externalstorage
|
|
|
...
|
|
|
// other packages here
|
|
|
...
|
|
|
```
|
|
|
|
|
|
#### system applications
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell pm list packages -s
|
|
|
```
|
|
|
|
|
|
#### third-party usage
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell pm list packages -3
|
|
|
```
|
|
|
|
|
|
#### Application package name contains a string
|
|
|
|
|
|
For example, to view a list of package names that contain the string `mazhuang` applications, order:
|
|
|
|
|
|
```sh
|
|
|
adb shell pm list packages mazhuang
|
|
|
```
|
|
|
|
|
|
Of course, you can also use grep to filter:
|
|
|
|
|
|
```sh
|
|
|
adb shell pm list packages | grep mazhuang
|
|
|
```
|
|
|
|
|
|
### Install APK
|
|
|
|
|
|
Format:
|
|
|
|
|
|
```sh
|
|
|
adb install [-lrtsdg] <path_to_apk>
|
|
|
```
|
|
|
|
|
|
parameter:
|
|
|
|
|
|
`Adb install` may be followed by some optional parameters to control the behavior of the installation APK, available parameters and their meanings are as follows:
|
|
|
|
|
|
| Parameter | Meaning |
|
|
|
|-----------|-----------------------------------------------------------------------------------------------------------|
|
|
|
| -l | Will be applied to protect the installation directory / mnt / asec |
|
|
|
| -r | Allowed to cover the installation |
|
|
|
| -t | Allowed to install application specified in AndroidManifest.xml `android: testOnly =" true "` Application |
|
|
|
| -s | Install apps to sdcard |
|
|
|
| -d | Downgrade coverage allows installation |
|
|
|
| -g | Grant all runtime permissions |
|
|
|
|
|
|
After you run the command to see if similar to the following output (status is `Success`) represents the installation was successful:
|
|
|
|
|
|
```sh
|
|
|
[100%] /data/local/tmp/1.apk
|
|
|
pkg: /data/local/tmp/1.apk
|
|
|
Success
|
|
|
```
|
|
|
|
|
|
The above is the output of adb current latest version v1.0.36, it will push apk file to display the progress of the percentage of mobile phones.
|
|
|
|
|
|
Using older versions of adb output is this:
|
|
|
|
|
|
```sh
|
|
|
12040 KB/s (22205609 bytes in 1.801s)
|
|
|
pkg: /data/local/tmp/SogouInput_android_v8.3_sweb.apk
|
|
|
Success
|
|
|
```
|
|
|
|
|
|
If the status is `Failure` said installation failure, such as:
|
|
|
|
|
|
```sh
|
|
|
[100%] /data/local/tmp/map-20160831.apk
|
|
|
pkg: /data/local/tmp/map-20160831.apk
|
|
|
Failure [INSTALL_FAILED_ALREADY_EXISTS]
|
|
|
```
|
|
|
|
|
|
Common Installation failed output code, the meaning and possible solutions are as follows:
|
|
|
|
|
|
| Output | Meaning | solutions |
|
|
|
|----------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
|
|
|
| INSTALL\_FAILED\_ALREADY\_EXISTS | application already exists | use `-r` parameters |
|
|
|
| INSTALL\_FAILED\_INVALID\_APK | invalid APK file | |
|
|
|
| INSTALL\_FAILED\_INVALID\_URI | invalid filename APK | APK file names to ensure no Chinese |
|
|
|
| INSTALL\_FAILED\_INSUFFICIENT\_STORAGE | lack of space | cleanup space |
|
|
|
| INSTALL\_FAILED\_DUPLICATE\_PACKAGE | program of the same name already exists | |
|
|
|
| INSTALL\_FAILED\_NO\_SHARED\_USER | shared user requested does not exist | |
|
|
|
| INSTALL\_FAILED\_UPDATE\_INCOMPATIBLE | already installed signature is not the same application with the same name, and the data is not removed | |
|
|
|
| INSTALL\_FAILED\_SHARED\_USER\_INCOMPATIBLE | shared user request exists but the signatures do not match | |
|
|
|
| INSTALL\_FAILED\_MISSING\_SHARED\_LIBRARY | installation package used on the device unusable shared library | |
|
|
|
| INSTALL\_FAILED\_REPLACE\_COULDNT\_DELETE | can not be deleted when replacing | |
|
|
|
| INSTALL\_FAILED\_DEXOPT | dex optimization validation failure or lack of space | |
|
|
|
| INSTALL\_FAILED\_OLDER\_SDK | equipment system version is lower than the application requirements | |
|
|
|
| INSTALL\_FAILED\_CONFLICTING\_PROVIDER | equipment already exists with the same name in application content provider | |
|
|
|
| INSTALL\_FAILED\_NEWER\_SDK | equipment system version higher than the application requirements | |
|
|
|
| INSTALL\_FAILED\_TEST\_ONLY | test-only applications, but when you install `-t` parameter is not specified | |
|
|
|
| INSTALL\_FAILED\_CPU\_ABI\_INCOMPATIBLE | contains incompatible device CPU Application Binary Interface for native code | |
|
|
|
| INSTALL\_FAILED\_MISSING\_FEATURE | application uses device features that are unavailable | |
|
|
|
| INSTALL\_FAILED\_CONTAINER\_ERROR | sdcard access failure | confirm sdcard is available, or to install built-in storage |
|
|
|
| INSTALL\_FAILED\_INVALID\_INSTALL\_LOCATION | can not be installed to the specified location | switch mounting position, add or delete `-s` parameters |
|
|
|
| INSTALL\_FAILED\_MEDIA\_UNAVAILABLE | installation location is unavailable | generally sdcard, confirm sdcard is available or to install built-in storage |
|
|
|
| INSTALL\_FAILED\_VERIFICATION\_TIMEOUT | Installation Timeout verify | |
|
|
|
| INSTALL\_FAILED\_VERIFICATION\_FAILURE | verify the installation package fails | |
|
|
|
| INSTALL\_FAILED\_PACKAGE\_CHANGED | calling application program expects inconsistent | |
|
|
|
| INSTALL\_FAILED\_UID\_CHANGED | previously installed the app, and this assignment UID inconsistent | remove residual files previously installed |
|
|
|
| INSTALL\_FAILED\_VERSION\_DOWNGRADE | already installed the application later | use `-d` parameters |
|
|
|
| INSTALL\_FAILED\_PERMISSION\_MODEL\_DOWNGRADE | installed target SDK runtime support for application permissions of the same name, to install the runtime version does not support permission | |
|
|
|
| INSTALL\_PARSE\_FAILED\_NOT\_APK | specified path is not a file or not to `.apk` end | |
|
|
|
| INSTALL\_PARSE\_FAILED\_BAD\_MANIFEST | unresolved AndroidManifest.xml file | |
|
|
|
| INSTALL\_PARSE\_FAILED\_UNEXPECTED\_EXCEPTION | parser encounters an exception | |
|
|
|
| INSTALL\_PARSE\_FAILED\_NO\_CERTIFICATES | installation package is not signed | |
|
|
|
| INSTALL\_PARSE\_FAILED\_INCONSISTENT\_CERTIFICATES | already installed the app, and signed with the APK files are inconsistent | first uninstall the application on the device, then install |
|
|
|
| INSTALL\_PARSE\_FAILED\_CERTIFICATE\_ENCODING | encountered while parsing APK file `CertificateEncodingException` | |
|
|
|
| INSTALL\_PARSE\_FAILED\_BAD\_PACKAGE\_NAME | manifest file no or an invalid package name | |
|
|
|
| INSTALL\_PARSE\_FAILED\_BAD\_SHARED\_USER\_ID | manifest file specifies an invalid shared user ID | |
|
|
|
| INSTALL\_PARSE\_FAILED\_MANIFEST\_MALFORMED | encountered while parsing file manifest error structural | |
|
|
|
| INSTALL\_PARSE\_FAILED\_MANIFEST\_EMPTY | in the manifest file can not be found to find operable label (instrumentation or application) | |
|
|
|
| INSTALL\_FAILED\_INTERNAL\_ERROR | installation fails because of system problems | |
|
|
|
| INSTALL\_FAILED\_USER\_RESTRICTED | Users are limited to installing applications | |
|
|
|
| INSTALL\_FAILED\_DUPLICATE\_PERMISSION | application attempts to define an existing permission name | |
|
|
|
| INSTALL\_FAILED\_NO\_MATCHING\_ABIS | applications include device application binary interface does not support the native code | |
|
|
|
| INSTALL\_CANCELED\_BY\_USER | applications installed on the device needs confirmation, but not operate the device or the point of cancellation | agree to install on the device |
|
|
|
| INSTALL\_FAILED\_ACWF\_INCOMPATIBLE | applications are not compatible with the device | |
|
|
|
| Does not contain AndroidManifest.xml | invalid APK file | |
|
|
|
| Is not a valid zip file | invalid APK file | |
|
|
|
| Offline | device is not connected successfully | first device with adb successful connection |
|
|
|
| Unauthorized | unauthorized device allows debugging | |
|
|
|
| Error: device not found | not successfully connected equipment | equipment and adb first successful connection |
|
|
|
| Protocol failure | device is disconnected | first device with adb successful connection |
|
|
|
| Unknown option: -s | Android 2.2 does not support the following installation to sdcard | do not use `-s` parameters |
|
|
|
| No space left on devicerm | lack of space | cleanup space |
|
|
|
| Permission denied ... sdcard ... | sdcard unavailable | |
|
|
|
|
|
|
Reference: [PackageManager.java](https://github.com/android/platform_frameworks_base/blob/master/core%2Fjava%2Fandroid%2Fcontent%2Fpm%2FPackageManager.java)
|
|
|
|
|
|
*`Adb install` internal principle Introduction*
|
|
|
|
|
|
`Adb install` actually three steps:
|
|
|
|
|
|
1. push apk files to / data / local / tmp.
|
|
|
|
|
|
2. Call pm install installation.
|
|
|
|
|
|
3. Delete the corresponding apk file / data / local / tmp under.
|
|
|
|
|
|
Therefore, when necessary, according to this step, manually step through the installation process.
|
|
|
|
|
|
### Uninstalling
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb uninstall [-k] <packagename>
|
|
|
```
|
|
|
|
|
|
`<Packagename>` represents the application package name, `-k` optional parameter indicates uninstall the application but keep the data and cache directories.
|
|
|
|
|
|
Command Example:
|
|
|
|
|
|
```sh
|
|
|
adb uninstall com.qihoo360.mobilesafe
|
|
|
```
|
|
|
|
|
|
Uninstall represents 360 mobile guards.
|
|
|
|
|
|
### Clear app cache data
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell pm clear <packagename>
|
|
|
```
|
|
|
|
|
|
`<Packagename>` represents the name of the application package, the effect of this command is equivalent to the application information in the settings screen, click the "Clear Cache" and "Clear data."
|
|
|
|
|
|
Command Example:
|
|
|
|
|
|
```sh
|
|
|
adb shell pm clear com.qihoo360.mobilesafe
|
|
|
```
|
|
|
|
|
|
360 mobile guards to clear the data and cache.
|
|
|
|
|
|
### View Reception Activity
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell dumpsys activity activities | grep mFocusedActivity
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
mFocusedActivity: ActivityRecord{8079d7e u0 com.cyanogenmod.trebuchet/com.android.launcher3.Launcher t42}
|
|
|
```
|
|
|
|
|
|
Where `com.cyanogenmod.trebuchet / com.android.launcher3.Launcher` is currently in the foreground Activity.
|
|
|
|
|
|
## Applications to interact with
|
|
|
|
|
|
Primarily using `am <command>` command commonly used `<command>` as follows:
|
|
|
|
|
|
| Command | use |
|
|
|
|-----------------------------------|----------------------------------------|
|
|
|
| `Start [options] <INTENT>` | Start `<INTENT>` specified Activity |
|
|
|
| `Startservice [options] <INTENT>` | Start `<INTENT>` designated Service |
|
|
|
| `Broadcast [options] <INTENT>` | Send `<INTENT>` designated broadcast |
|
|
|
| `Force-stop <packagename>` | stop `<packagename>` related processes |
|
|
|
|
|
|
`<INTENT>` very flexible parameters, and write Android program code corresponding to the Intent.
|
|
|
|
|
|
Options for determining intent objects as follows:
|
|
|
|
|
|
| Parameter | Meaning |
|
|
|
|------------------|---------------------------------------------------------------------------------------------------------------------------------------|
|
|
|
| `-a <ACTION>` | specified action, such as `android.intent.action.VIEW` |
|
|
|
| `-c <CATEGORY>` | specify a category, such as `android.intent.category.APP_CONTACTS` |
|
|
|
| `-n <COMPONENT>` | specify the full component name, which is used to explicitly specify the start Activity, such as `com.example.app / .ExampleActivity` |
|
|
|
|
|
|
`<INTENT>` can bring in data, like Bundle write code like:
|
|
|
|
|
|
| Parameter | Meaning |
|
|
|
|------------------------------------------------------------------|----------------------------------------|
|
|
|
| `--esn <EXTRA_KEY>` | null value (only key name) |
|
|
|
| `-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE>` | string value |
|
|
|
| `--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE>` | boolean value |
|
|
|
| `--ei <EXTRA_KEY> <EXTRA_INT_VALUE>` | integer value |
|
|
|
| `--el <EXTRA_KEY> <EXTRA_LONG_VALUE>` | long value |
|
|
|
| `--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE>` | float value |
|
|
|
| `--eu <EXTRA_KEY> <EXTRA_URI_VALUE>` | URI |
|
|
|
| `--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>` | component name |
|
|
|
| `--eia <EXTRA_KEY> <EXTRA_INT_VALUE> [, <EXTRA_INT_VALUE ...]` | integer array |
|
|
|
| `--ela <EXTRA_KEY> <EXTRA_LONG_VALUE> [, <EXTRA_LONG_VALUE ...]` | long array |
|
|
|
|
|
|
### Transferred from Activity
|
|
|
|
|
|
Format:
|
|
|
|
|
|
```sh
|
|
|
adb shell am start [options] <INTENT>
|
|
|
```
|
|
|
|
|
|
E.g:
|
|
|
|
|
|
```sh
|
|
|
adb shell am start -n com.tencent.mm/.ui.LauncherUI
|
|
|
```
|
|
|
|
|
|
It represents transfer from the micro-channel main interface.
|
|
|
|
|
|
```sh
|
|
|
adb shell am start -n org.mazhuang.boottimemeasure/.MainActivity --es "toast" "hello, world"
|
|
|
```
|
|
|
|
|
|
Expressed from the transfer `org.mazhuang.boottimemeasure / .MainActivity` key data string and pass it to` toast - hello, world`.
|
|
|
|
|
|
### Transferred from the Service
|
|
|
|
|
|
Format:
|
|
|
|
|
|
```sh
|
|
|
adb shell am startservice [options] <INTENT>
|
|
|
```
|
|
|
|
|
|
E.g:
|
|
|
|
|
|
```sh
|
|
|
adb shell am startservice -n com.tencent.mm/.plugin.accountsync.model.AccountAuthenticatorService
|
|
|
```
|
|
|
|
|
|
Service represents a transfer from micro-letter.
|
|
|
|
|
|
### Transmits broadcast
|
|
|
|
|
|
Format:
|
|
|
|
|
|
```sh
|
|
|
adb shell am broadcast [options] <INTENT>
|
|
|
```
|
|
|
|
|
|
All components can be broadcast to be broadcast only to the specified component.
|
|
|
|
|
|
For example, all of the components to broadcast `BOOT_COMPLETED`:
|
|
|
|
|
|
```sh
|
|
|
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED
|
|
|
```
|
|
|
|
|
|
As another example, only to `org.mazhuang.boottimemeasure / .BootCompletedReceiver` broadcast` BOOT_COMPLETED`:
|
|
|
|
|
|
```sh
|
|
|
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -n org.mazhuang.boottimemeasure/.BootCompletedReceiver
|
|
|
```
|
|
|
|
|
|
Such usage is very practical in the test, such as a broadcast scenes difficult to manufacture, can be considered to transmit broadcast in this way.
|
|
|
|
|
|
Both predefined broadcast transmission system can also send a custom broadcast. The following is part of the normal pre-defined radio and Trigger timing:
|
|
|
|
|
|
| Action | trigger timing |
|
|
|
|-------------------------------------------------|--------------------------------------------------------------------|
|
|
|
| android.net.conn.CONNECTIVITY_CHANGE | Fi changes |
|
|
|
| android.intent.action.SCREEN_ON | screen lit |
|
|
|
| android.intent.action.SCREEN_OFF | screen off |
|
|
|
| android.intent.action.BATTERY_LOW | low battery, low battery prompt box will pop up |
|
|
|
| android.intent.action.BATTERY_OKAY | electricity restored |
|
|
|
| android.intent.action.BOOT_COMPLETED | equipment Booted |
|
|
|
| android.intent.action.DEVICE_STORAGE_LOW | storage space is running low |
|
|
|
| android.intent.action.DEVICE_STORAGE_OK | storage space recovery |
|
|
|
| android.intent.action.PACKAGE_ADDED | install a new application |
|
|
|
| android.net.wifi.STATE_CHANGE | WiFi connection status change |
|
|
|
| android.net.wifi.WIFI_STATE_CHANGED | WiFi state to the On / Off / Starting up / shutting down / Unknown |
|
|
|
| android.intent.action.BATTERY_CHANGED | battery level changes |
|
|
|
| android.intent.action.INPUT_METHOD_CHANGED | system input method changes |
|
|
|
| android.intent.action.ACTION_POWER_CONNECTED | external power connector |
|
|
|
| android.intent.action.ACTION_POWER_DISCONNECTED | disconnected from external power |
|
|
|
| android.intent.action.DREAMING_STARTED | system began Sleep |
|
|
|
| android.intent.action.DREAMING_STOPPED | system stops Sleep |
|
|
|
| android.intent.action.WALLPAPER_CHANGED | wallpaper changes |
|
|
|
| android.intent.action.HEADSET_PLUG | insert earphone |
|
|
|
| android.intent.action.MEDIA_UNMOUNTED | unload external media |
|
|
|
| android.intent.action.MEDIA_MOUNTED | mount external media |
|
|
|
| android.os.action.POWER_SAVE_MODE_CHANGED | power-saving mode is turned on |
|
|
|
|
|
|
* (Above broadcast can be used to trigger adb) *
|
|
|
|
|
|
### Forcibly stop the application
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell am force-stop <packagename>
|
|
|
```
|
|
|
|
|
|
Command Example:
|
|
|
|
|
|
```sh
|
|
|
adb shell am force-stop com.qihoo360.mobilesafe
|
|
|
```
|
|
|
|
|
|
Stop all processes and services represents 360 security guards.
|
|
|
|
|
|
## File Management
|
|
|
|
|
|
### Copy files to the computer equipment in
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb pull <file path on device> [directory on the computer]
|
|
|
```
|
|
|
|
|
|
The parameters on which the directory `` computer can be omitted, it defaults to the current directory.
|
|
|
|
|
|
example:
|
|
|
|
|
|
```sh
|
|
|
adb pull /sdcard/sr.mp4 ~/tmp/
|
|
|
```
|
|
|
|
|
|
* Tips: * file path on the device may need root privileges to access, if your equipment has been root, you can use the `adb shell` and` su` command to obtain root privileges adb shell Lane after the first `cp / path / on / device / sdcard / filename` copy files to sdcard, then `adb pull / sdcard / filename / path / on / pc`.
|
|
|
|
|
|
### Copy computer files to the device
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb push <file path on your computer> <equipment in the catalog>
|
|
|
```
|
|
|
|
|
|
example:
|
|
|
|
|
|
```sh
|
|
|
adb push ~/sr.mp4 /sdcard/
|
|
|
```
|
|
|
|
|
|
* Tips: * file on the path of ordinary privileges may not be directly written to the device if you have root too, can be `adb push / path / on / pc / sdcard / filename`, and then` `adb shell` after su` obtain root privileges adb shell inside, `cp / sdcard / filename / path / on / device`.
|
|
|
|
|
|
## Analog Keys / inputs
|
|
|
|
|
|
In `adb shell` there is a very useful command called` input`, through which you can do some interesting things.
|
|
|
|
|
|
`Complete help information input` command is as follows:
|
|
|
|
|
|
```sh
|
|
|
Usage: input [<source>] <command> [<arg>...]
|
|
|
|
|
|
The sources are:
|
|
|
mouse
|
|
|
keyboard
|
|
|
joystick
|
|
|
touchnavigation
|
|
|
touchpad
|
|
|
trackball
|
|
|
stylus
|
|
|
dpad
|
|
|
gesture
|
|
|
touchscreen
|
|
|
gamepad
|
|
|
|
|
|
The commands and default sources are:
|
|
|
text <string> (Default: touchscreen)
|
|
|
keyevent [--longpress] <key code number or name> ... (Default: keyboard)
|
|
|
tap <x> <y> (Default: touchscreen)
|
|
|
swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)
|
|
|
press (Default: trackball)
|
|
|
roll <dx> <dy> (Default: trackball)
|
|
|
```
|
|
|
|
|
|
Such as using `adb shell input keyevent <keycode>` command, different keycode to achieve different functions, keycode complete list see [KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html), I think the interesting part of the quote is as follows:
|
|
|
|
|
|
| Keycode | Meaning |
|
|
|
|---------|--------------------------------------------------------------|
|
|
|
| 3 | HOME button |
|
|
|
| 4 | return key |
|
|
|
| 5 | open dialing application |
|
|
|
| 6 | hang up |
|
|
|
| 24 | increase volume |
|
|
|
| 25 | Volume Down |
|
|
|
| 26 | Power button |
|
|
|
| 27 | taking pictures (in the camera application needs in) |
|
|
|
| 64 | Open Browser |
|
|
|
| 82 | menu button |
|
|
|
| 85 | Play / Pause |
|
|
|
| 86 | stop playing |
|
|
|
| 87 | play the next |
|
|
|
| 88 | played on a |
|
|
|
| 122 | Move the cursor to the beginning or top of the list |
|
|
|
| 123 | Move the cursor to the end of the line or bottom of the list |
|
|
|
| 126 | resume playing |
|
|
|
| 127 | pause play |
|
|
|
| 164 | Mute |
|
|
|
| 176 | Open the System Setup |
|
|
|
| 187 | switching applications |
|
|
|
| 207 | Open Contacts |
|
|
|
| 208 | Open calendar |
|
|
|
| 209 | Open Music |
|
|
|
| 210 | Open Calculator |
|
|
|
| 220 | Decrease screen brightness |
|
|
|
| 221 | Increase screen brightness |
|
|
|
| 223 | System Sleep |
|
|
|
| 224 | light up the screen |
|
|
|
| 231 | Open the voice assistant |
|
|
|
| 276 | If no wakelock allow the system to sleep |
|
|
|
|
|
|
Here are some examples of the use of `input` command.
|
|
|
|
|
|
### Power button
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell input keyevent 26
|
|
|
```
|
|
|
|
|
|
Executive effect equivalent to pressing the power button.
|
|
|
|
|
|
### menu
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell input keyevent 82
|
|
|
```
|
|
|
|
|
|
### HOME key
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell input keyevent 3
|
|
|
```
|
|
|
|
|
|
### return key
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell input keyevent 4
|
|
|
```
|
|
|
|
|
|
### volume control
|
|
|
|
|
|
Increase the volume:
|
|
|
|
|
|
```sh
|
|
|
adb shell input keyevent 24
|
|
|
```
|
|
|
|
|
|
lower the volume:
|
|
|
|
|
|
```sh
|
|
|
adb shell input keyevent 25
|
|
|
```
|
|
|
|
|
|
Mute:
|
|
|
|
|
|
```sh
|
|
|
adb shell input keyevent 164
|
|
|
```
|
|
|
|
|
|
### Media Control
|
|
|
|
|
|
play / Pause:
|
|
|
|
|
|
```sh
|
|
|
adb shell input keyevent 85
|
|
|
```
|
|
|
|
|
|
Stop play:
|
|
|
|
|
|
```sh
|
|
|
adb shell input keyevent 86
|
|
|
```
|
|
|
|
|
|
Play the next song:
|
|
|
|
|
|
```sh
|
|
|
adb shell input keyevent 87
|
|
|
```
|
|
|
|
|
|
Played on one:
|
|
|
|
|
|
```sh
|
|
|
adb shell input keyevent 88
|
|
|
```
|
|
|
|
|
|
Resume playback:
|
|
|
|
|
|
```sh
|
|
|
adb shell input keyevent 126
|
|
|
```
|
|
|
|
|
|
Pause playback:
|
|
|
|
|
|
```sh
|
|
|
adb shell input keyevent 127
|
|
|
```
|
|
|
|
|
|
### On / Off screen
|
|
|
|
|
|
It can be switched on and off by telling off the screen above the analog power button, but if you want to light up or clear off the screen, then you can use the following method.
|
|
|
|
|
|
Light up the screen:
|
|
|
|
|
|
```sh
|
|
|
adb shell input keyevent 224
|
|
|
```
|
|
|
|
|
|
Off screen:
|
|
|
|
|
|
```sh
|
|
|
adb shell input keyevent 223
|
|
|
```
|
|
|
|
|
|
### Slide to unlock
|
|
|
|
|
|
If no password lock screen is unlocked by sliding gestures, so you can `input swipe` to unlock.
|
|
|
|
|
|
Command (parameter models Nexus 5, swipe up to unlock, for example):
|
|
|
|
|
|
```sh
|
|
|
adb shell input swipe 300 1000 300 500
|
|
|
```
|
|
|
|
|
|
`3001000300 parameters represent` 500` starting x coordinate of the start point y coordinate of the end point x coordinate y coordinate of the end point '.
|
|
|
|
|
|
### Enter text
|
|
|
|
|
|
When the focus is in a text box, you can enter text by `input` command.
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell input text hello
|
|
|
```
|
|
|
|
|
|
`Hello` now appear in the text box.
|
|
|
|
|
|
## View Log
|
|
|
|
|
|
Log Android system is divided into two parts, the underlying Linux kernel log output to / proc / kmsg, Android's log output to / dev / log.
|
|
|
|
|
|
### Android log
|
|
|
|
|
|
Format:
|
|
|
|
|
|
```sh
|
|
|
[adb] logcat [<option>] ... [<filter-spec>] ...
|
|
|
```
|
|
|
|
|
|
Common usage are listed below:
|
|
|
|
|
|
### Filter the log by level
|
|
|
|
|
|
Android log divided into the following levels:
|
|
|
|
|
|
* V - Verbose (lowest output most)
|
|
|
* D - Debug
|
|
|
* I - Info
|
|
|
* W - Warning
|
|
|
* E - Error
|
|
|
* F - Fatal
|
|
|
* S - Silent (highest, what is not output)
|
|
|
|
|
|
Press a grade level and above filter log is the log output.
|
|
|
|
|
|
For example, the command:
|
|
|
|
|
|
```sh
|
|
|
adb logcat *:W
|
|
|
```
|
|
|
|
|
|
Will Warning, Error, Fatal and Silent log output.
|
|
|
|
|
|
#### Filter by tag and log level
|
|
|
|
|
|
For example, the command:
|
|
|
|
|
|
```sh
|
|
|
adb logcat ActivityManager:I MyApp:D *:S
|
|
|
```
|
|
|
|
|
|
Represents an output tag `ActivityManager` above the level of Info logs, Debug log output above the level of the tag` MyApp`, and other tag Silent level of log (ie, shield other tag logging).
|
|
|
|
|
|
#### Log format
|
|
|
|
|
|
You can use `adb logcat -v <format>` option specifies log output format.
|
|
|
|
|
|
Log supported by the following `<format>`:
|
|
|
|
|
|
* brief
|
|
|
|
|
|
The default format. The format is:
|
|
|
|
|
|
```sh
|
|
|
<priority>/<tag>(<pid>): <message>
|
|
|
```
|
|
|
|
|
|
Example:
|
|
|
|
|
|
```sh
|
|
|
D/HeadsetStateMachine( 1785): Disconnected process message: 10, size: 0
|
|
|
```
|
|
|
|
|
|
* process
|
|
|
|
|
|
The format is:
|
|
|
|
|
|
```sh
|
|
|
<priority>(<pid>) <message>
|
|
|
```
|
|
|
|
|
|
Example:
|
|
|
|
|
|
```sh
|
|
|
D( 1785) Disconnected process message: 10, size: 0 (HeadsetStateMachine)
|
|
|
```
|
|
|
|
|
|
* tag
|
|
|
|
|
|
The format is:
|
|
|
|
|
|
```sh
|
|
|
<priority>/<tag>: <message>
|
|
|
```
|
|
|
|
|
|
Example:
|
|
|
|
|
|
```sh
|
|
|
D/HeadsetStateMachine: Disconnected process message: 10, size: 0
|
|
|
```
|
|
|
|
|
|
* raw
|
|
|
|
|
|
The format is:
|
|
|
|
|
|
```sh
|
|
|
<message>
|
|
|
```
|
|
|
|
|
|
Example:
|
|
|
|
|
|
```sh
|
|
|
Disconnected process message: 10, size: 0
|
|
|
```
|
|
|
|
|
|
* time
|
|
|
|
|
|
The format is:
|
|
|
|
|
|
```sh
|
|
|
<datetime> <priority>/<tag>(<pid>): <message>
|
|
|
```
|
|
|
|
|
|
Example:
|
|
|
|
|
|
```sh
|
|
|
08-28 22:39:39.974 D/HeadsetStateMachine( 1785): Disconnected process message: 10, size: 0
|
|
|
```
|
|
|
|
|
|
* threadtime
|
|
|
|
|
|
The format is:
|
|
|
|
|
|
```sh
|
|
|
<datetime> <pid> <tid> <priority> <tag>: <message>
|
|
|
```
|
|
|
|
|
|
Example:
|
|
|
|
|
|
```sh
|
|
|
08-28 22:39:39.974 1785 1832 D HeadsetStateMachine: Disconnected process message: 10, size: 0
|
|
|
```
|
|
|
|
|
|
* long
|
|
|
|
|
|
The format is:
|
|
|
|
|
|
```sh
|
|
|
[ <datetime> <pid>:<tid> <priority>/<tag> ]
|
|
|
<message>
|
|
|
```
|
|
|
|
|
|
Example:
|
|
|
|
|
|
```sh
|
|
|
[ 08-28 22:39:39.974 1785: 1832 D/HeadsetStateMachine ]
|
|
|
Disconnected process message: 10, size: 0
|
|
|
```
|
|
|
|
|
|
Specified format can be used simultaneously with the above filter. such as:
|
|
|
|
|
|
```sh
|
|
|
adb logcat -v long ActivityManager:I *:S
|
|
|
```
|
|
|
|
|
|
#### Clear log
|
|
|
|
|
|
```sh
|
|
|
adb logcat -c
|
|
|
```
|
|
|
|
|
|
### Kernel log
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell dmesg
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
<6>[14201.684016] PM: noirq resume of devices complete after 0.982 msecs
|
|
|
<6>[14201.685525] PM: early resume of devices complete after 0.838 msecs
|
|
|
<6>[14201.753642] PM: resume of devices complete after 68.106 msecs
|
|
|
<4>[14201.755954] Restarting tasks ... done.
|
|
|
<6>[14201.771229] PM: suspend exit 2016-08-28 13:31:32.679217193 UTC
|
|
|
<6>[14201.872373] PM: suspend entry 2016-08-28 13:31:32.780363596 UTC
|
|
|
<6>[14201.872498] PM: Syncing filesystems ... done.
|
|
|
```
|
|
|
|
|
|
In brackets `[14201.684016]` time represents the core begins to start in seconds.
|
|
|
|
|
|
By kernel log, we can do some things, such as a measure of the kernel boot time, `Freeing init memory` find that time is in front of the line after system startup, the kernel log.
|
|
|
|
|
|
## View device information
|
|
|
|
|
|
### Model
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell getprop ro.product.model
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
Nexus 5
|
|
|
```
|
|
|
|
|
|
### Battery Status
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell dumpsys battery
|
|
|
```
|
|
|
|
|
|
Input Example:
|
|
|
|
|
|
```sh
|
|
|
Current Battery Service state:
|
|
|
AC powered: false
|
|
|
USB powered: true
|
|
|
Wireless powered: false
|
|
|
status: 2
|
|
|
health: 2
|
|
|
present: true
|
|
|
level: 44
|
|
|
scale: 100
|
|
|
voltage: 3872
|
|
|
temperature: 280
|
|
|
technology: Li-poly
|
|
|
```
|
|
|
|
|
|
`Scale` which represents the maximum power,` level` represents the current power. The above output represents 44% of remaining power.
|
|
|
|
|
|
### Screen Resolution
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell wm size
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
Physical size: 1080x1920
|
|
|
```
|
|
|
|
|
|
The device's screen resolution is 1080px * 1920px.
|
|
|
|
|
|
### Screen density
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell wm density
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
Physical density: 420
|
|
|
```
|
|
|
|
|
|
The device screen density of 420dpi.
|
|
|
|
|
|
### Display Parameters
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell dumpsys window displays
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
WINDOW MANAGER DISPLAY CONTENTS (dumpsys window displays)
|
|
|
Display: mDisplayId=0
|
|
|
init=1080x1920 420dpi cur=1080x1920 app=1080x1794 rng=1080x1017-1810x1731
|
|
|
deferred=false layoutNeeded=false
|
|
|
```
|
|
|
|
|
|
Where `mDisplayId` to display numbers,` init` initial resolution and screen density, `app` height than` init` in the smaller, bottom of the screen indicates the virtual keys and a height of 1920 - 1794 = 126px co 42dp .
|
|
|
|
|
|
### android\_id
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell settings get secure android_id
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
51b6be48bac8c569
|
|
|
```
|
|
|
|
|
|
### IMEI
|
|
|
|
|
|
In Android 4.4 and below versions are available through the following command IMEI:
|
|
|
|
|
|
```sh
|
|
|
adb shell dumpsys iphonesubinfo
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
Phone Subscriber Info:
|
|
|
Phone Type = GSM
|
|
|
Device ID = 860955027785041
|
|
|
```
|
|
|
|
|
|
`Device ID` which is IMEI.
|
|
|
|
|
|
In Android 5.0 and above in the command output is empty, was acquired by other means (requires root privileges):
|
|
|
|
|
|
```sh
|
|
|
adb shell
|
|
|
su
|
|
|
service call iphonesubinfo 1
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
Result: Parcel(
|
|
|
0x00000000: 00000000 0000000f 00360038 00390030 '........8.6.0.9.'
|
|
|
0x00000010: 00350035 00320030 00370037 00350038 '5.5.0.2.7.7.8.5.'
|
|
|
0x00000020: 00340030 00000031 '0.4.1... ')
|
|
|
```
|
|
|
|
|
|
The effective content is extracted from the inside of the IMEI, such as here is `860955027785041`.
|
|
|
|
|
|
Reference: [adb shell dumpsys iphonesubinfo not working since Android 5.0 Lollipop](http://stackoverflow.com/questions/27002663/adb-shell-dumpsys-iphonesubinfo-not-working-since-android-5-0-lollipop)
|
|
|
|
|
|
### Android system version
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell getprop ro.build.version.release
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
5.0.2
|
|
|
```
|
|
|
|
|
|
### IP address
|
|
|
|
|
|
Every time you want to know the IP address of the device had the "Setting" - "About phone" - "state information" - "IP address" annoying, right? You can easily see via adb.
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell ifconfig | grep Mask
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
inet addr:10.130.245.230 Mask:255.255.255.252
|
|
|
inet addr:127.0.0.1 Mask:255.0.0.0
|
|
|
```
|
|
|
|
|
|
So it is `10.130.245.230` device IP address.
|
|
|
|
|
|
On some devices this command no output, if the device is attached to WiFi, you can use the following command to view the LAN IP:
|
|
|
|
|
|
```sh
|
|
|
adb shell ifconfig wlan0
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
wlan0: ip 10.129.160.99 mask 255.255.240.0 flags [up broadcast running multicast]
|
|
|
```
|
|
|
|
|
|
or
|
|
|
|
|
|
```sh
|
|
|
wlan0 Link encap:UNSPEC
|
|
|
inet addr:10.129.168.57 Bcast:10.129.175.255 Mask:255.255.240.0
|
|
|
inet6 addr: fe80::66cc:2eff:fe68:b6b6/64 Scope: Link
|
|
|
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
|
|
|
RX packets:496520 errors:0 dropped:0 overruns:0 frame:0
|
|
|
TX packets:68215 errors:0 dropped:0 overruns:0 carrier:0
|
|
|
collisions:0 txqueuelen:3000
|
|
|
RX bytes:116266821 TX bytes:8311736
|
|
|
```
|
|
|
|
|
|
If the above command still can not get the desired information, then you can try the following command (part of the system version is available):
|
|
|
|
|
|
```sh
|
|
|
adb shell netcfg
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
wlan0 UP 10.129.160.99/20 0x00001043 f8:a9:d0:17:42:4d
|
|
|
lo UP 127.0.0.1/8 0x00000049 00:00:00:00:00:00
|
|
|
p2p0 UP 0.0.0.0/0 0x00001003 fa:a9:d0:17:42:4d
|
|
|
sit0 DOWN 0.0.0.0/0 0x00000080 00:00:00:00:00:00
|
|
|
rmnet0 DOWN 0.0.0.0/0 0x00000000 00:00:00:00:00:00
|
|
|
rmnet1 DOWN 0.0.0.0/0 0x00000000 00:00:00:00:00:00
|
|
|
rmnet3 DOWN 0.0.0.0/0 0x00000000 00:00:00:00:00:00
|
|
|
rmnet2 DOWN 0.0.0.0/0 0x00000000 00:00:00:00:00:00
|
|
|
rmnet4 DOWN 0.0.0.0/0 0x00000000 00:00:00:00:00:00
|
|
|
rmnet6 DOWN 0.0.0.0/0 0x00000000 00:00:00:00:00:00
|
|
|
rmnet5 DOWN 0.0.0.0/0 0x00000000 00:00:00:00:00:00
|
|
|
rmnet7 DOWN 0.0.0.0/0 0x00000000 00:00:00:00:00:00
|
|
|
rev_rmnet3 DOWN 0.0.0.0/0 0x00001002 4e:b7:e4:2e:17:58
|
|
|
rev_rmnet2 DOWN 0.0.0.0/0 0x00001002 4e:f0:c8:bf:7a:cf
|
|
|
rev_rmnet4 DOWN 0.0.0.0/0 0x00001002 a6:c0:3b:6b:c4:1f
|
|
|
rev_rmnet6 DOWN 0.0.0.0/0 0x00001002 66:bb:5d:64:2e:e9
|
|
|
rev_rmnet5 DOWN 0.0.0.0/0 0x00001002 0e:1b:eb:b9:23:a0
|
|
|
rev_rmnet7 DOWN 0.0.0.0/0 0x00001002 7a:d9:f6:81:40:5a
|
|
|
rev_rmnet8 DOWN 0.0.0.0/0 0x00001002 4e:e2:a9:bb:d0:1b
|
|
|
rev_rmnet0 DOWN 0.0.0.0/0 0x00001002 fe:65:d0:ca:82:a9
|
|
|
rev_rmnet1 DOWN 0.0.0.0/0 0x00001002 da:d8:e8:4f:2e:fe
|
|
|
```
|
|
|
|
|
|
You can see the network connection name, enabled, IP address and Mac address and other information.
|
|
|
|
|
|
### Mac Address
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell cat /sys/class/net/wlan0/address
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
f8:a9:d0:17:42:4d
|
|
|
```
|
|
|
|
|
|
This view is LAN Mac address, or other information connected to the mobile network can `adb shell netcfg` command" IP address "mentioned in the previous section to see through.
|
|
|
|
|
|
### CPU Information
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell cat /proc/cpuinfo
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
Processor : ARMv7 Processor rev 0 (v7l)
|
|
|
processor : 0
|
|
|
BogoMIPS : 38.40
|
|
|
|
|
|
processor : 1
|
|
|
BogoMIPS : 38.40
|
|
|
|
|
|
processor : 2
|
|
|
BogoMIPS : 38.40
|
|
|
|
|
|
processor : 3
|
|
|
BogoMIPS : 38.40
|
|
|
|
|
|
Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt
|
|
|
CPU implementer : 0x51
|
|
|
CPU architecture: 7
|
|
|
CPU variant : 0x2
|
|
|
CPU part : 0x06f
|
|
|
CPU revision : 0
|
|
|
|
|
|
Hardware : Qualcomm MSM 8974 HAMMERHEAD (Flattened Device Tree)
|
|
|
Revision : 000b
|
|
|
Serial : 0000000000000000
|
|
|
```
|
|
|
|
|
|
This is the CPU information Nexus 5, we can see from the output hardware used is `Qualcomm MSM 8974`, processor number is 0-3, so it is a quad-core, the use of architecture is` ARMv7 Processor rev 0 ( v71) `.
|
|
|
|
|
|
### Memory Information
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell cat /proc/meminfo
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
MemTotal: 1027424 kB
|
|
|
MemFree: 486564 kB
|
|
|
Buffers: 15224 kB
|
|
|
Cached: 72464 kB
|
|
|
SwapCached: 24152 kB
|
|
|
Active: 110572 kB
|
|
|
Inactive: 259060 kB
|
|
|
Active(anon): 79176 kB
|
|
|
Inactive(anon): 207736 kB
|
|
|
Active(file): 31396 kB
|
|
|
Inactive(file): 51324 kB
|
|
|
Unevictable: 3948 kB
|
|
|
Mlocked: 0 kB
|
|
|
HighTotal: 409600 kB
|
|
|
HighFree: 132612 kB
|
|
|
LowTotal: 617824 kB
|
|
|
LowFree: 353952 kB
|
|
|
SwapTotal: 262140 kB
|
|
|
SwapFree: 207572 kB
|
|
|
Dirty: 0 kB
|
|
|
Writeback: 0 kB
|
|
|
AnonPages: 265324 kB
|
|
|
Mapped: 47072 kB
|
|
|
Shmem: 1020 kB
|
|
|
Slab: 57372 kB
|
|
|
SReclaimable: 7692 kB
|
|
|
SUnreclaim: 49680 kB
|
|
|
KernelStack: 4512 kB
|
|
|
PageTables: 5912 kB
|
|
|
NFS_Unstable: 0 kB
|
|
|
Bounce: 0 kB
|
|
|
WritebackTmp: 0 kB
|
|
|
CommitLimit: 775852 kB
|
|
|
Committed_AS: 13520632 kB
|
|
|
VmallocTotal: 385024 kB
|
|
|
VmallocUsed: 61004 kB
|
|
|
VmallocChunk: 209668 kB
|
|
|
```
|
|
|
|
|
|
Wherein, `MemTotal` is the total memory device,` MemFree` is currently free memory.
|
|
|
|
|
|
### More hardware and system properties
|
|
|
|
|
|
More hardware devices and system properties can be obtained by the following command:
|
|
|
|
|
|
```sh
|
|
|
adb shell cat /system/build.prop
|
|
|
```
|
|
|
|
|
|
This will output a lot of information, including the previously mentioned several sections of "model" and "version of Android," and so on.
|
|
|
|
|
|
In output also includes some other useful information, they can also be `adb shell getprop <attribute name>` command alone, part of the property include the following:
|
|
|
|
|
|
| Attribute name | Meaning |
|
|
|
|---------------------------------|-------------------------------|
|
|
|
| ro.build.version.sdk | SDK version |
|
|
|
| ro.build.version.release | Android system version |
|
|
|
| ro.build.version.security_patch | Android security patch level |
|
|
|
| ro.product.model | Type |
|
|
|
| ro.product.brand | Brands |
|
|
|
| ro.product.name | device name |
|
|
|
| ro.product.board | Processor Model |
|
|
|
| ro.product.cpu.abilist | CPU support list abi |
|
|
|
| persist.sys.isUsbOtgEnabled | supports OTG |
|
|
|
| dalvik.vm.heapsize | each application's memory cap |
|
|
|
| ro.sf.lcd_density | screen density |
|
|
|
|
|
|
## Utility functions
|
|
|
|
|
|
### Screenshots
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell screencap -p /sdcard/sc.png
|
|
|
```
|
|
|
|
|
|
And then export the png file to your computer:
|
|
|
|
|
|
```sh
|
|
|
adb pull /sdcard/sc.png
|
|
|
```
|
|
|
|
|
|
You can use the `adb shell screencap -h` See` help screencap` command, here are two significant parameters and their meanings:
|
|
|
|
|
|
| Parameter | Meaning |
|
|
|
|---------------|------------------------------------------------------------------------------|
|
|
|
| -p | Save the file in png format specified |
|
|
|
| -d Display-id | screenshots display the specified number (multiple screen display case next) |
|
|
|
|
|
|
Found If you specify a file name can be omitted when the -p parameter to `.png` ending; otherwise you need to use the -p parameter. If you do not specify a file name, file contents screenshot will be directly output to stdout.
|
|
|
|
|
|
### Recording Screen
|
|
|
|
|
|
Record screen are saved in mp4 format to / sdcard:
|
|
|
|
|
|
```sh
|
|
|
adb shell screenrecord /sdcard/filename.mp4
|
|
|
```
|
|
|
|
|
|
When you need to stop press <kbd> Ctrl-C </ kbd>, the default recording time and maximum recording time is 180 seconds.
|
|
|
|
|
|
If you need to export to your computer:
|
|
|
|
|
|
```sh
|
|
|
adb pull /sdcard/filename.mp4
|
|
|
```
|
|
|
|
|
|
You can use the `adb shell screenrecord --help` See` help screenrecord` command, the following are common parameters and their meanings:
|
|
|
|
|
|
| Parameter | Meaning |
|
|
|
|---------------------|-------------------------------------------------------------------------|
|
|
|
| --size WIDTHxHEIGHT | dimensions of the video, such as `1280x720`, default screen resolution. |
|
|
|
| --bit-Rate RATE | bit-rate video, the default is 4Mbps. |
|
|
|
| --time-Limit TIME | recording length, in seconds. |
|
|
|
| --verbose | Print more information. |
|
|
|
|
|
|
### Remount system partition as writable
|
|
|
|
|
|
**Note: You need root privileges.**
|
|
|
|
|
|
/system partitions are mounted read-only, but some operating systems such as Android to add commands to remove the need to bring their own application / system write operation, it is necessary to remount it read-write.
|
|
|
|
|
|
step:
|
|
|
|
|
|
1. Enter the shell and switch to the root user privileges.
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell
|
|
|
su
|
|
|
```
|
|
|
|
|
|
2. View the current partition mounted case.
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
mount
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
rootfs / rootfs ro,relatime 0 0
|
|
|
tmpfs /dev tmpfs rw,seclabel,nosuid,relatime,mode=755 0 0
|
|
|
devpts /dev/pts devpts rw,seclabel,relatime,mode=600 0 0
|
|
|
proc /proc proc rw,relatime 0 0
|
|
|
sysfs /sys sysfs rw,seclabel,relatime 0 0
|
|
|
selinuxfs /sys/fs/selinux selinuxfs rw,relatime 0 0
|
|
|
debugfs /sys/kernel/debug debugfs rw,relatime 0 0
|
|
|
none /var tmpfs rw,seclabel,relatime,mode=770,gid=1000 0 0
|
|
|
none /acct cgroup rw,relatime,cpuacct 0 0
|
|
|
none /sys/fs/cgroup tmpfs rw,seclabel,relatime,mode=750,gid=1000 0 0
|
|
|
none /sys/fs/cgroup/memory cgroup rw,relatime,memory 0 0
|
|
|
tmpfs /mnt/asec tmpfs rw,seclabel,relatime,mode=755,gid=1000 0 0
|
|
|
tmpfs /mnt/obb tmpfs rw,seclabel,relatime,mode=755,gid=1000 0 0
|
|
|
none /dev/memcg cgroup rw,relatime,memory 0 0
|
|
|
none /dev/cpuctl cgroup rw,relatime,cpu 0 0
|
|
|
none /sys/fs/cgroup tmpfs rw,seclabel,relatime,mode=750,gid=1000 0 0
|
|
|
none /sys/fs/cgroup/memory cgroup rw,relatime,memory 0 0
|
|
|
none /sys/fs/cgroup/freezer cgroup rw,relatime,freezer 0 0
|
|
|
/dev/block/platform/msm_sdcc.1/by-name/system /system ext4 ro,seclabel,relatime,data=ordered 0 0
|
|
|
/dev/block/platform/msm_sdcc.1/by-name/userdata /data ext4 rw,seclabel,nosuid,nodev,relatime,noauto_da_alloc,data=ordered 0 0
|
|
|
/dev/block/platform/msm_sdcc.1/by-name/cache /cache ext4 rw,seclabel,nosuid,nodev,relatime,data=ordered 0 0
|
|
|
/dev/block/platform/msm_sdcc.1/by-name/persist /persist ext4 rw,seclabel,nosuid,nodev,relatime,data=ordered 0 0
|
|
|
/dev/block/platform/msm_sdcc.1/by-name/modem /firmware vfat ro,context=u:object_r:firmware_file:s0,relatime,uid=1000,gid=1000,fmask=0337,dmask=0227,codepage=cp437,iocharset=iso8859-1,shortname=lower,errors=remount-ro 0 0
|
|
|
/dev/fuse /mnt/shell/emulated fuse rw,nosuid,nodev,relatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0
|
|
|
/dev/fuse /mnt/shell/emulated/0 fuse rw,nosuid,nodev,relatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0
|
|
|
```
|
|
|
|
|
|
Find one of our concerns with the / system of the line:
|
|
|
|
|
|
```sh
|
|
|
/dev/block/platform/msm_sdcc.1/by-name/system /system ext4 ro,seclabel,relatime,data=ordered 0 0
|
|
|
```
|
|
|
|
|
|
3. remount.
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
mount -o remount,rw -t yaffs2 /dev/block/platform/msm_sdcc.1/by-name/system /system
|
|
|
```
|
|
|
|
|
|
Here `/ dev / block / platform / msm_sdcc.1 / by-name / system` is we get the file path from the output in the previous step.
|
|
|
|
|
|
If the output is not an error, then the operation is successful, you can file / system under wanted.
|
|
|
|
|
|
### Check connection over WiFi password
|
|
|
|
|
|
**Note: You need root privileges.**
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell
|
|
|
su
|
|
|
cat /data/misc/wifi/*.conf
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
network={
|
|
|
ssid="TP-LINK_9DFC"
|
|
|
scan_ssid=1
|
|
|
psk="123456789"
|
|
|
key_mgmt=WPA-PSK
|
|
|
group=CCMP TKIP
|
|
|
auth_alg=OPEN
|
|
|
sim_num=1
|
|
|
priority=13893
|
|
|
}
|
|
|
|
|
|
network={
|
|
|
ssid="TP-LINK_F11E"
|
|
|
psk="987654321"
|
|
|
key_mgmt=WPA-PSK
|
|
|
sim_num=1
|
|
|
priority=17293
|
|
|
}
|
|
|
```
|
|
|
|
|
|
`Ssid` we shall see in the WLAN settings in the name,` psk` the password, `key_mgmt` security encryption.
|
|
|
|
|
|
### To set the system date and time
|
|
|
|
|
|
** Note: You need root privileges. **
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell
|
|
|
su
|
|
|
date -s 20160823.131500
|
|
|
```
|
|
|
|
|
|
It said it would change the system date and time at 13:15:00 on August 23, 2016.
|
|
|
|
|
|
### restart cellphone
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb reboot
|
|
|
```
|
|
|
|
|
|
### Detect whether the device is root
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell
|
|
|
su
|
|
|
```
|
|
|
|
|
|
In this case the command line prompt is `` $ indicates no root privileges, is `` the # indicates root.
|
|
|
|
|
|
### Monkey use stress testing
|
|
|
|
|
|
Monkey can generate pseudo-random event to simulate a user click, touch, gesture and other operations, you can program being developed random stress test.
|
|
|
|
|
|
Usage is simple:
|
|
|
|
|
|
```sh
|
|
|
adb shell monkey -p <packagename> -v 500
|
|
|
```
|
|
|
|
|
|
He told `<packagename>` specific application to send 500 pseudo-random events.
|
|
|
|
|
|
Monkey in detail with reference to the use of [official document](https://developer.android.com/studio/test/monkey.html).
|
|
|
|
|
|
### On / off WiFi
|
|
|
|
|
|
** Note: You need root privileges. **
|
|
|
|
|
|
Sometimes the need to control the device WiFi mode, you can use the following command to complete.
|
|
|
|
|
|
Open WiFi:
|
|
|
|
|
|
```sh
|
|
|
adb root
|
|
|
adb shell svc wifi enable
|
|
|
```
|
|
|
|
|
|
Close WiFi:
|
|
|
|
|
|
```sh
|
|
|
adb root
|
|
|
adb shell svc wifi disable
|
|
|
```
|
|
|
|
|
|
If successfully implemented, the output is empty; if not get root privileges to execute this command will fail, output `Killed`.
|
|
|
|
|
|
## Brush related commands
|
|
|
|
|
|
### Restart to Recovery mode
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb reboot recovery
|
|
|
```
|
|
|
|
|
|
### To restart from the Recovery Android
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb reboot
|
|
|
```
|
|
|
|
|
|
### Restart to Fastboot mode
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb reboot bootloader
|
|
|
```
|
|
|
|
|
|
### Through sideload system update
|
|
|
|
|
|
If we downloaded the Android system update package corresponds to the device to your computer, you can also adb to complete the update.
|
|
|
|
|
|
Case in Recovery Mode Update:
|
|
|
|
|
|
1. Restart to Recovery mode.
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb reboot recovery
|
|
|
```
|
|
|
|
|
|
2. Recovery operations on the interface device into the `Apply update`-`Apply from ADB`.
|
|
|
|
|
|
Note: Different Recovery menu may differ from this, there is some level menu `Apply update from ADB`.
|
|
|
|
|
|
3. adb upload and update the system.
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb sideload <path-to-update.zip>
|
|
|
```
|
|
|
|
|
|
## More adb shell command
|
|
|
|
|
|
Android system is based on Linux kernel, so Linux where many commands in Android also has the same or similar implement, in `adb shell` where you can call. Part earlier in this document have been used in the `adb shell` command.
|
|
|
|
|
|
### See process
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell ps
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
USER PID PPID VSIZE RSS WCHAN PC NAME
|
|
|
root 1 0 8904 788 ffffffff 00000000 S /init
|
|
|
root 2 0 0 0 ffffffff 00000000 S kthreadd
|
|
|
...
|
|
|
u0_a71 7779 5926 1538748 48896 ffffffff 00000000 S com.sohu.inputmethod.sogou:classic
|
|
|
u0_a58 7963 5926 1561916 59568 ffffffff 00000000 S org.mazhuang.boottimemeasure
|
|
|
...
|
|
|
shell 8750 217 10640 740 00000000 b6f28340 R ps
|
|
|
```
|
|
|
|
|
|
Meaning of each column:
|
|
|
|
|
|
| Listing | Meaning |
|
|
|
|---------|-------------------|
|
|
|
| USER | their user |
|
|
|
| PID | Process ID |
|
|
|
| PPID | parent process ID |
|
|
|
| NAME | process name |
|
|
|
|
|
|
### View real-time resource consumption
|
|
|
|
|
|
command:
|
|
|
|
|
|
```sh
|
|
|
adb shell top
|
|
|
```
|
|
|
|
|
|
Example output:
|
|
|
|
|
|
```sh
|
|
|
User 0%, System 6%, IOW 0%, IRQ 0%
|
|
|
User 3 + Nice 0 + Sys 21 + Idle 280 + IOW 0 + IRQ 0 + SIRQ 3 = 307
|
|
|
|
|
|
PID PR CPU% S #THR VSS RSS PCY UID Name
|
|
|
8763 0 3% R 1 10640K 1064K fg shell top
|
|
|
131 0 3% S 1 0K 0K fg root dhd_dpc
|
|
|
6144 0 0% S 115 1682004K 115916K fg system system_server
|
|
|
132 0 0% S 1 0K 0K fg root dhd_rxf
|
|
|
1731 0 0% S 6 20288K 788K fg root /system/bin/mpdecision
|
|
|
217 0 0% S 6 18008K 356K fg shell /sbin/adbd
|
|
|
...
|
|
|
7779 2 0% S 19 1538748K 48896K bg u0_a71 com.sohu.inputmethod.sogou:classic
|
|
|
7963 0 0% S 18 1561916K 59568K fg u0_a58 org.mazhuang.boottimemeasure
|
|
|
...
|
|
|
```
|
|
|
|
|
|
Meaning of each column:
|
|
|
|
|
|
| Listing | Meaning |
|
|
|
|---------|-------------------------------------------------------------------------------------------|
|
|
|
| PID | Process ID |
|
|
|
| PR | Priority |
|
|
|
| CPU% | instantaneous current occupancy percentage of CPU |
|
|
|
| S | process state (R = run, S = sleep, T = trace / stop, Z = zombie process) |
|
|
|
| #THR | Threads |
|
|
|
| VSS | Virtual Set Size of virtual memory consumption (including shared libraries occupy memory) |
|
|
|
| RSS | Resident Set Size actual physical memory (including shared libraries occupy memory) |
|
|
|
| PCY | scheduling policy priority, SP_BACKGROUND / SPFOREGROUND |
|
|
|
| UID | process owner user ID |
|
|
|
| NAME | process name |
|
|
|
|
|
|
`Top` command also supports a number of command-line parameters, detailed usage is as follows:
|
|
|
|
|
|
```sh
|
|
|
Usage: top [ -m max_procs ] [ -n iterations ] [ -d delay ] [ -s sort_column ] [ -t ] [ -h ]
|
|
|
-m num How many processes displays up
|
|
|
-n num refresh how many times
|
|
|
-d num refresh interval (in seconds, default value of 5)
|
|
|
-s col sorted by a column (available col value: cpu, vss, rss, thr)
|
|
|
-t display thread information
|
|
|
-h displays help documentation
|
|
|
```
|
|
|
|
|
|
### Other
|
|
|
|
|
|
The following is a brief description of other commonly used commands, has previously spoken commands no special additional explanation:
|
|
|
|
|
|
| Command | function |
|
|
|
|---------|------------------------------------|
|
|
|
| cat | display file contents |
|
|
|
| cd | change directory |
|
|
|
| chmod | change file access mode / access |
|
|
|
| df | view disk space usage |
|
|
|
| grep | output filter |
|
|
|
| kill | kill the specified process PID |
|
|
|
| ls | list directory contents |
|
|
|
| mount | Mount View and manage directory |
|
|
|
| mv | move or rename a file |
|
|
|
| ps | view running processes |
|
|
|
| rm | delete files |
|
|
|
| top | Check process resource consumption |
|
|
|
|
|
|
## common problem
|
|
|
|
|
|
### Start adb server failure
|
|
|
|
|
|
**Error message**
|
|
|
|
|
|
```sh
|
|
|
error: protocol fault (couldn't read status): No error
|
|
|
```
|
|
|
|
|
|
**Possible Causes**
|
|
|
|
|
|
adb server process wants to use 5037 port is occupied.
|
|
|
|
|
|
**solution**
|
|
|
|
|
|
Found consumes process 5037 port, and then terminate it. In Windows, for example:
|
|
|
|
|
|
```sh
|
|
|
netstat -ano | findstr LISTENING
|
|
|
|
|
|
...
|
|
|
TCP 0.0.0.0:5037 0.0.0.0:0 LISTENING 1548
|
|
|
...
|
|
|
```
|
|
|
|
|
|
1548 Here is the process ID, the process ends with the command:
|
|
|
|
|
|
```sh
|
|
|
taskkill /PID 1548
|
|
|
```
|
|
|
|
|
|
Then start adb no problem.
|
|
|
|
|
|
## adb unofficial implementation
|
|
|
|
|
|
* [fb-adb](https://github.com/facebook/fb-adb) - A better shell for Android devices (for Mac).
|
|
|
|
|
|
## Acknowledgements
|
|
|
|
|
|
Thanks for sharing with friends and selfless supplement.
|
|
|
|
|
|
* [zxning](https://github.com/zxning)
|
|
|
* [linhua55](https://github.com/linhua55)
|
|
|
* [codeskyblue](https://github.com/codeskyblue)
|
|
|
* [seasonyuu](https://github.com/seasonyuu)
|
|
|
* [fan123199](https://github.com/fan123199)
|
|
|
* [zhEdward](https://github.com/zhEdward)
|
|
|
* [0x8BADFOOD](https://github.com/0x8BADFOOD)
|
|
|
|
|
|
## Reference Links
|
|
|
|
|
|
* [Android Debug Bridge](https://developer.android.com/studio/command-line/adb.html)
|
|
|
* [ADB Shell Commands](https://developer.android.com/studio/command-line/shell.html)
|
|
|
* [logcat Command-line Tool](https://developer.android.com/studio/command-line/logcat.html)
|
|
|
* [Android ADB命令大全](http://zmywly8866.github.io/2015/01/24/all-adb-command.html)
|
|
|
* [adb 命令行的使用记录](https://github.com/ZQiang94/StudyRecords/blob/master/other/src/main/java/com/other/adb%20%E5%91%BD%E4%BB%A4%E8%A1%8C%E7%9A%84%E4%BD%BF%E7%94%A8%E8%AE%B0%E5%BD%95.md)
|
|
|
* [Android ADB命令大全(通过ADB命令查看wifi密码、MAC地址、设备信息、操作文件、查看文件、日志信息、卸载、启动和安装APK等)](http://www.jianshu.com/p/860bc2bf1a6a)
|
|
|
* [那些做Android开发必须知道的ADB命令](http://yifeiyuan.me/2016/06/30/ADB%E5%91%BD%E4%BB%A4%E6%95%B4%E7%90%86/)
|
|
|
* [adb shell top](http://blog.csdn.net/kittyboy0001/article/details/38562515)
|
|
|
* [像高手一样使用ADB命令行(2)](http://cabins.github.io/2016/03/25/UseAdbLikeAPro-2/)
|
|
|
|
|
|
[1]: #ip-address
|
|
|
|