当前位置:网站首页>As a tester, you cannot fail to understand ADB commands and operations
As a tester, you cannot fail to understand ADB commands and operations
2022-07-23 15:42:00 【ZYT acridine】
Just from web go to app test , A lot of knowledge needs to be added , Make a note of
1. Concept
In fact, what we said adb It's a general term , There are two tools ——Fastboot and ADB
fastboot Quick start ,usb A way to connect data lines
ADB Debug Android or follow app Tools for , It's Android sdk A tool in , With this tool, you can debug Android simulator or real machine
ps: Cold knowledge
commonly Android Device to connect WinXP There is no need to install the driver
2.adb The function of
Operating equipment shell( Command line )
Manage simulator or device Port mapping
Upload between computer and device / Download the file
Will local apk The software is installed into the simulator or android equipment
ADB It's a client - Server side Program , The client is the computer you use to operate , The server side is android equipment . and ADB The driver is the computer and android Client driver for device communication .
All mobile phone operations can be used adb Realization . That is to say, if you play 6, You are the touch screen is completely broken , The display screen is completely broken , Just give you a motherboard , You can still do what you have to do . Of course, this is not recommended in general scenarios , Efficiency first .
ps: download adb When it comes to tools , Many packages pack these two tools together
3. Usage method
a. Download and install on the computer adb Tools
Android Developer website SDK Platform Tools release notes | Android Developers Download the corresponding adb An Zhuo Bao
After decompressing , Configure environment variables , That is to say adb.exe The directory file path of the layer is configured in the environment variable path in
cmd Input adb, If there is adb Version information , Prove that the computer has been installed adb Tool success
ps:
If not configured adb environment variable , It needs to be done first cd To adb.exe Under that directory , Enter again adb Command can succeed
Or in adb.exe The blank space under the folder , Hold down shift+ Right click , The following options appear “ Open here powershell window ”, Get into powershell After window , First enter cmd The command switches to command prompt mode , Input again adb Command to enter adb Pattern
b. Make sure the phone is turned on usb Debug mode
Mobile phone data cable links to computer ,cmd Input in adb devices View the devices that have been successfully linked
c. Through the driver software , Drive elves / Drive life, etc , Put your android The mobile phone driver is installed ( It's said on the Internet , But I don't know why , My mobile phone doesn't need this step , It's a little strange. )
a.b After operation , We are skilled in mobile phone adb The command operates
4. Principle of use
adb It's a c/s Architecture program , It's made up of three parts
1. Running on the pc Of adb client( client ), Used to run shell perhaps adb command ,adb” The program tries to locate ADB The server , If you can't find it ADB The server ,“adb” The program automatically starts a ADB The server . Next , When the equipment adbd and pc Terminal adb server Once the connection is established ,adb client You can go to ADB servcer Send service request ;
2. Running on the pc Terminal adb server:
ADB Server Is a background process running on the host . Its function is to detect USB Connection and removal of port aware devices , And the start or stop of the simulator instance ,ADB Server Also need to adb client The request was passed usb perhaps tcp Send to the corresponding adbd On ;
3. Resident processes running on the device side adb demon (adbd):
Program “adbd” As a background process in Android Running in a device or simulator system . What it does is it connects ADB The server , And provide some services for clients running on the host ;
In summary :
adb There are three major components :
client (client)
Run on your own computer , Can pass shell To start a client
The server (server)
Running in the background of the computer , Responsible for managing the client and damon communicate
Daemon (damon)
5. Start using adb command , Common operation commands are as follows :
Basic command format :
adb [-d|-e|-s ]
| -d | Specifies the current unique pass USB Connected Android The device is the command target |
| -e | Specify the currently unique running simulator as the command target |
-s <serialNumber> | Specify the corresponding serialNumber Equipment No / The simulator is the command target |
On multiple devices / When the simulator is connected, it is more commonly used to -s Parameters ,serialNumber Can pass adb devices Command acquisition
Such as :
adb -s cf264b8f shell wm size Get phone screen size
As a test, you need to master adb command :
1.adb shell Get into adb shell Pattern
2.adb pull < Mobile path > < Computer path > Pull the files in the mobile phone to the computer Mobile phone path can be used ls/cd Find it later 3
1.adb install + Package name adb install apk ( Overlay installation is using -r Options )
2.adb uninstall + Package name adb uninstall apk
3.adb connect + equipment IP network connections Android equipment
4.adb reboot restart Android equipment
5.adb devices Get the connected device list and device status
6.adb get-state Get the status of the device ( The state of the device is 3 The clock ,device: The device is connected properly , offline: Connection exception , Device not responding , unknown: No device connected )
7. Look at running in Android On the device adb Background processes :
perform adb shell ps | grep adbd , You can find the background process ,windows Please use findstr replace grep
adb shell command :
adb shell command
adb The order is adb Some of the commands that come with this program , and adb shell Is called Android Commands in the system , these Android Special orders are placed in Android The equipment system/bin Under the table of contents
8.1. adb shell bugreport , Print dumpsys、dumpstate、logcat Output , It is also used to analyze errors
More output , It is recommended to redirect to a file
adb shell dumpsys > d:\bugreport.log
8.2 pm
Package Manager , You can get some installed in Android Application information on the device
8.2.1 adb shell pm list package List the package names of all applications (-s: List system applications -3: List third-party applications -f: List the application package name and the corresponding apk Name and storage location -i: List the application package name and its installation source )
8.2.2 adb shell pm path+ Package name List the corresponding package name .apk Location
8.2.3 adb shell pm install +apk Storage path Install application ( The goal is apk Stored in PC End , use adb install install The goal is apk Stored in Android On the device , use pm install install )
8.3 am
8.3.1 adb shell am start + Package name /.Activity ( To start Activity) Start a Activity (-s Stop the target application first , Restart -w Wait for the application to finish starting -a Start the default browser and open a web page :adb shell am start -a android.intent.action.VIEW -d http://testerhome.com)
8.3.2 adb shell am monitor monitor crash And ANR
8.3.3 adb shell am force-stop Follow the package name , The end of the application
8.3.4 adb shell am startservice Start a service
8.3.5 adb shell am broadcast Send a broadcast
8.4 input
This command can be directed to Android The device sends a key event
8.4.1 adb shell input text + The specific content Send text content , Can't send Chinese
8.4.2 adb shell input keyevent + Key events Send key event for example :adb shell input keyevent KEYCODE_HOME Analog press Home key
8.4.3 adb shell input tap + Touch the location of the event , Send a touch event to the screen for example : Click the coordinates on the screen as 500 500 The location of (adb shell input tap 500 500)
8.4.4 adb shell input tap , Send a touch event to the screen
8.4.4 adb shell input swipe Sliding events for example : Slide the screen from right to left
adb shell input swipe 800 600 100 600
8.5 screencap
Screenshot command
adb shell screencap -p /sdcard/DCIM/screenTest.png
8.6 screenrecord
4.4 New recording commands in the above system versions
adb shell screenrecord /sdcard/demo.mp4
Operate the mobile phone after executing the command ,ctrl + c The end of the recording , Save the recording results to sdcard/ Next
8.7 ime
List the input methods on the device
adb shell ime list -s
The other one does not need a data line to link the mobile phone adb The way :
adopt WiFi Remote debugging , At this point, we don't need to pass USB The cable connects the mobile phone to the computer , But there are the following precautions :
1、 Make sure your phone and computer are on the same network ( Connected to the same router )
2、 To pass ahead of time adb tcpip 5555 To determine the communication port number
3、 Re pass adb connect Add your own mobile phone ip Address to connect
If you want to cancel the connection , Use it directly adb disconnect Command is enough
start-up adb server command :
adb command
Some mobile phones need to be unlocked system Partition ( Like millet )
Input :adb root
Input :adb disable-verity
Check the phone connection status :adb device
get root jurisdiction :root
Set super user mode : su
sign out su : exit
Restart command :adb reboot
Restart to Rec:adb reboot recovery
Restart to Fastboot:adb reboot bootloader
push ROM package :adb sideload <Rom package >
Copy files from your phone to your computer : adb pull < Mobile path > < Computer path >
Copy files from your computer to your mobile phone : adb push < Computer path > < Mobile path >
Remount the file system : adb remount
Install the software : adb install apk File name .apk
uninstall apk Software : adb uninstall apk Package name .apk
Fastboot command :
Check the connection status :fastboot devices
restart :fastboot reboot
Restart to Fastboot :fastboot reboot-bootloader
Unless you know the order well , Otherwise, please use the following commands carefully :
Unlock :fastboot flashing unlock or fastboot oem unlock
locked :fastboot flashing lock or fastboot oem lock
Clear partition data :fastboot erase <boot/system/data/cache/userdata/recovery>
Clear partition ( Siqing ) :fastboot erase system -w
Format partition data :fastboot format <boot/system/data/cache/userdata/recovery>
Burn partition :fastboot flash < boot/system /recovery/radio/bootloader/ splash1/>
Problems encountered :
1.adb root No entry into force
This really does not need to be supported by the kernel , Kernel independent , That is, native . Mobile phones can Authorization tools .
2, After Baidu , Say you need to download first root Tools , obtain root After permission , It's useful to execute the command again ,
It is recommended to download the brush wizard and click on the computer root
边栏推荐
- Use of RSA encryption
- Unreal中通过FMonitoredProcess启动其他独立程序
- Safety 7.18 operation
- Kirin V10 source code compilation qtcreater4.0.3 record
- 地图附近名片流量主小程序开发
- 第三篇 RBAC权限管理 数据库设计详解
- Smart headline: smart clothing forum will be held on August 4, and the whole house smart sales will exceed 10billion in 2022
- C语言经典例题-逆序打印输入的两位数
- day1
- What is the difference between server hosting and virtual host
猜你喜欢

什么是真正的 HTAP ?(二)挑战篇
![[200 opencv routines] 225. Fourier descriptor for feature extraction](/img/4b/1f373505ffd5c0dbaa5c20431c4b42.png)
[200 opencv routines] 225. Fourier descriptor for feature extraction

centos7 中彻底卸载mysql
[email protected]]#颜色"/>修改ssh命令行[[email protected]]#颜色

