一、findstr查找、grep

如查找手机是否有安装com.vivo.bsptest这个APP

C:\Users\micaw>adb shell pm list package |findstr vivo.bsptest
package:com.vivo.bsptest

 

直接进入adb  shell

PD1901:/ $ ps -ef |grep 28971
shell 2968 2948 2 10:13:08 pts/28 00:00:00 grep 28971
u0_i11 28971 1526 0 17:19:02 ? 00:02:42 com.google.android.webview:sandboxed_process0

 

二、ps/kill 列出/杀进程

PD1901:/ $ ps -ef |grep jx
u0_a135 2994 562 21 10:14:40 ? 00:02:12 com.jxrs.jxrsapp

1|PD1901:/ $ kill -9 2994

 

三、adb logcat -b crash 抓取崩溃日志

C:\Users\micaw>adb logcat -b crash

或者

C:\Users\micaw>adb logcat -v time  -d  >d:/err.txt

 

四、adb shell netcfg 抓取手机IP地址

前提条件是手机要有root权限,

 

 

五、强制关闭某个APP

C:\Users\micaw>adb shell am force-stop

 

六、获取当 前布局

前提:打开一个当前活动的APP,

C:\Users\micaw>adb shell uiautomator events


11-13 10:43:07.400 EventType: TYPE_WINDOW_STATE_CHANGED; EventTime: 35976968; PackageName: com.jxrs.jxrsapp; MovementGranularity: 0; Action: 0; ContentChangeTypes: []; WindowChangeTypes: [] [ ClassName: com.jxrs.jxrsapp.LoginActivity; Text: [姹熻タ浜虹ぞ]; ContentDescription: null; ItemCount: -1; CurrentItemIndex: -1; Enabled: true; Password: false; Checked: false; FullScreen: true; Scrollable: false; BeforeText: null; FromIndex: -1; ToIndex: -1; ScrollX: -1; ScrollY: -1; MaxScrollX: -1; MaxScrollY: -1; AddedCount: -1; RemovedCount: -1; ParcelableData: null ]; recordCount: 0
11-13 10:43:07.418 EventType: TYPE_VIEW_FOCUSED; EventTime: 35976972; PackageName: com.jxrs.jxrsapp; MovementGranularity: 0; Action: 0; ContentChangeTypes: []; WindowChangeTypes: [] [ ClassName: android.widget.EditText; Text: [璇疯緭鍏ラ獙 璇佺爜]; ContentDescription: null; ItemCount: 12; CurrentItemIndex: 4; Enabled: true; Password: false; Checked: false; FullScreen: false; Scrollable: false; BeforeText: null; FromIndex: -1; ToIndex: -1; ScrollX: -1; ScrollY: -1; MaxScrollX: -1; MaxScrollY: -1; AddedCount: -1; RemovedCount: -1; ParcelableData: null ]; recordCount: 0
11-13 10:43:07.427 EventType: TYPE_WINDOW_STATE_CHANGED; EventTime: 35976978; PackageName: com.jxrs.jxrsapp; MovementGranularity: 0; Action: 0; ContentChangeTypes: []; WindowChangeTypes: [] [ ClassName: com.jxrs.jxrsapp.LoginActivity; Text: [姹熻タ浜虹ぞ]; ContentDescription: null; ItemCount: -1; CurrentItemIndex: -1; Enabled: true; Password: false; Checked: false; FullScreen: true; Scrollable: false; BeforeText: null; FromIndex: -1; ToIndex: -1; ScrollX: -1; ScrollY: -1; MaxScrollX: -1; MaxScrollY: -1; AddedCount: -1; RemovedCount: -1; ParcelableData: null ]; recordCount: 0

七、制裁流氓软件

有些软件无论如何,无法卸载成功,可直接使用命令adb shell pm uninstall -k --user 0 包名

C:\Users\micaw>adb shell pm uninstall -k --user 0 com.vivo.wallet

 

八、列出当前包的详细信息

C:\Users\micaw>adb shell dumpsys package com.vivo.wallet

 

 

 

九、查看当前手机有安装的app包名

C:\Users\micaw>adb shell pm list package
package:com.mediatek.gba
package:com.mediatek.ims
package:com.android.cts.priv.ctsshim

等等

adb shell pm list package -s         -s:列出系统应用

adb shell pm list package -3   -3:列出第三方应用

adb shell pm list package -f    -f:列出应用包名及对应的apk名及存放位置

十、获取当前的Activity

C:\Users\micaw>adb shell dumpsys activity activities |findstr mFocusedActivity(安卓版本小于8.0用这个命令)

C:\Users\micaw>adb shell dumpsys activity activities |findstr mResumedActivity(安卓版本大于8.0用这个命令)
mResumedActivity: ActivityRecord{17383d1 u0 net.anylocation/.TabBarActivity d0 s14 t17}

net.anylocation为当前活动的应用。