adb shell dumpsys 系统服务
目录
adb shell dumpsys 命令
dumpsys 运行在手机设备上,可通过 adb shell dumpsys
命令获取系统服务状态信息。
直接运行 adb shell dumpsys
会打印出当前系统所有服务信息,可在后面加上具体的服务名
。可用的服务名可以通过-l
打印,数量非常多,有 200+
个。
常用选项:
-h
:输出帮助文档,仅部分命令支持| grep any_text
:仅输出包含指定内容的信息> file_name
:将信息导出到文件中
adb shell dumpsys activity
查看组件信息,支持-h
adb shell dumpsys activity com.bqt.test
:查看指定应用的 activity 信息(应用必须是启动状态)adb shell dumpsys activity com.bqt.test | grep ACTIVITY
:按调用顺序显示启动且未 destory 的 activityadb shell dumpsys activity com.bqt.test | grep DecorView -A5
:查看 activity 的布局结构信息
adb shell dumpsys activity a
:activity stack stateadb shell dumpsys activity a | grep mResumedActivity
:当前处于 onResumed 状态的 activityadb shell dumpsys activity a | grep mLastPausedActivity
:当前最近处于 onPaused 状态的 activityadb shell dumpsys activity a | grep Activities
:按调用顺序显示启动且未 destory 的 activityadb shell dumpsys activity a | grep ' Stack '
:显示 Stack
adb shell dumpsys activity top
:dump the top activityadb shell dumpsys activity top | grep ACTIVITY
:查看所有应用的栈顶 activityadb shell dumpsys activity top | grep DecorView -A5
:查看 activity 的布局结构信息adb shell dumpsys activity top | grep TASK
:查看所有 Task
adb shell dumpsys activity r | grep ActivityRecord
:查看近期的 activityadb shell dumpsys activity b com.bqt.test
:查看指定应用的 broadcastadb shell dumpsys activity broadcast-stats com.bqt.test
:聚合广播统计
λ adb shell dumpsys activity -h
Activity manager dump options:
[-a] [-c] [-p PACKAGE] [-h] [WHAT] ...
WHAT may be one of:
a[ctivities]: activity stack state
r[ecents]: recent activities state
b[roadcasts] [PACKAGE_NAME] [history [-s]]: broadcast state
broadcast-stats [PACKAGE_NAME]: aggregated broadcast statistics
i[ntents] [PACKAGE_NAME]: pending intent state
p[rocesses] [PACKAGE_NAME]: process state
o[om]: out of memory management
perm[issions]: URI permission grant state
prov[iders] [COMP_SPEC ...]: content provider state
provider [COMP_SPEC]: provider client-side state
s[ervices] [COMP_SPEC ...]: service state
allowed-associations: current package association restrictions
as[sociations]: tracked app associations
exit-info [PACKAGE_NAME]: historical process exit information
lmk: stats on low memory killer
lru: raw LRU process list
binder-proxies: stats on binder objects and IPCs
settings: currently applied config settings
service [COMP_SPEC]: service client-side state
package [PACKAGE_NAME]: all state related to given package
all: dump all activities
top: dump the top activity
WHAT may also be a COMP_SPEC to dump activities.
COMP_SPEC may be a component name, a partial substring in a component name, a hex object identifier.
-a: include all available server state.
-c: include client state.
-p: limit output to given package.
--checkin: output checkin format, resetting data.
--C: output checkin format, not resetting data.
--proto: output dump in protocol buffer format.
--autofill: dump just the autofill-related state of an activity
adb shell dumpsys package
查看安装包信息,支持-h
adb shell dumpsys package com.bqt.test
:查看应用安装包信息adb shell dumpsys package perm | grep 'AppOp Permission'
:查看权限信息
λ adb shell dumpsys package -h
Package manager dump options:
[-h] [-f] [--checkin] [--all-components] [cmd] ...
--checkin: dump for a checkin
-f: print details of intent filters
-h: print this help
--all-components: include all component names in package dump
cmd may be one of:
apex: list active APEXes and APEX session state
l[ibraries]: list known shared libraries
f[eatures]: list device features
k[eysets]: print known keysets
r[esolvers] [activity|service|receiver|content]: dump intent resolvers
perm[issions]: dump permissions
permission [name ...]: dump declaration and use of given permission
pref[erred]: print preferred package settings
preferred-xml [--full]: print preferred package settings as xml
prov[iders]: dump content providers
p[ackages]: dump installed packages
q[ueries]: dump app queryability calculations
s[hared-users]: dump shared user IDs
m[essages]: print collected runtime messages
v[erifiers]: print package verifier info
d[omain-preferred-apps]: print domains preferred apps
i[ntent-filter-verifiers]|ifv: print intent filter verifier info
version: print database version info
write: write current settings now
installs: details about install sessions
check-permission <permission> <package> [<user>]: does pkg hold perm?
dexopt: dump dexopt state
compiler-stats: dump compiler statistics
service-permissions: dump permissions required by services
<package.name>: info about given package
其他常用命令
可通过 adb shell dumpsys -l
命令获取可用的服务名。
adb shell dumpsys meminfo com.bqt.test
:查看指定应用的内存占用信息,支持-h
adb shell dumpsys notification | grep NotificationRecord
:近期通知记录adb shell dumpsys notification | grep 'AppSettings: com.bqt.test' -A5
:查看指定应用的通知渠道设置adb shell dumpsys cpuinfo | grep -E 'CPU usage|system_server|com.bqt.test'
:查看指定应用 cpu 使用信息adb shell dumpsys display | grep DisplayDeviceInfo
:获取设备分辨率等屏幕信息adb shell dumpsys window | grep mCurrentFocus
:查看当前 activitybattery
:电池batterystats
:电池状态alarm
:闹钟location
:位置telephony.registry
:电话gfxinfo
:帧率power
:电源wifi
:wifi
2020-05-26
本文来自博客园,作者:白乾涛,转载请注明原文链接:https://www.cnblogs.com/baiqiantao/p/12962290.html