1 / 19

Android 常用小工具

Android 常用小工具. Android 常用小工具的使用方法. Input Screencap monkey Am Pm Bugreport Procrank ( debug ) toolbox. input. input text <string> 输入字符串,可以不使用软键盘,更方便调试 ( 包括写脚本测试 ) input keyevent <event_code> 输入按键事件,支持全键盘按键,可以在没有输入设备时,操作系统。. input. JellyBean 上,可以支持更多的功能:

dyami
Télécharger la présentation

Android 常用小工具

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Android常用小工具

  2. Android常用小工具的使用方法 • Input • Screencap • monkey • Am • Pm • Bugreport • Procrank(debug) • toolbox

  3. input • input text <string> • 输入字符串,可以不使用软键盘,更方便调试(包括写脚本测试) • input keyevent <event_code> • 输入按键事件,支持全键盘按键,可以在没有输入设备时,操作系统。

  4. input JellyBean上,可以支持更多的功能: • input keyevent <key code number or name> • Keyevent可以用名字表示 • input tap <x> <y> • 可以发送一个点击事件 • input swipe <x1> <y1> <x2> <y2> • 可以发送一个滑动事件

  5. input • input keyevent 82 • Input keyevent MENU (JellyBean) • Input text hello%sworld • Input tap 20 20 • Input swip 100 100 300 300

  6. screencap 截屏工具 • 请求SurfaceFlinger重新render Surface • surfaceFlinger通过openGL画到FBO中 • 没有走hwcomposer及我们的DE最终显示 • 如果这个截图和最终屏幕显示可能不一致: • SurfaceFlinger有问题(framebuffer或hwcomposer) • 有overlay • 我们的DE有两层, graphic (Android UI) 和overlay (video/camera的显示),目前只针对前者 • 截取framebuffer,可以通过sys文件接口实现 • Cat /dev/graphics/fb0

  7. screencap • 使用方式: usage: screencap [-hp] [FILENAME] -h: this message -p: save the file as a png. If FILENAME ends with .png it will be saved as a png. If FILENAME is not given, the results will be printed to stdout. #adb shell screencap –p /sdcard/screen.png #adb pull /sdcard/screen.png ~/

  8. monkey • Monkey是设备上的可执行程序,产生随机数如事件 • Keyevent • Touch event • Guesture • System events • 开发阶段作为压力测试使用 • 客户定制阶段可部分作为稳定性验证 • 可通过脚本实现一定的测试方法

  9. monkey • 命令格式 • usage: monkey [options] COUNT • 参数详解 • Basic configuration options, such as setting the number of events to attempt. • Operational constraints, such as restricting the test to a single package. • Event types and frequencies. • Debugging options. • https://developer.android.com/tools/help/monkey.html

  10. monkey • 常用命令 • Monkey 100 • 基本命令 • monkey --ignore-crashes --ignore-timeouts 99999 • 无特定目的的压力测试 • Monkey –p com.android.browser –p com.android.launcher –v –v 999999 • 仅测试lancher和browser,测试是输出最多的trace信息

  11. am • Android可以支持从命令行控制android的启动行为 • 在项目/硬件带起的初始阶段,很有帮助 • usage: am [subcommand] [options]

  12. am • 启动music • am start -n com.android.music/com.android.music.MediaPlaybackActivity  • 拨打电话 • am start -a android.intent.action.CALL -d tel:10086 • 浏览网页 • am start -a android.intent.action.VIEW -d http://www.google.cn/

  13. am • 性能测试 • am profile com.android.browser start /sdcard/dump.trace • am profile com.android.browser stop • 结合traceview,可以很方便tracejava程序的性能问题 • 目前的版本,traceview运行不起来(log 不配对)。

  14. pm • usage: pm [list|path|install|uninstall] • Android的包管理工具,功能强大 • 调试时会经常使用:安装、卸载、禁用等

  15. bugreport • Bugreport比较简单,主要是收集系统信息并输出到文件,以供开发人员分析 • 注意很多信息可能需要root权限才能获得 • 实际执行的就是dumpstate,获取的信息包括 • Logcat • Kernel message • Dumpsys • 其他系统信息

  16. procrank • 获得当前系统中各进程的内存使用快照 • 只有工程版本才带此工具 • 使用方法: Usage: procrank [ -W ] [ -v | -r | -p | -u | -h ] -v Sort by VSS. -r Sort by RSS. -p Sort by PSS. -u Sort by USS. (Default sort order is PSS.) -R Reverse sort order (default is descending). -w Display statistics for working set only. -W Reset working set of all processes. -h Display this help screen.

  17. procrank • VSS - Virtual Set Size 虚拟耗用内存(包含共享库占用的内存)RSS - Resident Set Size 实际使用物理内存(包含共享库占用的内存)PSS - Proportional Set Size 实际使用的物理内存(比例分配共享库占用的内存)USS - Unique Set Size 进程独自占用的物理内存(不包含共享库占用的内存) • Procrank在我们机器上统计的并不准确

  18. toolbox • Android实现的shell命令 • 少的可怜 • 功能简单,不够强大 • 工具参看 system/core/toolbox/Android.mk • 我们的系统提供了更强大的busybox

  19. Thanks!

More Related