Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android dumpsys命令的使用

Android dumpsys命令的使用

編輯:關於Android編程

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”關鍵字後面的單詞都可以直接通過 dumpsys + 單詞 查看相關信息,具體每一個如何使用有一種通用的查看幫助的辦法。
查看每一個命令的使用幫助,以下以activity為例演示:

adb shell dumpsys activity -h

Activity 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

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved