本文章已收录于:
![](http://static.blog.csdn.net/images/category_icon.jpg)
作者同类文章
X
版权声明:本文为博主原创文章,未经博主允许不得转载。
Android设备连接PC后,我们可以通过adb命令完成绝大多数工作。下面借助getprop、dumpsys来了解一些系统相关信息。
一、getprop
此命令的原理很简单,就是从系统的各种配置文件中读取信息。那么这些文件在你用adb shell进入设备内部后很容易找到,它们是:
init.rc
default.prop
/system/build.prop
- 1
- 2
- 3
- 1
- 2
- 3
此时直接使用cat命令也是可以把这些信息显示出来的。
下面列出比较常用的信息
1.获得IP
$ adb shell getprop dhcp.wlan0.ipaddress
192.168.0.107
- 1
- 2
- 1
- 2
2.手机名称
$ adb shell getprop ro.product.device
Ulike2
$ adb shell getprop ro.product.model
U705T
$ adb shell getprop ro.product.name
oppo17_12035
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 1
- 2
- 3
- 4
- 5
- 6
- 7
3.serial number
$ adb shell getprop ro.serialno
0000012035ABCXXX
- 1
- 2
- 3
- 1
- 2
- 3
4.屏幕密度
$ adb shell getprop ro.sf.lcd_density
240
- 1
- 2
- 3
- 1
- 2
- 3
好了,只要使用adb shell getprop就可以把所有的信息都打印出来。而使用setprop命令就可以进行相对应的设置啦。
二、dumpsys
Android系统启动时会有大批的服务随之启动,那么我们就可以用dumpsys命令来查看每个服务的运行情况。作为一名Android开发者,我们至少要了解这些Service的存在:
Currently running services:
DMAgent
NvRAMAgent
SurfaceFlinger
accessibility
account
activity
alarm
appwidget
audio
audioprofile
backup
battery
batteryinfo
bluetooth
bluetooth_a2dp
bluetooth_profile_manager
bluetooth_socket
clipboard
connectivity
content
country_detector
cpuinfo
device_policy
devicestoragemonitor
diskstats
drm.drmManager
dropbox
entropy
gfxinfo
hardware
input_method
iphonesubinfo
isms
location
media.audio_flinger
media.audio_policy
media.camera
media.mdp_service
media.player
meminfo
memory.dumper
mount
mtk-agps
mtk-epo-client
netpolicy
netstats
network_management
notification
oppo.com.IRUtils
package
permission
phone
power
samplingprofiler
search
sensorservice
simphonebook
statusbar
telephony.registry
telephony.registry2
textservices
throttle
uimode
usagestats
usb
vibrator
wallpaper
wifi
wifip2p
window
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
当我们需要知道设备的分辨率时,可以使用如下命令:
$ adb shell dumpsys window displays
WINDOW MANAGER DISPLAY CONTENTS (dumpsys window displays)
Display: mDisplayId=0
init=720x1280 320dpi cur=720x1280 app=720x1280 rng=720x670-1280x1230
layoutNeeded=false
- 1
- 2
- 3
- 4
- 5
- 1
- 2
- 3
- 4
- 5
or
$ adb shell dumpsys window
...
Display: init=540x960 base=540x960 cur=540x960 app=540x888 raw=540x960
- 1
- 2
- 3
- 1
- 2
- 3
Refer to :
http://blog.csdn.net/wangjia55/article/details/7446772
http://blog.csdn.net/kevinx_xu/article/details/11846289
http://blog.csdn.net/z_guijin/article/details/8203028
-
顶
- 2
-
踩
- 0
我的同类文章
http://blog.csdn.net
- •Android实战技巧之五十三:dom4j&xstream2016-06-12
- •Android问题集锦之四十八:Error:duplicate files during packaging of APK2016-06-11
- •Android实战技巧之五十一:libjpeg与Android2016-04-07
- •Android实战技巧之五十:App的系统签名2016-03-15
- •Android实战技巧之四十八:Android上的Java8和kotlin2016-02-03
- •Android问题集锦之四十六:改包名后出现Error type 32015-11-15
- •Android问题集锦之四十九:Can't add XStream file dependency to Android Studio project2016-06-11
- •Android实战技巧之五十二:fastjson2016-06-10
- •Android问题集锦之四十七: Error:Execution failed for task ':app:packageRelease'. > Unable to compute hash of2016-03-28
- •Android实战技巧之四十九:Usb通信之USB Host2016-02-25
- •Android实战技巧之四十七:不用预览拍照与图片缩放剪裁2015-11-16