AndroidADB操作命令Word格式.docx

上传人:b****6 文档编号:20741126 上传时间:2023-01-25 格式:DOCX 页数:10 大小:35.71KB
下载 相关 举报
AndroidADB操作命令Word格式.docx_第1页
第1页 / 共10页
AndroidADB操作命令Word格式.docx_第2页
第2页 / 共10页
AndroidADB操作命令Word格式.docx_第3页
第3页 / 共10页
AndroidADB操作命令Word格式.docx_第4页
第4页 / 共10页
AndroidADB操作命令Word格式.docx_第5页
第5页 / 共10页
点击查看更多>>
下载资源
资源描述

AndroidADB操作命令Word格式.docx

《AndroidADB操作命令Word格式.docx》由会员分享,可在线阅读,更多相关《AndroidADB操作命令Word格式.docx(10页珍藏版)》请在冰豆网上搜索。

AndroidADB操作命令Word格式.docx

唯一地识别一个模拟器/设备实例。

一个序列号的例子:

emulator-5554

adb[-d|-e|-s<

serialNumber>

]<

command>

-d发送命令给usb连接的设备

-e发送命令到模拟器设备

-s<

发送命令到指定设备

如启动手机设备shell:

adb-dshell

adbforward<

local>

<

remote>

发布端口,可以设置任意的端口号,做为主机向模拟器或设备的请求端口。

如:

adbforwardtcp:

5555tcp:

8000adbreboot重启手机

adbremount将system分区重新挂载为可读写分区

adbkill-server终止adb服务进程

adbstart-server重启adb服务进程

adbroot已root权限重启adb服务

adbwait-for-device在模拟器/设备连接之前把命令转载在adb的命令器中adbjdwp查看指定的设施的可用的JDW信息.

可以用forwardjdwp:

vpid>

端口映射信息来连接指定的JDW进程.例如:

adbforwardtcp:

8000jdwp:

472

jdb-attachlocalhost:

8000adbshellam命令可以启动应用程序

adbshellinputkeyevent<

event_code>

向设备发送按键事件

在编辑短信时,往文本框输入文本:

adbshellinputtext"

hello"

向手机发送键值回Home:

adbshellinputkeyevent3event_code参考view/KeyEvent.java中的KEYCODE_*

publicstaticfinalintKEYCODE_SOFT_LEFT=1;

publicstaticfinalintKEYCODE_SOFT_RIGHT=2;

publicstaticfinalintKEYCODE_HOME=3;

publicstaticfinalintKEYCODE_BACK=4;

publicstaticfinalintKEYCODE_CALL=5;

publicstaticfinalintKEYCODE_ENDCALL=6;

安装卸载系列

adbinstall[-l][-r]<

file>

-pushthispackagefiletothedeviceandinstallit

('

-l'

meansforward-locktheapp)

-r'

meansreinstalltheapp,keepingitsdata)

adbuninstall[-k]<

package>

-removethisapppackagefromthedevice

-k'

meanskeepthedataandcachedirectories)

adbinstalld:

\hello.apk

如果带-r选项重新安装apk时,安装在/data/local/tmp/目录下,手机重启后还是使用原来的apk.

文件操作系列

adbpush<

-copyfile/dirtodevice

adbpull<

-copyfile/dirfromdevice

基本linuxshell命令系列

adbshell[command]

ls列出目录下的文件和文件夹

cd切换目录

rm删除目录和文件

cat查看文件内容

ps可以看那个进程再跑

ps-x[PID]查看单个进程的状态

top可以看那个进程的占用率最高

su切换到root用户

kill[pid]杀死一个进程

chmod777<

修改该文件为可执行权限

详细使用情况可以登录一台Linux服务器在shell下查看帮助手册,man<

查看系统状态和信息系列adbshellprocrank查询各进程内存使用情况adbshellservicelist查看services信息adbshellcat/proc/meminfo查看当前的内存情况adbshellcat/proc/cpuinfo查看CPU言息(硬件)

adbshellcat/proc/iomem查看IO内存分区adbshellgetprop列出系统所有属性

adbshellgetprop|findstr"

gsm"

列出包含gsm的属性

adbshellsetprop<

key>

value>

修改系统属性

adbshellsqlite3可以执行sql语句查看数据库信息,具体使用情况待调查Log系列

adblogcat[<

filter-spec>

]-Viewdevicelog

1~~~~~~~~~~~查看可用日志缓冲区:

adblogcat-bradio—查看缓冲区的相关的信息.

adblogcat-bevents—查看和事件相关的的缓冲区.

adblogcat-bmain—查看主要的日志缓冲区

2~~~~~~~~~~~过滤日志输出:

表示是标签,priority是表示标

过滤器语句按照下面的格式描tag:

