adb
常用命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| adb devices adb kill-server adb tcpip adb connect adb logcat adb bugreport # 查看资源信息 adb shell dumpsys -l # 查看当前包名 adb shell dumpsys activity # app信息 adb shell dumpsys activity top # 获取当前界⾯元素 adb shell dumpsys activity activities # 获取任务列表 # app⼊口 adb logcat |grep -i displayed aapt dump badging mobike.apk | grep launchable-activity apkanalyzer # 启动应⽤ adb shell am start -W -n com.xueqiu.android/.view.WelcomeActivityAlias -S # 查看当前活动页面 adb shell dumpsys activity | grep mFocusedActivity adb shell dumpsys activity activities|grep realActivity adb logcat | grep -i displayed # dump当前页面信息 adb shell "uiautomator dump && cat /sdcard/window_dump.xml" # x浏览器主页面点击主菜单 adb shell input tap $(adb shell "uiautomator dump --compressed && cat /sdcard/window_dump.xml" | sed 's\<node\^<node>\g' | awk 'BEGIN{RS="^"}{print $0}' | grep 主菜单 | awk 'BEGIN{FS=",|\\[|\\]"}{print ($2+$5)/2,($3+$6)/2}')
# 获取所有的dumpsys⼦命令 dumpsys |grep -i DUMP # 获取当前activity adb shell dumpsys activity top # 获取activities的记录,可以获取到appium依赖的原始activity adb shell dumpsys activity activities # 获取特定包基本信息 adb shell dumpsys package com.mmbox.xbrowser # 获取系统通知 adb shell dumpsys notification # 获得内存信息 adb shell dumpsys meminfo com.android.settings # 获取cpu信息 adb shell dumpsys cpuinfo # 获取gpu绘制分析 adb shell dumpsys gfxinfo com.android.settings # 获取短信 adb shell dumpsys activity broadcasts | grep senderName=
|
1 2 3 4 5 6
| # 获取内存信息 adb shell dumpsys meminfo com.mmbox.xbrowser # 一秒滑动一次 while true;do adb shell input swipe 270 850 240 320 1000;done # app内存占用图形化 for i in $(seq 20); do adb shell dumpsys meminfo com.mmbox.xbrowser | grep "Dalvik Heap" | awk '{print $4}'; sleep 1; done | gnuplot -e "set terminal dumb;plot '<cat' using 1 with line"
|
模拟器
1 2 3 4 5
| # 进⼊emulator所在⽬录 emulator -list-avds emulator @avd (cd $(dirname $(which emulator));emulator @Nexus_6P_API_23;)
|
func
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| # 点击 click(){ local index=1 [ -n "$2" ] && index=$2 adb shell input tap $(\ adb shell "uiautomator dump --compressed && cat /sdcard/window_dump.xml" \ | sed 's\<node\^<node>\g' \ | awk 'BEGIN{RS="^"}{print $0}' \ | grep "$1" \ | sed -n "$index"p \ | awk 'BEGIN{FS=",|\\[|\\]"}{print ($2+$5)/2,($3+$6)/2}'\ ) } # x浏览器试验 for kw in X浏览器 主菜单 历史;do click $kw;done
# 输入 input(){ adb shell input test $1 }
# 滑动 swipe(){ width=$(adb shell wm size | grep -oE "[0-9]*" | head -1) heigth=$(adb shell wm size | grep -oE "[0-9]*" | tail -1) adb shell input swipe $(awk 'BEGIN{print '$width'*'$1'}') $(awk 'BEGIN{print '$heigth'*'$2'}') $(awk 'BEGIN{print '$width'*'$3'}') $(awk 'BEGIN{print '$heigth'*'$4'}') 1000 }
|
scrcpy
https://github.com/Genymobile/scrcpy
实体键映射
切换全屏模式 |
Ctrl +f |
将窗口大小调整为 1:1(像素完美) |
Ctrl +g |
调整窗口大小以删除黑色边框 |
Ctrl + x | 双击¹ |
点击 HOME |
Ctrl + h | 中键单击 |
点击 BACK |
Ctrl + b | 右键单击² |
点击 APP_SWITCH |
Ctrl +s |
点击 MENU |
Ctrl +m |
点击 VOLUME_UP |
Ctrl + ↑ (向上) |
点击 VOLUME_DOWN |
Ctrl + ↓ (下) |
点击 POWER |
Ctrl +p |
打开屏幕 |
右键单击² |
将计算机剪贴板粘贴到设备 |
Ctrl +v |
启用/禁用 FPS 计数器(在标准输出上) |
Ctrl +i |
从电脑安装APK |
拖放 APK 文件 |
推送文件到 /sdcard/ |
拖放非 APK 文件 |