当前Activity
adb shell dumpsys activity top | grep ACTIVITY
adb shell dumpsys activity activities | grep mResumed
adb shell dumpsys activity | grep Focuse
当前Fragment
adb shell dumpsys activity top | grep '#0: ' | tail -n 1
启动时间
# 获取当前页面的Activity
adb shell am start -W com.android.camera/.MainActivity
当前页面Fragment
内存占用
adb shell dumpsys meminfo com.android.camera
adb shell dumpsys meminfo --package com.android.camera
cpu占用率,gpu占用率
adb shell dumpsys cpuinfo
adb shell dumpsys gfxinfo
TODO
禁用/开启app
// 禁用相册
adb shell pm disable com.android.gallery
// 开启相册
adb shell pm enable com.android.gallery
查看进程
adb shell ps | grep "xxx"
adb shell kill [进程Pid]
后台service
adb shell dumpsys activity services
文件交互
从手机拉到本地
adb pull path-on-device/sample.trace ~/Documents/trace-logs/
从本地推送到手机
adb push system_raw.gz /storage/emulated/0/Download/
清除应用缓存数据
adb shell pm clear com.jingyao.easybike
Success
安装后的 apk 文件 路径
adb shell dumpsys package com.jingyao.easybike | grep path
若出现,does not have permission
需要在开发者选项中的开启USB调试
dump IPC调用
adb shell am trace-ipc start
adb shell am trace-ipc stop --dump-file /data/local/tmp/trace-ipc.txt
adb pull /data/local/tmp/trace-ipc.txt
查看某个进程的全部线程
# 找到进程号,第一个数字
adb shell ps | grep 进程名
# 输入全部线程
adb shell ps -T -p 进程号
抓hprof
adb shell am dumpheap com.xx.xx /data/local/tmp/test.hprof
adb pull /data/local/tmp/test.hprof
分辨率与屏幕密度
adb shell wm size
adb shell wm density