android 常用小工具

19
1

Upload: dyami

Post on 14-Feb-2016

160 views

Category:

Documents


1 download

DESCRIPTION

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

TRANSCRIPT

Page 1: Android 常用小工具

1

Page 2: Android 常用小工具

Android常用小工具的使用方法InputScreencapmonkeyAmPmBugreportProcrank ( debug )toolbox

2

Page 3: Android 常用小工具

input

input text <string>输入字符串,可以不使用软键盘,更方便调试 (包括写脚本测试 )

input keyevent <event_code>输入按键事件,支持全键盘按键,可以在没有输入设备时,操作系统。

3

Page 4: Android 常用小工具

inputJellyBean上,可以支持更多的功能: input keyevent <key code number or name>

Keyevent 可以用名字表示input tap <x> <y>

可以发送一个点击事件input swipe <x1> <y1> <x2> <y2>

可以发送一个滑动事件

4

Page 5: Android 常用小工具

input

input keyevent 82Input keyevent MENU (JellyBean)Input text hello%sworldInput tap 20 20Input swip 100 100 300 300

5

Page 6: Android 常用小工具

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

6

Page 7: Android 常用小工具

screencap使用方式 :

7

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 ~/

Page 8: Android 常用小工具

monkeyMonkey 是设备上的可执行程序,产生随机数如事件

KeyeventTouch eventGuestureSystem events

开发阶段作为压力测试使用客户定制阶段可部分作为稳定性验证可通过脚本实现一定的测试方法

8

Page 9: Android 常用小工具

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

9

Page 10: Android 常用小工具

monkey常用命令

Monkey 100 基本命令

monkey --ignore-crashes --ignore-timeouts 99999 无特定目的的压力测试

Monkey –p com.android.browser –p com.android.launcher –v –v 999999 仅测试 lancher 和 browser ,测试是输出最多的 trace 信息

10

Page 11: Android 常用小工具

amAndroid 可以支持从命令行控制 android 的启动行为在项目 /硬件带起的初始阶段,很有帮助

usage: am [subcommand] [options]

11

Page 12: Android 常用小工具

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/

12

Page 13: Android 常用小工具

am性能测试

am profile com.android.browser start /sdcard/dump.trace

am profile com.android.browser stop

结合 traceview ,可以很方便 tracejava 程序的性能问题 目前的版本, traceview 运行不起来 (log 不配对 )。

13

Page 14: Android 常用小工具

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

14

Page 15: Android 常用小工具

bugreportBugreport 比较简单,主要是收集系统信息并输出到文件,以供开发人员分析

注意很多信息可能需要 root 权限才能获得实际执行的就是 dumpstate ,获取的信息包括

Logcat Kernel message Dumpsys 其他系统信息

15

Page 16: Android 常用小工具

procrank获得当前系统中各进程的内存使用快照只有工程版本才带此工具使用方法:

16

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.

Page 17: Android 常用小工具

procrankVSS - Virtual Set Size 虚拟耗用内存(包含共享库占用的内存)

RSS - Resident Set Size 实际使用物理内存(包含共享库占用的内存)PSS - Proportional Set Size 实际使用的物理内存(比例分配共享库占用的内存)USS - Unique Set Size 进程独自占用的物理内存(不包含共享库占用的内存)

Procrank 在我们机器上统计的并不准确17

Page 18: Android 常用小工具

toolboxAndroid 实现的 shell 命令

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

18

Page 19: Android 常用小工具

Thanks !

19