欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Android中adb shell dumpsys相关命令

程序员文章站 2024-02-29 19:23:28
...

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

adb shell dumpsys activity [包名]

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

adb shell dumpsys batterystats [包名]

查看Location相关信息:

adb shell dumpsys location

然而其中的意义,或许很多人都不知道,我就是其中之一.
Android中adb shell dumpsys相关命令

其实, 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

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: []

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

// 查看Activity相关信息
adb shell dumpsys activity
// 查看CPU相关信息
adb shell dumpsys cpuinfo
// 查看电池使用信息
adb shell dumpsys battery
//查看Window的相关信息,最后部分可以看到分辨率的信息
adb shell dumpsys window

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

// 查看package这个service的帮助信息
adb shell dumpsys package -h
// 查看activity这个service的帮助信息
adb shell dumpsys activity -h

参考

adb shell dumpsys的使用