Android ADB 命令大全
1 cpu号:
文件在: /proc/cpuinfo
通过Adb shell 查看:
adb shell cat /proc/cpuinfo
2 mac 地址
文件路径 /sys/class/net/wlan0/address
adb shell cat /sys/class/net/wlan0/address
xx:xx:xx:xx:xx:aa
1. Android支持的linux command不多,在/system/bin下面可以找到,其中大部分都是Android的工具,只有一小部分是linux原有的命令
2. 一些常用的Android命令(这里只总结Android中特有的,其他的linux命令资料就很多了)
a)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]: []
watchprosp动态监视这些属性的变化,比如我修改系统的语言为中文,就会打印出:
# watchprops
watchprops
1269420653 persist.sys.language = 'zh'
1269420653 persist.sys.language = 'CN'
b) wipe <system|data|all>
wipe表示清除模拟器或者真机上的数据,比如你的模拟器用了很久,装了很多软件就可以用这个来清除
system表示清除 /system下的数据
data表述清除 /data 下的数据
c) am
usage: am [subcommand] [options]
start an Activity: am start [-D] <INTENT>
-D: enable debugging
send a broadcast Intent: am broadcast <INTENT>
start an Instrumentation: am instrument [flags] <COMPONENT>
-r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)
-e <NAME> <VALUE>: set argument <NAME> to <VALUE>
-p <FILE>: write profiling data to <FILE>
-w: wait for instrumentation to finish before returning
start profiling: am profile <PROCESS> start <FILE>
stop profiling: am profile <PROCESS> stop
<INTENT> specifications include these flags:
[-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]
[-c <CATEGORY> [-c <CATEGORY>] ...]
[-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]
[--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]
[-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]
[-n <COMPONENT>] [-f <FLAGS>] [<URI>]
am是管理activity的工具,主要有4种用法
am start/stop <INTENT> 表示启动或者停止一个activity,INTENT的参数可以在AndroidManifest.xml中的intent-filter中找到
比如我要打开发送邮件的activity就可以这样写
# am start -a android.intent.action.SEND_MULTIPLE
am start和StartActivity方法是一个作用
am也可以发送一个broadcast,后面的INTENT和上面同
除此之外还可以 start profiling和Instrumentation,这两个还不知怎么用,欢迎大家补充
d)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").
e)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充电的时候
f)bootanimation
显示开机动画,在替换默认的开机动画的时候可以用这个来调试
g)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)
h)一项常用的print message命令
dumpsy
dumpstate
logcat
dmesg
这几条命令都集成在ddms里面了,所以一般用的很少
3. 还有很多命令不知道怎么用,继续研究,完了再来更新