Android APP common concepts and adb commands

adb concept

adb stands for Android Debug Bridge. Enter adb in the window to display the help documentation. adb actually opens a server in the background, which receives adb commands and helps manage, control, and view device status and information. It is the most common method for developing and testing Android-related programs. If there is a problem with the connection, you can use adb kill-server to disconnect and reconnect.

Usually adb is connected to the computer through a data cable, but you can also use adb tcpip to connect to the mobile phone using TCP, which can be separated from the data cable service, and can even be carried out in the form of forwarding without being deployed under the same router. connect. After opening the TCP connection, you can use adb connect to connect to the mobile phone that has the TCP connection enabled.

Android APP information acquisition

adb devices This should be one of the most common adb commands, which is often encountered whether in development or testing. This command is relatively simple, it is to list all currently connected devices (includingsimulator)

Log command adb logcat This command is also commonly used to obtain the log of the mobile phone, but it will output a lot of content. You can use grep or findstr on Windows to filter it.

Use grep Displayed to filter out already displayed apps such as WeChat and Play Store. You can use this command to find some interesting information. Of course, you can also use it to capture app logs and locate and analyze problems. For example, adb logcat -v time | grep “xxx” > appLog.log where xxx is the package name or keyword.

Different levels of information can also be specified using the following letters:

V — detail verbose (lowest priority)

D — debug debug

I — Information info

W — Warn warn

E — error error

F — fatal error

S — no record silent

Start command

adb shell am start -n

com.android.vending/.AssetBrowserActivity -S

Use this command to pass in the package name and activity of the play store obtained above to start the app. Where am means ActivityManager is used to manage application activities and windows. -S means to kill the original program before starting it

Installation command

adb install

Then just give the package name

Get APP entrance

aapt dump badging xxx | grep launchable-activity

Where xxx is the installation package

Collect log data

adb bugreport

This command can be used to analyze mobile phone log data, including power consumption, CPU, etc.

adb shell

adb shell is a Linux shell that can be used to call Android's built-in commands. adb shell is interactive and can do many things, including pull/push files, input, etc.

Clean package data

adb shell pm clear com.android.vending

You can clean the package data. After cleaning, the permissions will also be cleared and restored to the state just after installation. pm is the package management tool, corresponding to am

Get the xml of the interface

adb shell "uiautomator dump

&& cat /sdcard/window_dump.xml"

Turn each control and element of the current interface into a node in xml, which contains the properties of each control, such as whether it is clickable, etc.

dumpsys

dumpsys is a very commonly used command, so it is listed separately.

Get the current activity

adb shell dumpsys activity top

Get the records of activities and get the original activities that appium depends on.

dumpsys activity activities

Get basic information about a specific package

adb shell dumpsys package com.android.vending

Use grep to filter out the required information

Get notification information

adb shell dumpsys notification

For different mobile phones, obtaining notification information through the UI level drop-down may have an impact on the compatibility of the script, so you can use this command to obtain and then filter out the required notification content by title, text, etc.

Get memory information

adb shell dumpsys meminfo com.android.settings

Get CPU information

adb shell dumpsys cpuinfo

Get GPU drawing analysis

adb shell dumpsys gfxinfo com.android.settings

Among them, memory, CPU, and GPU information acquisition can be used to analyze performance and other issues.


          [The following is the most comprehensive software testing engineer learning knowledge architecture system diagram in 2023 that I compiled]


1. Python programming from entry to proficiency


2. Practical implementation of interface automation projects  

3. Web automation project actual combat


4. Practical implementation of App automation project 

5. Resumes of first-tier manufacturers


6. Test and develop DevOps system 

7. Commonly used automated testing tools


8. JMeter performance test 

9. Summary (little surprise at the end)

life is long so add oil. Every effort will not be disappointed, as long as you persevere, you will eventually be rewarded. Cherish your time and pursue your dreams. Don’t forget your original intention and forge ahead. Your future is in your control!

Life is short and time is precious. We cannot predict what will happen in the future, but we can control the present. Cherish every day, work hard, and make yourself stronger and better. With firm belief and persistent pursuit, success will eventually belong to you!

Only by constantly challenging yourself can you constantly surpass yourself. Keep pursuing your dreams and move forward bravely, and you will find that the process of struggle is so beautiful and worthwhile. Believe in yourself, you can do it!

Finally, I would like to thank everyone who reads my article carefully. Reciprocity is always necessary. Although it is not a very valuable thing, if you can use it, you can take it directly:

This information should be the most comprehensive and complete preparation warehouse for [software testing] friends. This warehouse has also accompanied tens of thousands of test engineers through the most difficult journey. I hope it can also help you!​ 

Guess you like

Origin blog.csdn.net/2301_78276982/article/details/135018207