priority...,tag签的报告的最低等级

adblogcat*:

W显示优先级为warning或更高的日志信息

adblogcatActivityManager:

IMyApp:

D*:

S

日志的标签是系统部件原始信息的一个简要的标志。

(比如:

“View”就是查看系统的标

签).

优先级有下列集中,是按照从低到高顺利排列的:

V—Verbose(lowestpriority)

D—Debug

I—Info

W—Warning

E—Error

F—Fatal

S—Silent(highestpriority,onwhichnothingiseverprinted)

如果你电脑上运行logcat,相比在远程adbshell端,你还可以为环境变量

ANDROID_LOG_TAGt入一个参数来设置默认的过滤

exportANDROID_LOG_TAGS="

ActivityManager:

S"

需要注意的是ANDROID_LOG_TAGS滤器如果通过远程shell运行logcat或用adbshelllogcat来运行模拟器/设备不能输出日志.

3~~~~~~~~~~~控制日志输出格式:

日志信息包括了许多元数据域包括标签和优先级。

可以修改日志的输出格式,所以可以显示出特定的元数据域。

可以通过-v选项得到格式化输出日志的相关信息.

brief—Displaypriority/tagandPIDoforiginatingprocess(thedefaultformat).process—DisplayPIDonly.

tag—Displaythepriority/tagonly.

thread—Displayprocess:

threadandpriority/tagonly.

raw—Displaytherawlogmessage,withnoothermetadatafields.

time—Displaythedate,invocationtime,priority/tag,andPIDoftheoriginatingprocess.

long—Displayallmetadatafieldsandseparatemessageswithablanklines.

当启动了logcat,你可以通过-v选项来指定输出格式:

[adb]logcat[-v<

format>

]

下面是用thread来产生的日志格式:

adblogcat-vthread需要注意的是你只能-v选项来规定输出格式option.

4Logcat命令列表

-b<

buffer>

加载一个可使用的日志缓冲区供查看,比如event和radio.默认值是

main。

具体查看ViewingAlternativeLogBuffers.

-c清楚屏幕上的日志.

-d输出日志到屏幕上

-g输出指定的日志缓冲区,输出后退出.

-n<

count>

设置日志的最大数目<

.,默认值是4,需要和-r选项一起使用。

-r<

kbytes>

每<

时输出日志,默认值为16,需要和-f选项一起使用.

-s设置默认的过滤级别为silent.

-v<

设置日志输入格式,默认的是brief格式,要知道更多的支持的格式,参看ControllingLogOutputFormat

adbbugreport-returnallinformationfromthedevice

thatshouldbeincludedinabugreport.

adbshelldmesg查询内核缓冲区信息

adbshelldumpstate各类信息,比如进程信息,内存信息,进程是否异常,kernnel的

log等

adbshelldumpcrash

adbshelldumpsys查询所有service的状态

其他

模拟器使用镜像sdcard

用SDK里的mksdcard工具来创建FAT32磁盘镜像并在模拟器启动时加载它。

这样创建镜像:

mksdcard<

size>

比如我要创建一个64M的SD卡模拟文件,文件路径是在D:

\workspace\sdcard.img

Emulator—sdcardD:

或者在eclipse的run菜单的openrundialog对话框中配置启动参数。

#top

Usage:

top[-mmax_procs][-niterations][-ddelay][-ssort_column][-t][-h]

-mnumMaximumnumberofprocessestodisplay.

-nnumUpdatestoshowbeforeexiting.

-dnumSecondstowaitbetweenupdates.

-scolColumntosortby(cpu,vss,rss,thr).

-tShowthreadsinsteadofprocesses.

-hDisplaythishelpscreen.

-Aallprocesses

-Cbycommandname

-Nnegateselection

-GbyrealgroupID(supportsnames)

-aallw/ttyexceptsessionleaders-UbyrealuserID(supportsnames)

-dallexceptsessionleaders-gbysessionORbyeffectivegroupname

-eallprocesses-pbyprocessID

Tallprocessesonthisterminal-sprocessesinthesessionsgiven

aallw/tty,includingotherusers-tbytty

ronlyrunningprocesses

Uprocessesforspecifiedusers

xprocessesw/ocontrollingttystbytty

 

***********

outputformat

**********

longoptions

-o,ouser-defined-ffull

-j,jjobcontrolssignal

--Group--User--pid--cols--ppid

--group--user--sid--rows--info-O,Opreloaded-ovvirtualmemory--cumulative--format--deselect

-l,llonguuser-oriented--sort--tty--forest--version

*********

miscoptions

-FextrafullXregisters--heading--no-heading--context

-V,VshowversionLlistformatcodesfASCIIartforest-m,m,-L,-T,HthreadsSchildreninsum-ychange-lformat-M,Zsecuritydatactruecommandname-cschedulingclass

