当前位置: 代码迷 >> Android >> [Share]最近研究Android command,稍微总结一下分享出来,该怎么解决
  详细解决方案

[Share]最近研究Android command,稍微总结一下分享出来,该怎么解决

热度:256   发布时间:2016-05-01 22:26:42.0
[Share]最近研究Android command,稍微总结一下分享出来
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.
  相关解决方案