Clickhouse, let the query fly!!!

用rpm -e --nodeps进行批量删除

Matlab simulation of solving multi-objective optimal value based on PSO optimization

Deep understanding of L1 and L2 regularization

946. 验证栈序列 ●● & 剑指 Offer 31. 栈的压入、弹出序列 ●●

多线程一定能优化程序性能吗?
随机推荐
Idea starts multiple projects at once
开源四足机器人 附设计图及代码「建议收藏」
C语言经典例题-两个分数相加
After vscode is updated, the shortcut keys related to tab cannot be used
什么是服务器托管及和虚拟主机的区别
C # calculate the number of times a character appears in the string
[pyGame actual combat] aircraft shooting masterpiece: fierce battle in the universe is imminent... This super classic shooting game should also be taken out and restarted~
Redis Key没设置过期时间,为什么被主动删除了
C语言经典例题-逆序打印输入的两位数
安全作业7.22
深入理解CAS (自旋锁)
STL map操作
Solve the problem that kotlin writes the Android project compilation report execution failed for task ': app:kaptdebugkotlin'. Exception
Linux: analysis of the basic use of vim editor
BGP federal experiment
C语言书籍推荐
ERP管理系统在装备制造企业管理中的应用
STL deque
Dynamic planning - force buckle
Deep understanding of CAS (spin lock)