赞
踩
因为工作的关系,经常需要用串口连接Andriod设备进行调试,命令用的多了,就想总结起来,让知识升华。
按照我的理解,常用的有三种命令:
属性和值,应用层,功能
下面对这三种调试命令分别介绍
这个命令的作用是更改安卓数据库里面的值。举个例子
settings put global device_provisioned 1
settings put secure user_setup_complete 1
settings get global device_provisioned
settings get secure user_setup_complete
博主因为要改一个和开机引导的问题,用下面这段代码来回加打印编译验证,后来再网上发现了settings命令,发现自己好蠢
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.USER_SETUP_COMPLETE, 0);
settings命令包含三类数据,security,global,system
如果需要全部列出来,则可以使用如下命令
settings list system
settings list global
settings list secure
这个命令是获取系统属性的,用法如下:
getprop prop.name
getprop | grep factory
setprop prop.name prop.value
pm dump com.xxx.xxx | grep "versionName"
am命令经常用于对应用进行调试
am start 用于打开Activity
am broadcast 用于发送广播
am startservice 用于开启服务
dumpsys用来查看系统的运行信息
dumpsys activity 查看Activity信息
dumpsys package <package-name> 查看包的信息
dumpsys activity activities 查看Activity栈
dumpsys audio 查看audio信息
dumpsys |grep BroadcastRecord 查看广播记录
dumpsys input 查看设备对应的kl文件信息
dumpsys wifi 查看wifi信息
dumpsys activity top 查看顶层应用情况,具体哪一个在最上面
这个命令和屏幕有关,主要用来进行一些屏幕相关的设置因为用的不多,所以罗列一下,就不细讲了。
usage: wm [subcommand] [options]
wm size [reset|WxH|WdpxHdp]
wm density [reset|DENSITY]
wm overscan [reset|LEFT,TOP,RIGHT,BOTTOM]
wm scaling [off|auto]
wm screen-capture [userId] [true|false]
wm size: return or override display size.width and height in pixels unless suffixed with 'dp'.
wm density: override display density.
wm overscan: set overscan area for display.
wm scaling: set display scaling mode.
wm screen-capture: enable/disable screen capture.
wm dismiss-keyguard: dismiss the keyguard, prompting the user for auth if necessary.
这个命令用来输入键值和文字很好用,对于没有遥控器和输入比较复杂的内容(例如网址)比较有用
input text text-content
input keyevent keycode
这个是截图命令,用来截取设备当前画面
usage: screencap [-hp] [-d display-id] [FILENAME]
-h: this message
-p: save the file as a png.
-d: specify the display id to capture, default 0
用来控制和sim卡相关的命令
help Show information about the subcommands
power Control the power manager
data Control mobile data connectivity
wifi Control the Wi-Fi manager
usb Control Usb state
例如,如果想关闭移动数据可以使用
svc data enable
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。