Android提供的dumpsys工具能够用于查看手机中的应用程序和系统服务信息与状态,手机连接电脑后能够直接命令行运行adb shell dumpsys 查看全部支持的Service可是这样输出的太多,能够通过dumpsys | grep "DUMP OF SERVICE" 仅显示基本的Service的信息。关于这个命令的用法在这里做一下记录,以备使用。
1、dumpsys支持的全部命令
输入:adb shell dumpsys | grep DUMP或
adb shell dumpsys | grep "DUMP OF SERVICE"
就列出了当前手机支持的全部dumpsys參数:
DUMP OF SERVICE Exynos.HWCService:DUMP OF SERVICE SurfaceFlinger:DUMP OF SERVICE access_control:DUMP OF SERVICE accessibility:DUMP OF SERVICE account:DUMP OF SERVICE activity:DUMP OF SERVICE alarm:DUMP OF SERVICE android.security.keystore:DUMP OF SERVICE appops:DUMP OF SERVICE appwidget:DUMP OF SERVICE audio:DUMP OF SERVICE backup:DUMP OF SERVICE battery:DUMP OF SERVICE batterypropreg:DUMP OF SERVICE batterystats:DUMP OF SERVICE bluetooth_manager:DUMP OF SERVICE blurglassinfo:DUMP OF SERVICE clipboard:DUMP OF SERVICE com.meizu.nfc.NxpExt:DUMP OF SERVICE commontime_management:DUMP OF SERVICE connectivity:DUMP OF SERVICE consumer_ir:DUMP OF SERVICE content:DUMP OF SERVICE country_detector:DUMP OF SERVICE cpuinfo:DUMP OF SERVICE dbinfo:DUMP OF SERVICE deivce_states:DUMP OF SERVICE device_policy:DUMP OF SERVICE devicestoragemonitor:DUMP OF SERVICE diskstats:DUMP OF SERVICE display:DUMP OF SERVICE dreams:DUMP OF SERVICE drm.drmManager:DUMP OF SERVICE dropbox:DUMP OF SERVICE entropy:DUMP OF SERVICE gesture_manager:DUMP OF SERVICE gfxinfo:DUMP OF SERVICE hardware:DUMP OF SERVICE input:DUMP OF SERVICE input_method:DUMP OF SERVICE iphonesubinfo:DUMP OF SERVICE isms:DUMP OF SERVICE location:DUMP OF SERVICE lock_settings:DUMP OF SERVICE media.audio_flinger:DUMP OF SERVICE media.audio_policy:DUMP OF SERVICE media.camera:DUMP OF SERVICE media.player:DUMP OF SERVICE media_router:DUMP OF SERVICE meizu.camera:DUMP OF SERVICE meminfo:DUMP OF SERVICE mount:DUMP OF SERVICE netpolicy:DUMP OF SERVICE netstats:DUMP OF SERVICE network_management:DUMP OF SERVICE nfc:DUMP OF SERVICE notification:DUMP OF SERVICE package:DUMP OF SERVICE permission:DUMP OF SERVICE phone:DUMP OF SERVICE phone_ext:DUMP OF SERVICE power:DUMP OF SERVICE pppoe:DUMP OF SERVICE print:DUMP OF SERVICE procstats:DUMP OF SERVICE samba_client:DUMP OF SERVICE samba_server:DUMP OF SERVICE samplingprofiler:DUMP OF SERVICE scheduling_policy:DUMP OF SERVICE search:DUMP OF SERVICE secloader:DUMP OF SERVICE secloader2:DUMP OF SERVICE secsystemserver:DUMP OF SERVICE sensorservice:DUMP OF SERVICE serial:DUMP OF SERVICE servicediscovery:DUMP OF SERVICE simphonebook:DUMP OF SERVICE sip:DUMP OF SERVICE statusbar:DUMP OF SERVICE telephony.registry:DUMP OF SERVICE textservices:DUMP OF SERVICE uimode:DUMP OF SERVICE updatelock:DUMP OF SERVICE usagestats:DUMP OF SERVICE usb:DUMP OF SERVICE user:DUMP OF SERVICE vibrator:DUMP OF SERVICE voicesense:DUMP OF SERVICE wallpaper:DUMP OF SERVICE wifi:DUMP OF SERVICE wifip2p:DUMP OF SERVICE window:
2、详细命令怎样查看帮助
从上面能够看出能够查看的Service许多,“DUMP OF SERVICE”keyword后面的单词都能够直接通过 dumpsys + 单词 查看相关信息,详细每个怎样使用有一种通用的查看帮助的办法。
查看每个命令的使用帮助,下面以activity为例演示:adb shell dumpsys activity -hActivity manager dump options: [-a] [-c] [-h] [cmd] ... cmd may be one of: a[ctivities]: activity stack state b[roadcasts] [PACKAGE_NAME] [history [-s]]: broadcast state i[ntents] [PACKAGE_NAME]: pending intent state p[rocesses] [PACKAGE_NAME]: process state o[om]: out of memory management prov[iders] [COMP_SPEC ...]: content provider state provider [COMP_SPEC]: provider client-side state s[ervices] [COMP_SPEC ...]: service state 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 cmd may also be a COMP_SPEC to dump activities. COMP_SPEC may be a component name (com.foo/.myApp), a partial substring in a component name, a hex object identifier. -a: include all available server state. -c: include client state.这样就能够清楚每一个命名的用法以及相应输出内容的信息查看方法。
3、一些经常使用命令解释
adb shell dumpsys activity: 显示activity的相关信息,包含任务栈等;
adb shell dumpsys SurfaceFlinger: 查看UI绘制的各个层级信息 adb shell dumpsys window: 显示键盘,窗体和它们的关系 adb shell dumpsys statusbar: 显示状态栏相关信息 adb shell dumpsys usagestats: 每一个应用的启动次数和时间 adb shell dumpsys battery: 电池信息 adb shell dumpsys diskstats: 磁盘相关信息 adb shell dumpsys alarm: 显示Alarm信息 adb shell dumpsys wifi: 显示wifi信息4、參考资料:
http://www.open-open.com/lib/view/open1405061994872.html
https://source.android.com/devices/tech/input/dumpsys.html