[转载] Android中adb shell dumpsys相关命令

很多时候,我们也会时不时的使用adb shell dumpsys相关命令,比如: 
查看Activity的相关信息(输入包名则查看具体包名的Activity信息):

adb shell dumpsys activity [包名]
  • 1

查看battery相关信息(输入包名则查看具体包名的battery信息):

adb shell dumpsys batterystats [包名]
  • 1

查看Location相关信息:

adb shell dumpsys location
  • 1

然而其中的意义,或许很多人都不知道,我就是其中之一. 
这里写图片描述

其实, adb shell dumpsys命令是用于打印出当前系统信息(更切确的说是dumpsys命令,因为adb shell只是为了进入手机或模拟器的shell内核,使其能够执行dumpsys命令),可以在命令后面加指定的service name(比如activity,location),如果不加则默认打印出设备中所有service的信息. 
在adb shell dumpsys后面可添加的service name可通过adb shell dumpsysadb shell service list方法获取. 
1.adb shell dumpsys 
输出信息的开始部分就是所有运行的service,如下:

Currently running services:
  DmAgent
  DockObserver
  GuiExtService
  IIccPhoneBookMz
  NvRAMAgent
  PPLAgent
  SurfaceFlinger
  access_control
  accessibility
  account
  activity
  alarm
  alphame_server
  android.security.keystore
  anrmanager
  appops
  appwidget
  audio
  backup
  battery
  batteryproperties
  batterystats
  bluetooth_manager
  clipboard
  commontime_management
  connectivity
  consumer_ir
  content
  country_detector
  cpuinfo
  dbinfo
  device_control
  device_policy
  device_states
  devicestoragemonitor
  diskstats
  display
  dreams
  drm.drmManager
  dropbox
  entropy
  fingerprint
  fingerprints_service
  flyme_error_report_manager
  flyme_novccusagestats
  flyme_packagemanager
  flyme_permission
  flyme_splitmode
  flyme_statusbar
  flyme_theme_service
  flyme_wallpaper
  gesture_manager
  gfxinfo
  hardware
  hips_service
  imms
  input
  input_method
  iphonesubinfo
  isms
  isub
  jobscheduler
  launcherapps
  location
  lock_settings
  media.audio_flinger
  media.audio_policy
  media.camera
  media.mmsdk
  media.player
  media.sound_trigger_hw
  media_projection
  media_router
  media_session
  meizu.camera
  meminfo
  memory_dumper
  mobile
  mount
  move_window
  mtk-perfservice
  mtk.codecservice
  netpolicy
  netstats
  network_management
  network_score
  networkmanagement_service_flyme
  notification
  package
  permission
  phone
  phoneEx
  phone_ext
  power
  pppoe
  print
  procstats
  program_binary
  recovery
  restrictions
  rttmanager
  samba_client
  samba_server
  samplingprofiler
  scheduling_policy
  search
  search_engine
  sensorservice
  serial
  servicediscovery
  simphonebook
  sip
  statusbar
  telecom
  telephony.registry
  textservices
  trust
  uimode
  updatelock
  usagestats
  usb
  user
  vibrator
  voiceinteraction
  wallpaper
  webviewupdate
  wifi
  wifip2p
  wifiscanner
  window
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131

2.adb shell service list 
输出结果如下:

