Commonly used adb commands (including adb shell pm, am, dumpsys) Android phone debugging

1. Simple adb command

adb devices 查看设备信息
adb kill-server 关闭adb服务
adb start-server 打开adb服务
adb connect HOST[:PORT] 远程连接设备
adb disconnect 断开远程连接
adb push  从电脑推到手机
adb pull  从手机拉到电脑
adb install packages(包路径) 安装应用
adb uninstall packages(包路径) 卸载应用
adb install -r packages(包路径) 覆盖安装
adb reboot 重启设备
adb logcat 打印日志
adb logcat > log.txt 日志保存到log.txt文件中

adb connects the device wirelessly (Wi-Fi connection)

Reference: adb wireless connection device for debugging operation (Wi-Fi connection)_Vermouth_00's Blog-CSDN Blog

The difference between adb install and pm install

adb install directly installs the apk on the computer to the phone;

pm install needs to adb push apk to the mobile phone first, then adb shell pm install apk; pm install is to install the apk in the mobile phone to the mobile phone;

Adb install may pop up a window, and pm install can bypass the pop-up window.

adb logcat encountered an error: read: unexpected EOF!

It is because the log cache size is limited;

Solution:

1.adb logcat -G 16m modify the cache size;

2. Developer options on the phone --- "logger buffer size --> set to the maximum.

Two, adb shell pm command

pm:package manager

adb shell pm list packages 查看手机上安装的应用
adb shell pm list packages -3 查看第三方应用
adb shell pm list packages -s 查看系统应用
adb shell pm install  安装某个包
adb shell pm uninstall packagename 卸载某个包
adb shell pm dump packagename 包的详细信息
adb shell pm path packagename 包的路径
adb shell pm clear com.ablesky.ui.activity 清除缓存数据

Three, adb shell am command

am:activity manager

adb shell am start -W/-n/-S apk/activity 启动某个apk的某个页面
adb shell am force-stop apk 强制停止某个apk

Four, adb shell dumpsys command

adb shell dumpsys cpuinfo packagename 获取某个包的cpu数据
adb shell dumpsys meminfo packagename 获取某个包的内存数据
adb shell dumpsys gfxinfo packagename 获取某个包的fps数据
adb shell dumpsys battery 获取电池数据
adb shell dumpsys wifi
adb shell dumpsys activity

How to measure the power consumption of mobile phone?

1. adb connects the mobile phone to the computer wirelessly;

2. Clear the power consumption data before starting the test

adb shell dumpsys batterystats --reset

3. Operating equipment test

4. Obtain power data

adb shell dumpsys batterystats > battery.txt

5. View the apk package name

adb shell dumpsys activity recents | grep intent={
   
   

6. View uid according to the package name

adb shell ps | grep 包名

7. Search for Estimated power use in the battery.txt file, and get the power consumption information corresponding to the uid, in mAh

 

5. Others

adb shell screencap -p /sdcard/test.png
adb shell screenrecord
adb shell screenshot
adb shell ps | grep packagename
adb shell kill
adb shell getprop ro.product.model 获取设备型号
adb -d shell getprop ro.product.brand 获取手机厂商名称
adb shell getprop ro.build.version.release 获取设备 Android 系统版本
adb shell getprop ro.build.version.sdk 获取手机系统api版本
adb shell getprop ro.serialno 获取设备的序列号(设备号)
adb get-serialno 获取设备的序列号(设备号)
adb shell wm size 获取设备屏幕分辨率
adb shell money -p 包名 100 指定APP产生随机事件100次
adb shell monkey -p 包名 -v -v 100 指定APP产生随机事件100次并发送详细的activity信息
adb shell cat /sys/class/net/wlan0/address 获取手机mac地址
adb shell cat /proc/meminfo 获取手机内存信息
adb shell df 获取手机存储信息
adb shell df /storage/sdcard 获取sdcard存储信息
aapt dump badging +包的全路径 查看指定apk的包名

 

Supongo que te gusta

Origin blog.csdn.net/Vermouth_00/article/details/131195642
Recomendado
Clasificación