adb进阶四 —— dumpsys

adb进阶四 —— dumpsys

dumpsys简介

Dumpsys用于系统诊断,并提供系统服务状态信息,命令格式:

1
adb shell dumpsys [system serbices]

系统服务查询

直接运行adb shell dumpsys会输出很多很多信息,可以指定需要检查的服务

查看系统服务、:

1
2
3
adb shell service list
或者
adb shell dumpsys -l

可以看见cpuinfomeminfo等服务,因此指定检查的服务示例:

1
2
3
4
5
6
7
8
9
10
11
12
{lamb} adb shell dumpsys cpuinfo
Load: 6.04 / 6.17 / 6.21
CPU usage from 364288ms to 62061ms ago (2019-04-12 16:20:56.605 to 2019-04-12 16:25:58.831):
99% 28771/com.tencent.tmgp.supercell.clashofclans: 99% user + 0% kernel / faults: 128 minor
2.4% 1641/system_server: 1.4% user + 0.9% kernel / faults: 5586 minor 1 major
1.3% 582/android.hardware.sensors@1.0-service: 0.5% user + 0.7% kernel
0.9% 441/ueventd: 0.6% user + 0.3% kernel
0.6% 4950/kworker/u16:2: 0% user + 0.6% kernel
0.5% 5727/kworker/u16:0: 0% user + 0.5% kernel
0.5% 5679/kworker/u16:5: 0% user + 0.5% kernel

... ...

命令行参数:

1
2
-h:对于大多数的服务,可以添加-h看到文本的帮助
-c:对于一些服务,可以添加-c查看数据会更友好

例如:

1
2
3
4
5
6
7
8
9
10
{lamb} adb shell dumpsys usb -h
Dump current USB state or issue command:
ports
set-port-roles <id> <source|sink|no-power> <host|device|no-data>
add-port <id> <ufp|dfp|dual|none>
connect-port <id> <ufp|dfp><?> <source|sink><?> <host|device><?>
(add ? suffix if mode, power role, or data role can be changed)
disconnect-port <id>
remove-port <id>
reset

包服务查询

格式:

1
adb shell dumpsys package [-h] [-f] [—checkin] [cmd]…
参数 说明
-h 打印帮助信息
-f 打印intent filter的信息
–checkin 打印出已经登记的库、系统功能、安装包
cmd 子命令(可以在-h帮助文档中查看有哪些子命令)
cmd子命令 说明
prov[iders] 获取content providers
p[ackages] 获取安装包基本信息
s[hared-user] 获取共享用户ID的应用
m[essages] 打印运行时收集的信息
v[erifiers] 打印包校验信息
version 打印数据库版本信息
write 写当前位置
package.name 输出给定包的信息
installs 安装会话的详细信息
l[ibraries] 列出已知的共享库
f[ibraries] 列出手机的功能
k[eysets] 列出各个包的Signing KeySets
r[esolvers] 获取intent filter
perm[issions] 获取权限
pref[erred] 打印包首选项
preferred-xml [—full] 打印包首选项,xml格式打印

示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{lamb} adb shell dumpsys package com.kuaikan.comic 
Activity Resolver Table:
Schemes:
qwallet1104081998:
2d32642 com.kuaikan.comic/com.kuaikan.pay.kkb.activity.RechargeCenterActivity filter ba2036f
Action: "android.intent.action.VIEW"
Category: "android.intent.category.BROWSABLE"
Category: "android.intent.category.DEFAULT"
Scheme: "qwallet1104081998"
commonqwallet20181030:
7efe8c0 com.kuaikan.comic/com.kuaikan.pay.cashPay.TranslucentPayActivity filter b5a1d49
Action: "android.intent.action.VIEW"
Category: "android.intent.category.BROWSABLE"
Category: "android.intent.category.DEFAULT"
Scheme: "commonqwallet20181030"
Scheme: "commonalipay20181030"
Scheme: "commonwx20181030"
Scheme: "commonpay20181105"
comicwx201804028:

activity信息查询

格式:

1
adb shell dumpsys activity [-a] [-c]…
参数 说明
-a 包括所有可用的服务器状态
-c 包括客户端状态
-p 限制输出为给定的包,例如: adb shell dumpsys activity -p com.android.browser
-h 打印帮助信息
cmd 子命令
cmd子命令 说明
a[ctivities] activity堆栈状态
r[recents] 最近activity的状态
b[rodacasts] [package_name] [histpry [-s]] 广播状态
i[ntents] [package_name] 挂起的intent状态
p[rocesses] [package_name] 进程状态
o[om] oom管理
perm[issions] url权限授权状态
prov[iders] [comp_spec…] content provider状态
provider [comp_spec] provider客户端状态
s[ervices] [comp_spec…] 服务状态
as[sociations] 跟踪应用程序的关联
service [comp_spec] 服务客户端状态
package [package_name] 给的包的所有状态
all 转储所有的activityes
top 转储栈顶的activity
write 写入所有挂起状态存储
track-associations 允许会话跟踪
untrack-associations 禁用和明确会话跟踪,命令参数可能也是一个comp_spec 转储的activity

示例:

1
2
3
4
5
# 获取当前页面UI信息
adb shell dumpsys activity top

# 获取当前页面的Activity
adb shell dumpsys activity top | findstr ACTIVITY

网络信息查询

| 子命令 | 说明 |命令格式|
|——–|——–|
| connectivity | 网络连接 |adb shell dumpsys connectivity|
|netpolicy |网络策略 | adb shell dumpsys netpolicy|
|netstats | 网络状态| adb shell dumpsys netstats|
| network_management| 网络管理|adb shell dumpsys network_management |

其他常用服务信息查询

| 子命令 | 说明 |命令格式|
|——–|——–|
| meminfo | 内存 |adb shell dumpsys meminfo|
|cpuinfo |CPU |adb shell dumpsys cpuinfo |
|gfxinfo | 帧率|adb shell dumpsys gfxinfo |
| display| 显示|adb shell dumpsys display |
|power |电源 |adb shell dumpsys power |
|batterystats |电池状态 |adb shell dumpsys batterystats |
|battery |电池 |adb shell dumpsys battery |
|alarm |闹钟 |adb shell dumpsys alarm |
|location |位置 |adb shell dumpsys location |
|wifi |wifi |adb shell dumpsys wifi |
|power |电源 |adb shell dumpsys power |
|notification |通知 |adb shell dumpsys notification |

示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 电池信息
{lamb} adb shell dumpsys battery
Current Battery Service state:
AC powered: false
USB powered: true
Wireless powered: false
Max charging current: 500000
Max charging voltage: 5000000
Charge counter: 3321815
status: 5 #电池状态
health: 2
present: true
level: 100 #电量
scale: 100
voltage: 4369
temperature: 310 #电池温度
technology: Li-poly

完~

文章目录
  1. dumpsys简介
    1. 系统服务查询
  2. 包服务查询
  3. activity信息查询
  4. 网络信息查询
  5. 其他常用服务信息查询
|