ADB

ADB 常用命令

一些常用的 ADB 命令

Posted by Edger on January 7, 2019

ADB Root 步骤

打开 ROOT 工具,选中盘符后发送 SC_SWITCH_ROOT

1
2
3
4
5
adb root

adb shell setprop persist.<vendor>.verity_disable 1

adb disable-verity

重启

1
adb reboot

开机后再次选中盘符后发送 SC_SWITCH_ROOT

1
2
3
adb root

adb remount

获得当前活动窗口的信息,包名以及活动窗体:

1
adb shell dumpsys window windows | grep mCurrent

杀死进程

1
adb shell kill [PID]

1
am force-stop <package_name>

查看所有进程列表,Process Status

1
adb shell ps

查看 package_name 程序进程

1
adb shell ps | grep <package_name>

查看 PID 进程状态

1
adb shell ps -x [PID]

实时监听程序进程的变化

1
adb shell top | grep <package_name>

运行结果如下:

1
2
3
4
eg:
adb shell ps -x 13699
USER           PID    PPID    VSIZE     RSS     WCHAN      PC               NAME
u0_a94    13699 1734  1653292 28404   ffffffff    00000000 S com.polysaas.mdm (u:6, s:6)

包名管理命令,获得对应包名的对应 apk 路径:

1
adb shell pm  path com.android.settings

adb shell 查看当前进程和窗口信息可以使用如下命令:

1
adb shell dumpsys window windows | grep "Window #"

获取当前 activity:

方法一:

1
adb shell logcat | grep ActivityManager

方法二:

1
adb shell dumpsys activity activities

查看当前与用户交互的 activity

方法一:

1
adb shell dumpsys activity activities | sed -En -e '/Running activities/,/Run #0/p'

方法二:

1
adb shell dumpsys activity | grep -i run

方法三:

1
adb shell dumpsys activity | grep "mFoc"