android adb shell 常用命令
ofollow,noindex">adbshell
adb常用命令
1.模擬點選
adb shell input tap 100 100
2.滑動
adb shell input swipe x1 y1 x2 y2 adb input touchscreen swipe x1 y1 x2 y2 100 adb shell input swipe 100 100 400 100300 #左往右 adb shell input swipe 400 100 100 100300 #右往左 adb shell input swipe 100 100 100 400300 #上往下 adb shell input swipe 100 400 100 100300 #下往上 adb shell input swipe 100 100 400 400300 #上往下斜 adb shell input swipe 400 400 100 100300 #下往上斜
3.長按
adb shell input swipe 100 100 100 1001000 //在 100 100 位置長按 1000毫秒 adb shell input swipe 367 469 367 469 800
4.列印所有包名
adb shell pm list packages ➜~ adb shell pm list packages package:com.huawei.floatMms package:com.android.defcontainer package:com.tencent.mm
5.打印製定包的apk路徑
adb shell pm path com.android.phone ➜~ adb shell pm path com.huawei.android.launcher package:/system/app/HwLauncher6.apk
6.刪除制定包
adb shell pm clear com.test.abc
7.截圖
adb shell screencap /sdcard/screen.png adb pull /sdcard/screen.png #下載到本地
8.獲取被點選的位置資訊
adb shell getevent > /dev/input/event0 3 39 3e1 /dev/input/event0 1 14a 1 /dev/input/event0 1 145 1 /dev/input/event0 3 35 406//x座標 /dev/input/event0 3 54 1083//y座標 /dev/input/event0 0 0 0 /dev/input/event0 3 39 ffffffff /dev/input/event0 1 14a 0 /dev/input/event0 1 145 0 /dev/input/event0 0 0 getevent -l -c 16 輸出所有event裝置的基本資訊 add device 1: /dev/input/event2 name:"hi6421_on" could not get driver version for /dev/input/mouse0, Not a typewriter add device 2: /dev/input/event4 name:"huawei,touchscreen" add device 3: /dev/input/event0 name:"mhl_rcp_dev" could not get driver version for /dev/input/mice, Not a typewriter add device 4: /dev/input/event1 name:"hisi_gpio_key.14" add device 5: /dev/input/event3 name:"hi3630_hi6401_CARD Headset Jack" getevent -c 10 //輸出10條資訊後退出 getevent -l//將type、code、value以對應的常量名稱顯示
9.開啟對應的activity
adb shell am start -n {包(package)名}/{包名}.{活動(activity)名稱} adb shell am start com.songheng.eastnews/com.oa.eastfirst.activity.WelcomeActivity
10.獲得當前活動視窗的資訊,包名以及活動窗體
adb shell dumpsys window windows | grep mCurrent
11.包名管理命令,獲得對應包名的對應apk路徑
adb shell pmpath com.migu.lobby
12.使用dumpsys命令可以檢視Android手機當前正在執行的Activity
adb shell dumpsys activity activities | findstr "Run"
13.使用 uiautomator dump 獲取app上的頁面元素
adb shell uiautomator dump /data/local/tmp/uidump.xml adb shell uiautomator dump /sdcard/dump.xml
14.下載檔案
adb pull /sdcard/demo.mp4
15.上傳檔案
adb push test.apk /sdcard
16.息屏
adb shell input keyevent 26
17.keyevent
adb shell input keyevent 20 #向下 adb shell input keyevent 4 #返回 adb shell input keyevent 3 #Home adb shell input keyevent 6 #掛機 adb shell input keyevent 84 #搜尋 adb shell input keyevent 26 #電源 adb shell input keyevent 24 #音量+ adb shell input keyevent 25 #音量-
導航
3 Home 4 Back 19 Up 20 Down 21 Left 22 Right 23 Select/Ok 24 Volume+ 25 Volume- 82 Menu 選單 adb shell input text "ANDROID" 支援的KEYCODE 0 -->"KEYCODE_UNKNOWN" 1 -->"KEYCODE_MENU" 2 -->"KEYCODE_SOFT_RIGHT" 3 -->"KEYCODE_HOME" 4 -->"KEYCODE_BACK" 5 -->"KEYCODE_CALL" 6 -->"KEYCODE_ENDCALL" 7 -->"KEYCODE_0" 8 -->"KEYCODE_1" 9 -->"KEYCODE_2" 10 -->"KEYCODE_3" 11 -->"KEYCODE_4" 12 -->"KEYCODE_5" 13 -->"KEYCODE_6" 14 -->"KEYCODE_7" 15 -->"KEYCODE_8" 16 -->"KEYCODE_9" 17 -->"KEYCODE_STAR" 18 -->"KEYCODE_POUND" 19 -->"KEYCODE_DPAD_UP" 20 -->"KEYCODE_DPAD_DOWN" 21 -->"KEYCODE_DPAD_LEFT" 22 -->"KEYCODE_DPAD_RIGHT" 23 -->"KEYCODE_DPAD_CENTER" 24 -->"KEYCODE_VOLUME_UP" 25 -->"KEYCODE_VOLUME_DOWN" 26 -->"KEYCODE_POWER" 27 -->"KEYCODE_CAMERA" 28 -->"KEYCODE_CLEAR" 29 -->"KEYCODE_A" 30 -->"KEYCODE_B" 31 -->"KEYCODE_C" 32 -->"KEYCODE_D" 33 -->"KEYCODE_E" 34 -->"KEYCODE_F" 35 -->"KEYCODE_G" 36 -->"KEYCODE_H" 37 -->"KEYCODE_I" 38 -->"KEYCODE_J" 39 -->"KEYCODE_K" 40 -->"KEYCODE_L" 41 -->"KEYCODE_M" 42 -->"KEYCODE_N" 43 -->"KEYCODE_O" 44 -->"KEYCODE_P" 45 -->"KEYCODE_Q" 46 -->"KEYCODE_R" 47 -->"KEYCODE_S" 48 -->"KEYCODE_T" 49 -->"KEYCODE_U" 50 -->"KEYCODE_V" 51 -->"KEYCODE_W" 52 -->"KEYCODE_X" 53 -->"KEYCODE_Y" 54 -->"KEYCODE_Z" 55 -->"KEYCODE_COMMA" 56 -->"KEYCODE_PERIOD" 57 -->"KEYCODE_ALT_LEFT" 58 -->"KEYCODE_ALT_RIGHT" 59 -->"KEYCODE_SHIFT_LEFT" 60 -->"KEYCODE_SHIFT_RIGHT" 61 -->"KEYCODE_TAB" 62 -->"KEYCODE_SPACE" 63 -->"KEYCODE_SYM" 64 -->"KEYCODE_EXPLORER" 65 -->"KEYCODE_ENVELOPE" 66 -->"KEYCODE_ENTER" 67 -->"KEYCODE_DEL" 68 -->"KEYCODE_GRAVE" 69 -->"KEYCODE_MINUS" 70 -->"KEYCODE_EQUALS" 71 -->"KEYCODE_LEFT_BRACKET" 72 -->"KEYCODE_RIGHT_BRACKET" 73 -->"KEYCODE_BACKSLASH" 74 -->"KEYCODE_SEMICOLON" 75 -->"KEYCODE_APOSTROPHE" 76 -->"KEYCODE_SLASH" 77 -->"KEYCODE_AT" 78 -->"KEYCODE_NUM" 79 -->"KEYCODE_HEADSETHOOK" 80 -->"KEYCODE_FOCUS" 81 -->"KEYCODE_PLUS" 82 -->"KEYCODE_MENU" 83 -->"KEYCODE_NOTIFICATION" 84 -->"KEYCODE_SEARCH" 85 -->"TAG_LAST_KEYCODE"
adb shell input keyevent值所對應的字元 adb命令模擬按鍵事件 KeyCode
18.輸入框輸入
adb shell input text "ANDROID"
19.利用無線來檢視adb shell
> adb tcpip 5555 連線: > adb connect IP:5555
20.檢視所有已經連線上的裝置
adb devices
21.安裝解除安裝
adb install <apk檔案路徑> adb install -r <apk檔案路徑>通過install命令來安裝apk檔案,-r引數可以重新安裝某個應用並保留應用資料 adb install -r ~/chrome.apk 解除安裝應用: adb uninstall <軟體名> adb uninstall -k < 軟體名>如果加 -k 引數,為解除安裝軟體但是保留配置和快取檔案 adb uninstall com.android.chrome
22.關機命令
adb shell su reboot -p
重啟
reboot