Found 130 services:
0   flyme_novccusagestats: [android.nonvccUsageStats.INonVccStatsInterfaces]
1   sip: [android.net.sip.ISipService]
2   telecom: [com.android.internal.telecom.ITelecomService]
3   phone_ext: [android.telephony.ITelephonyExt]
4   phoneEx: [com.mediatek.internal.telephony.ITelephonyEx]
5   phone: [com.android.internal.telephony.ITelephony]
6   IIccPhoneBookMz: [com.android.internal.telephony.meizu.IIccPhoneBookMz]
7   isms: [com.android.internal.telephony.ISms]
8   iphonesubinfo: [com.android.internal.telephony.IPhoneSubInfo]
9   simphonebook: [com.android.internal.telephony.IIccPhoneBook]
10  fingerprints_service: [com.fingerprints.service.IFingerprintService]
11  isub: [com.android.internal.telephony.ISub]
12  alphame_server: [com.meizu.common.alphame.IAlphaMe]
13  flyme_splitmode: [meizu.splitmode.IFlymeSplitModeService]
14  flyme_packagemanager: [android.content.pm.IFlymePackageManager]
15  flyme_wallpaper: [meizu.wallpaper.IFlymeWallpaper]
16  device_states: [meizu.os.IDeviceStateService]
17  flyme_theme_service: [android.content.res.flymetheme.IFlymeThemeManager]
18  hips_service: [meizu.hips.IFlymeHipsService]
19  flyme_permission: [meizu.security.IFlymePermissionService]
20  device_control: [meizu.os.IDeviceControlService]
21  gesture_manager: [android.view.IGestureManager]
22  access_control: [meizu.security.IAccessControlManager]
23  move_window: [meizu.view.IMoveWindow]
24  imms: [com.android.internal.telephony.IMms]
25  media_projection: [android.media.projection.IMediaProjectionManager]
26  mtk-perfservice: [com.mediatek.perfservice.IPerfService]
27  launcherapps: [android.content.pm.ILauncherApps]
28  fingerprint: [android.service.fingerprint.IFingerprintService]
29  trust: [android.app.trust.ITrustManager]
30  media_router: [android.media.IMediaRouterService]
31  media_session: [android.media.session.ISessionManager]
32  restrictions: [android.content.IRestrictionsManager]
33  print: [android.print.IPrintManager]
34  dreams: [android.service.dreams.IDreamManager]
35  commontime_management: []
36  samplingprofiler: []
37  diskstats: []
38  voiceinteraction: [com.android.internal.app.IVoiceInteractionManagerService]
39  appwidget: [com.android.internal.appwidget.IAppWidgetService]
40  backup: [android.app.backup.IBackupManager]
41  jobscheduler: [android.app.job.IJobScheduler]
42  uimode: [android.app.IUiModeManager]
43  serial: [android.hardware.ISerialManager]
44  usb: [android.hardware.usb.IUsbManager]
45  DockObserver: []
46  audio: [android.media.IAudioService]
47  wallpaper: [android.app.IWallpaperManager]
48  dropbox: [com.android.internal.os.IDropBoxManagerService]
49  search_engine: [com.mediatek.search.ISearchEngineManagerService]
50  search: [android.app.ISearchManager]
51  country_detector: [android.location.ICountryDetector]
52  location: [android.location.ILocationManager]
53  devicestoragemonitor: []
54  notification: [android.app.INotificationManager]
55  updatelock: [android.os.IUpdateLock]
56  servicediscovery: [android.net.nsd.INsdManager]
57  samba_client: [meizu.samba.client.ISambaClientManager]
58  samba_server: [meizu.samba.server.ISambaServerManager]
59  pppoe: [android.net.pppoe.IPppoeManager]
60  connectivity: [android.net.IConnectivityManager]
61  rttmanager: [android.net.wifi.IRttManager]
62  wifiscanner: [android.net.wifi.IWifiScanner]
63  wifi: [android.net.wifi.IWifiManager]
64  wifip2p: [android.net.wifi.p2p.IWifiP2pManager]
65  netpolicy: [android.net.INetworkPolicyManager]
66  netstats: [android.net.INetworkStatsService]
67  network_score: [android.net.INetworkScoreService]
68  textservices: [com.android.internal.textservice.ITextServicesManager]
69  networkmanagement_service_flyme: [android.os.INetworkManagementServiceFlyme]
70  network_management: [android.os.INetworkManagementService]
71  clipboard: [android.content.IClipboard]
72  flyme_statusbar: [meizu.statusbar.IFlymeStatusBarService]
73  statusbar: [com.android.internal.statusbar.IStatusBarService]
74  device_policy: [android.app.admin.IDevicePolicyManager]
75  lock_settings: [com.android.internal.widget.ILockSettings]
76  mount: [IMountService]
77  accessibility: [android.view.accessibility.IAccessibilityManager]
78  input_method: [com.android.internal.view.IInputMethodManager]
79  bluetooth_manager: [android.bluetooth.IBluetoothManager]
80  input: [android.hardware.input.IInputManager]
81  window: [android.view.IWindowManager]
82  alarm: [android.app.IAlarmManager]
83  consumer_ir: [android.hardware.IConsumerIrService]
84  vibrator: [android.os.IVibratorService]
85  mobile: [com.mediatek.common.mom.IMobileManagerService]
86  content: [android.content.IContentService]
87  account: [android.accounts.IAccountManager]
88  entropy: []
89  telephony.registry: [com.android.internal.telephony.ITelephonyRegistry]
90  scheduling_policy: [android.os.ISchedulingPolicyService]
91  webviewupdate: [android.webkit.IWebViewUpdateService]
92  usagestats: [android.app.usage.IUsageStatsManager]
93  battery: []
94  hardware: [android.os.IHardwareService]
95  flyme_error_report_manager: [android.app.IFlymeErrorReportManager]
96  anrmanager: [android.app.IANRManager]
97  permission: [android.os.IPermissionController]
98  cpuinfo: []
99  dbinfo: []
100 gfxinfo: []
101 meminfo: []
102 procstats: [com.android.internal.app.IProcessStats]
103 activity: [android.app.IActivityManager]
104 user: [android.os.IUserManager]
105 package: [android.content.pm.IPackageManager]
106 media.mmsdk: [com.mediatek.mmsdk.IMMSdkService]
107 media.sound_trigger_hw: [android.hardware.ISoundTriggerHwService]
108 media.audio_policy: [android.media.IAudioPolicyService]
109 media.camera: [android.hardware.ICameraService]
110 recovery: [com.mediatek.recovery.IRecoveryManagerService]
111 display: [android.hardware.display.IDisplayManager]
112 power: [android.os.IPowerManager]
113 appops: [com.android.internal.app.IAppOpsService]
114 batterystats: [com.android.internal.app.IBatteryStats]
115 sensorservice: [android.gui.SensorServer]
116 meizu.camera: [meizu.camera.ICameraService]
117 memory_dumper: [android.memory.IMemoryDumper]
118 media.player: [android.media.IMediaPlayerService]
119 SurfaceFlinger: [android.ui.ISurfaceComposer]
120 drm.drmManager: [drm.IDrmManagerService]
121 media.audio_flinger: [android.media.IAudioFlinger]
122 batteryproperties: [android.os.IBatteryPropertiesRegistrar]
123 program_binary: []
124 mtk.codecservice: []
125 GuiExtService: [GuiExtService]
126 android.security.keystore: [android.security.keystore]
127 NvRAMAgent: [NvRAMAgent]
128 DmAgent: []
129 PPLAgent: []
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131

通过以上两个方法查询到运行的system service后,就可以在dumpsys后面加上service的名字,查看指定的service信息。

// 查看Activity相关信息
adb shell dumpsys activity
// 查看CPU相关信息
adb shell dumpsys cpuinfo
// 查看电池使用信息
adb shell dumpsys battery
//查看Window的相关信息,最后部分可以看到分辨率的信息
adb shell dumpsys window
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

有些service能够接收额外的参数,我们可以使用-h查看帮助信息。

// 查看package这个service的帮助信息
adb shell dumpsys package -h
// 查看activity这个service的帮助信息
adb shell dumpsys activity -h
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值