-w,wwideoutputnnumericWCHAN,UID-Hprocesshierarchy

netstat-ano查看网络连状态

显示协议统计信息和当前TCP/IP网络连接。

NETSTAT[-a][-b][-e][-n][-o][-pproto][-r][-s][-v][interval]

-a显示所有连接和监听端口。

-b显示包含于创建每个连接或监听端口的

可执行组件。

在某些情况下已知可执行组件

-e

-n

-o

-pproto

议之一:

-r

-s

包含于创建连接或监听端口的组件序列被显示。

这种情况下,可执行组件名在底部的[]中,顶部是其调用的组件,等等,直到TCP/IP部分。

注意此选项可能需要很长时间,如果没有足够权限可能失败。

显示以太网统计信息。

此选项可以与-s选项组合使用。

以数字形式显示地址和端口号。

显示与每个连接相关的所属进程ID。

显示proto指定的协议的连接;

proto可以是下列协议之一:

TCP、UDP、TCPv6或UDPv6。

如果与-s选项一起使用以显示按协议统计信息,proto可以是下列协

IP、IPv6、ICMRICMPv6TCPTCPv6UDP或UDPv&

显示路由表。

显示按协议统计信息。

默认地,显示IP、

IPv6

、ICMPICMPv6TCPTCPv6UDP和UDPv6的统计信息;

-p选项用于指定默认情况的子集。

-v

与-b选项一起使用时将显示包含于

为所有可执行组件创建连接或监听端口的

组件。

interval

重新显示选定统计信息,每次显示之间暂停时间间隔(以秒计)。

按CTRL+C停止重新显示统计信息。

如果省略,netstat显示当前配置信息(只显示一次)

pm

usage:

pm[list|path|install|uninstall]

pmlistpackages[-f]

pmlistpermission-groups

pmlistpermissions[-g][-f][-d][-u][GROUP]

pmlistinstrumentation[-f][TARGET-PACKAGE]

pmlistfeatures

pmpathPACKAGE

pminstall[-l][-r][-t][-iINSTALLER_PACKAGE_NAME]PATH

pmuninstall[-k]PACKAGE

pmenablePACKAGE_OR_COMPONENT

pmdisablePACKAGE_OR_COMPONENT

Thelistpackagescommandprintsallpackages.Options:

-f:

seetheirassociatedfile.

Thelistpermission-groupscommandprintsallknownpermissiongroups.

Thelistpermissionscommandprintsallknownpermissions,optionallyonlythoseinGROUP.Options:

-g:

organizebygroup.

printallinformation.

-s:

shortsummary.

-d:

onlylistdangerouspermissions.

-u:

listonlythepermissionsuserswillsee.

Thelistinstrumentationcommandprintsallinstrumentations,oronlythosethattargetaspecifiedpackage.Options:

Thelistfeaturescommandprintsallfeaturesofthesystem.

Thepathcommandprintsthepathtothe.apkofapackage.

Theinstallcommandinstallsapackagetothesystem.Options:

-l:

installthepackagewithFORWARD_LOCK.

-r:

reinstallanexisitingapp,keepingitsdata.

-t:

allowtest.apkstobeinstalled.

-i:

specifytheinstallerpackagename.

Theuninstallcommandremovesapackagefromthesystem.Options:

-k:

keepthedataandcachedirectoriesaround.

afterthepackageremoval.

Theenableanddisablecommandschangetheenabledstateof

agivenpackageorcomponent(writtenas"

package/class"

).

查看stdout和stderr

在默认状态下,Android系统有stdout和stderr(System.out和System.err)输出到/dev/null,

在运行DalvikVM的进程中,有一个系统可以备份日志文件。

在这种情况下,系统会用stdout和stderr和优先级I.来记录日志信息

通过这种方法指定输出的路径,停止运行的模拟器/设备,然后通过用setprop命令远程输入日志

$adbshellstop

$adbshellsetproplog.redirect-stdiotrue

$adbshellstart系统直到你关闭模拟器/设备前设置会一直保留,可以通过添加/data/local.prop可以使用模拟器/设备上的默认设置

UI/软件试验程序Monkey

当Monkey程序在模拟器或设备运行的时候,如果用户出发了比如点击,触摸,手势或一些系统级别的事件的时候,

它就会产生随机脉冲,所以可以用Monkey用随机重复的方法去负荷测试你开发的软件

最简单的方法就是用用下面的命令来使用Monkey这个命令将会启动你的软件并且触发

500个事件.

更多的关于命令Monkey的命令的信息,可以查看Ul/ApplicationExerciserMonkeydocumentationpage.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 考试认证 > 公务员考试

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1