当前位置:网站首页>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
边栏推荐
- C语言经典例题-两个分数相加
- 工业物联网中的时序数据
- VSCode 更新後與tab相關快捷鍵無法使用
- Safe operation 7.22
- Simulation of voltage source PWM rectifier with double closed loop vector control based on Simulink
- Simulation of synchronization performance of BOC modulation and demodulation based on MATLAB, output tracking curve and identification curve under different lead lag code distance
- 数据治理浅析
- RTA一种广告精准投放的新玩法?
- Dynamic planning - force buckle
- Opnsense - multifunctional, highly reliable and easy-to-use firewall (II)
猜你喜欢

The current situation and history of it migrant workers

printf函数-转换说明

Safe operation 7.22

7.13web safety operation
![[CTFHub]JWT 的头部和有效载荷这两部分的数据是以明文形式传输的,如果其中包含了敏感信息的话,就会发生敏感信息泄露。试着找出FLAG。格式为 flag{}](/img/d0/133d628a304f5c6b5f0d514c9fe222.jpg)
[CTFHub]JWT 的头部和有效载荷这两部分的数据是以明文形式传输的,如果其中包含了敏感信息的话,就会发生敏感信息泄露。试着找出FLAG。格式为 flag{}

ClickHouse,让查询飞起来!!!

SCA在得物DevSecOps平台上应用

7.13WEB安全作业

Time series data in industrial Internet of things

Kirin V10 source code compilation qtcreater4.0.3 record
随机推荐
对专利的学习
Six ways of uniapp route jump
Redis bloom filter
BGP federal experiment
Guangzhou held a competition for quality and safety supervisors of agricultural products in the town and street
C语言书籍推荐
Opnsense - multifunctional, highly reliable and easy-to-use firewall (II)
Modify SSH command line[ [email protected] ]Color
对C语言最基本的代码解释
第五篇 Druid数据源介绍
Start process of activity
开源四足机器人 附设计图及代码「建议收藏」
BGP routing principle
Kirin V10 source code compilation qtcreater4.0.3 record
day1
Application of ERP management system in equipment manufacturing enterprise management
After vscode is updated, the shortcut keys related to tab cannot be used
Matlab simulation of solving multi-objective optimal value based on PSO optimization
【Pygame实战】飞机射击大作:宇宙激战一触即发...这款超经典的射击游戏也该拿出来重启了~
uniapp路由跳转的六种方式