Chinaunix首页 | 论坛 | 博客
  • 博客访问: 686748
  • 博文数量: 182
  • 博客积分: 2088
  • 博客等级: 大尉
  • 技术积分: 1698
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-16 15:09
个人简介

.

文章分类

全部博文(182)

文章存档

2016年(1)

2015年(18)

2014年(14)

2013年(20)

2012年(129)

分类: Android平台

2013-03-20 20:47:15

Android支持的linux command不多,在/system/bin下面可以找到,其中大部分都是Android的工具,只有一小部分是linux原有的命令
一些常用的Android命令(这里只总结Android中特有的,其他的linux命令资料就很多了)
1) getprop/watchprops
getprop列出系统的属性,前面十名字,后面是值
# getprop
getprop
[ro.secure]: [0]
[ro.allow.mock.location]: [1]
[ro.debuggable]: [1]
[persist.service.adb.enable]: [1]
[ro.kernel.qemu]: [1]
[ro.kernel.console]: [ttyS0]
[ro.kernel.android.checkjni]: [1]
[ro.kernel.android.qemud]: [ttyS1]
[ro.kernel.android.ndns]: [1]
[ro.factorytest]: [0]
[ro.serialno]: []

2) watchprosp动态监视这些属性的变化,比如我修改系统的语言为中文,就会打印出:
# watchprops
watchprops
1269420653 persist.sys.language = 'zh'
1269420653 persist.sys.language = 'CN'

3) wipe
wipe表示清除模拟器或者真机上的数据,比如你的模拟器用了很久,装了很多软件就可以用这个来清除
system表示清除 /system下的数据
data表述清除 /data 下的数据

4) am
usage: am [subcommand] [options]

  start an Activity: am start [-D]
  -D: enable debugging

  send a broadcast Intent: am broadcast

  start an Instrumentation: am instrument [flags]
  -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)
  -e : set argument to
  -p : write profiling data to
  -w: wait for instrumentation to finish before returning

  start profiling: am profile start
  stop profiling: am profile stop

  specifications include these flags:
  [-a ] [-d ] [-t ]
  [-c [-c ] ...]
  [-e|--es ...]
  [--ez ...]
  [-e|--ei ...]
  [-n ] [-f ] []

am是管理activity的工具,主要有4种用法
am start/stop 表示启动或者停止一个activity,INTENT的参数可以在AndroidManifest.xml中的intent-filter中找到
比如我要打开发送邮件的activity就可以这样写
# am start -a android.intent.action.SEND_MULTIPLE
am start和StartActivity方法是一个作用

am也可以发送一个broadcast,后面的INTENT和上面同
除此之外还可以 start profiling和Instrumentation,这两个还不知怎么用,欢迎大家补充

5) pm
pm就是package manager,可以带下面的参数,因为帮助都说的很清楚了,我就不作解释了
usage: pm [list|path|install|uninstall]
  pm list packages [-f]
  pm list permission-groups
  pm list permissions [-g] [-f] [-d] [-u] [GROUP]
  pm list instrumentation [-f] [TARGET-PACKAGE]
  pm list features
  pm path PACKAGE
  pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] PATH
  pm uninstall [-k] PACKAGE
  pm enable PACKAGE_OR_COMPONENT
  pm disable PACKAGE_OR_COMPONENT

The list packages command prints all packages. Options:
  -f: see their associated file.

The list permission-groups command prints all known
permission groups.

The list permissions command prints all known
permissions, optionally only those in GROUP. Options:
  -g: organize by group.
  -f: print all information.
  -s: short summary.
  -d: only list dangerous permissions.
  -u: list only the permissions users will see.

The list instrumentation command prints all instrumentations,
or only those that target a specified package. Options:
  -f: see their associated file.

The list features command prints all features of the system.

The path command prints the path to the .apk of a package.

The install command installs a package to the system. Options:
  -l: install the package with FORWARD_LOCK.
  -r: reinstall an exisiting app, keeping its data.
  -t: allow test .apks to be installed.
  -i: specify the installer package name.

The uninstall command removes a package from the system. Options:
  -k: keep the data and cache directories around.
after the package removal.

The enable and disable commands change the enabled state of
a given package or component (written as "package/class").

6) svc
svc可硬用来管理wifi,power和data
svc [wifi|data|power] [option]

usage: svc wifi [enable|disable]
  打开或者关闭wifi

usage: svc power stayon [true|false|usb|ac]
  true电源一直保持stay on的状态,
  usb插上usb才保持stay on
  ac充电的时候

7) bootanimation
显示开机动画,在替换默认的开机动画的时候可以用这个来调试

8) getevent & sendevent
getevent监控当前的事件,鼠标事件,按键事件,拖动滑动等

# getevent
getevent
add device 1: /dev/input/event0
  name: "qwerty2"
/dev/input/event0: 0001 001e 00000001
/dev/input/event0: 0001 001e 00000000

其中/dev/input/event0是device的名字 0001是type, 001e是键码, 最后一个根据type不同而不同
比如上面的倒数第二条就是按下a键的keydown,最后一个是按下a的keyup
具体的type,code,value的定义可以在源码/frameworks/base/core/java/android/view/KeyEvent.java中找到

sendevent发送时间,格式和上面的一样,需要注意的是在get中code显示的是十六进制,而send中需要用十进制,例如

# sendevent /dev/input/event0 1 5 1
这个命令就是发送数字4的keydown消息,所以在屏幕上就会一直打印出很多个4(因为没有发送keyup)

9) 一项常用的print message命令
dumpsy
dumpstate
logcat
dmesg
这几条命令都集成在ddms里面了,所以一般用的很少

转载地址:http://www.cnblogs.com/armlinux/archive/2011/09/25/2396805.html

10) stop


阅读(1421) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~