Android dumpsys工具

分类: LINUX

这是一个很好用的工具,在adb shell下可以使用,主要用来获取一些系统service的信息,也可以对这些服务做一些简单的控制。

首先是获得哪些service信息可以dump
  1. $ adb shell dumpsys | grep DUMP
  2. DUMP OF SERVICE AtCmdFwd:
    DUMP OF SERVICE SurfaceFlinger:
    DUMP OF SERVICE accessibility:
    DUMP OF SERVICE account:
    DUMP OF SERVICE activity:
    DUMP OF SERVICE alarm:
    DUMP OF SERVICE appwidget:
    DUMP OF SERVICE audio:
    DUMP OF SERVICE backup:
    DUMP OF SERVICE battery:
    DUMP OF SERVICE batteryinfo:
    DUMP OF SERVICE bluetooth:
    DUMP OF SERVICE bluetooth_a2dp:
    DUMP OF SERVICE clipboard:
    ....

然后就是具体获取某个服务的信息,比如电池使用信息:
  1. $ adb shell dumpsys batteryinfo

比如抓某个package的进程的memory使用情况:
  1. $ adb shell dumpsys meminfo YourPkg

再比如测试wifi功能,写个script脚本:
  1. $ adb shell svc wifi enable  # disable对应禁用wifi
  2. $ adb shell sleep 4
  3. $ adb shell dumpsys wifi > wifiEnable.txt

如果dumpsys不能用,检查你的manifest.xml是不是加了这个permission:
  1. android.permission.DUMP

Android has an interesting command called dumpsys  to dump some system information. Even described on adb manual  I think that some points should be reinforced. In order to get the complete status just run (will produce a large output):

adb shell dumpsys

Also you can apply filters to running services:

1 SurfaceFlinger

2 accessibility

3 account

4 activity

5 alarm

6 appwidget

7 audio

8 backup

9 battery

10 batteryinfo

11 bluetooth

12 bluetooth_a2dp

13 clipboard

14 connectivity

15 content

16 cpuinfo

17 device_policy

18 devicestoragemonitor

19 diskstats

20 dropbox

21 entropy

22 ethernet

23 hardware

24 input_method

25 iphonesubinfo

26 isms

27 keybar

28 location

29 media.audio_flinger

30 media.audio_policy

31 media.camera

32 media.player

33 meminfo

34 mount

35 netstat

36 network_management

37 notification

38 package

39 permission

40 phone

41 power

42 search

43 sensorservice

44 simphonebook

45 statusbar

46 telephony.registry

47 throttle

48 uimode

49 usagestats

50 vibrator

51 wallpaper

52 wifi

53 window

Some examples:

adb shell dumpsys wifi
adb shell dumpsys cpuinfo

I suggest you try other items on the list above and be creative using all the power of Unix pipes. Example, to get all memory allocated by each process you can do something like:

adb shell dumpsys meminfo | grep "allocated:" | awk '{total = total + $5}END{print total}'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值