什么是 Android ADB shell“dumpsys”工具,它有什么好处?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11201659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What's the Android ADB shell "dumpsys" tool and what are its benefits?
提问by Vishwanath.M
I'm looking for the full list of ADB shell dumpsys
commands with a full explanation of all of the commands.
我正在寻找 ADB shelldumpsys
命令的完整列表以及所有命令的完整解释。
Where can I find this information?
我在哪里可以找到这些信息?
回答by K_Anas
What's dumpsys and what are its benefit
什么是 dumpsys 以及它的好处是什么
dumpsysis an android tool that runs on the device and dumps interesting information about the status of system services.
dumpsys是一个 android 工具,它运行在设备上并转储有关系统服务状态的有趣信息。
Obvious benefits:
明显的好处:
- Possibility to easily get system information in a simple string representation.
- Possibility to use dumped CPU, RAM, Battery, storage stats for a pretty charts, which will allow you to check how your application affects the overall device!
- 可以以简单的字符串表示轻松获取系统信息。
- 可以使用转储的 CPU、RAM、电池、存储统计数据以获得漂亮的图表,这将允许您检查您的应用程序如何影响整个设备!
What information can we retrieve from dumpsys shell command and how we can use it
我们可以从 dumpsys shell 命令中检索哪些信息以及我们如何使用它
If you run dumpsys you would see a ton of system information. But you can use only separate parts of this big dump.
如果您运行 dumpsys,您会看到大量的系统信息。但是您只能使用这个大转储的单独部分。
to see all of the "subcommands" of dumpsys do:
要查看 dumpsys 的所有“子命令”,请执行以下操作:
dumpsys | grep "DUMP OF SERVICE"
dumpsys | grep "DUMP OF SERVICE"
Output:
输出:
DUMP OF SERVICE SurfaceFlinger:
DUMP OF SERVICE accessibility:
DUMP OF SERVICE account:
DUMP OF SERVICE activity:
DUMP OF SERVICE alarm:
DUMP OF SERVICE appwidget:
DUMP OF SERVICE audio:
DUMP OF SERVICE backup:
DUMP OF SERVICE battery:
DUMP OF SERVICE batteryinfo:
DUMP OF SERVICE clipboard:
DUMP OF SERVICE connectivity:
DUMP OF SERVICE content:
DUMP OF SERVICE cpuinfo:
DUMP OF SERVICE device_policy:
DUMP OF SERVICE devicestoragemonitor:
DUMP OF SERVICE diskstats:
DUMP OF SERVICE dropbox:
DUMP OF SERVICE entropy:
DUMP OF SERVICE hardware:
DUMP OF SERVICE input_method:
DUMP OF SERVICE iphonesubinfo:
DUMP OF SERVICE isms:
DUMP OF SERVICE location:
DUMP OF SERVICE media.audio_flinger:
DUMP OF SERVICE media.audio_policy:
DUMP OF SERVICE media.player:
DUMP OF SERVICE meminfo:
DUMP OF SERVICE mount:
DUMP OF SERVICE netstat:
DUMP OF SERVICE network_management:
DUMP OF SERVICE notification:
DUMP OF SERVICE package:
DUMP OF SERVICE permission:
DUMP OF SERVICE phone:
DUMP OF SERVICE power:
DUMP OF SERVICE reboot:
DUMP OF SERVICE screenshot:
DUMP OF SERVICE search:
DUMP OF SERVICE sensor:
DUMP OF SERVICE simphonebook:
DUMP OF SERVICE statusbar:
DUMP OF SERVICE telephony.registry:
DUMP OF SERVICE throttle:
DUMP OF SERVICE usagestats:
DUMP OF SERVICE vibrator:
DUMP OF SERVICE wallpaper:
DUMP OF SERVICE wifi:
DUMP OF SERVICE window:
Some Dumping examples and output
一些转储示例和输出
1) Getting all possible battery statistic:
1) 获取所有可能的电池统计信息:
$~ adb shell dumpsys battery
You will get output:
你会得到输出:
Current Battery Service state:
AC powered: false
AC capacity: 500000
USB powered: true
status: 5
health: 2
present: true
level: 100
scale: 100
voltage:4201
temperature: 271 <---------- Battery temperature! %)
technology: Li-poly <---------- Battery technology! %)
2)Getting wifi informations
2)获取wifi信息
~$ adb shell dumpsys wifi
Output:
输出:
Wi-Fi is enabled
Stay-awake conditions: 3
Internal state:
interface tiwlan0 runState=Running
SSID: XXXXXXX BSSID: xx:xx:xx:xx:xx:xx, MAC: xx:xx:xx:xx:xx:xx, Supplicant state: COMPLETED, RSSI: -60, Link speed: 54, Net ID: 2, security: 0, idStr: null
ipaddr 192.168.1.xxx gateway 192.168.x.x netmask 255.255.255.0 dns1 192.168.x.x dns2 8.8.8.8 DHCP server 192.168.x.x lease 604800 seconds
haveIpAddress=true, obtainingIpAddress=false, scanModeActive=false
lastSignalLevel=2, explicitlyDisabled=false
Latest scan results:
Locks acquired: 28 full, 0 scan
Locks released: 28 full, 0 scan
Locks held:
3) Getting CPU info
3)获取CPU信息
~$ adb shell dumpsys cpuinfo
Output:
输出:
Load: 0.08 / 0.4 / 0.64
CPU usage from 42816ms to 34683ms ago:
system_server: 1% = 1% user + 0% kernel / faults: 16 minor
kdebuglog.sh: 0% = 0% user + 0% kernel / faults: 160 minor
tiwlan_wq: 0% = 0% user + 0% kernel
usb_mass_storag: 0% = 0% user + 0% kernel
pvr_workqueue: 0% = 0% user + 0% kernel
+sleep: 0% = 0% user + 0% kernel
+sleep: 0% = 0% user + 0% kernel
TOTAL: 6% = 1% user + 3% kernel + 0% irq
4)Getting memory usage informations
4)获取内存使用信息
~$ adb shell dumpsys meminfo 'your apps package name'
Output:
输出:
** MEMINFO in pid 5527 [com.sec.android.widgetapp.weatherclock] **
native dalvik other total
size: 2868 5767 N/A 8635
allocated: 2861 2891 N/A 5752
free: 6 2876 N/A 2882
(Pss): 532 80 2479 3091
(shared dirty): 932 2004 6060 8996
(priv dirty): 512 36 1872 2420
Objects
Views: 0 ViewRoots: 0
AppContexts: 0 Activities: 0
Assets: 3 AssetManagers: 3
Local Binders: 2 Proxy Binders: 8
Death Recipients: 0
OpenSSL Sockets: 0
SQL
heap: 0 MEMORY_USED: 0
PAGECACHE_OVERFLOW: 0 MALLOC_SIZE: 0
If you want see the info for all processes, use ~$ adb shell dumpsys meminfo
如果您想查看所有进程的信息,请使用 ~$ adb shell dumpsys meminfo
dumpsysis ultimately flexible and useful tool!
dumpsys最终是灵活且有用的工具!
If you want to use this tool do not forget to add permission into your android manifest automatically android.permission.DUMP
如果您想使用此工具,请不要忘记自动将权限添加到您的 android 清单中 android.permission.DUMP
Try to test all commands to learn more about dumpsys. Happy dumping!
尝试测试所有命令以了解有关 dumpsys 的更多信息。快乐倾销!
回答by Joe
Looking at the source code for dumpsysand service, you can get the list of services available by executing the following:
查看dumpsys和service的源代码,您可以通过执行以下命令获取可用服务列表:
adb shell service -l
You can then supply the service name you are interested in to dumpsys to get the specific information. For example (note that not all services provide dump info):
然后,您可以向 dumpsys 提供您感兴趣的服务名称以获取特定信息。例如(请注意,并非所有服务都提供转储信息):
adb shell dumpsys activity
adb shell dumpsys cpuinfo
adb shell dumpsys battery
As you can see in the code (and in K_Anas's answer), if you call dumpsys without any service name, it will dump the info on all services in one big dump:
正如您在代码(以及 K_Anas 的回答)中看到的,如果您在没有任何服务名称的情况下调用 dumpsys,它将在一个大转储中转储所有服务的信息:
adb shell dumpsys
Some services can receive additional arguments on what to show which normally is explained if you supplied a -h
argument, for example:
如果您提供了一个-h
参数,一些服务可以接收关于显示内容的附加参数,通常会被解释,例如:
adb shell dumpsys activity -h
adb shell dumpsys window -h
adb shell dumpsys meminfo -h
adb shell dumpsys package -h
adb shell dumpsys batteryinfo -h
回答by lujop
According to official Android information about dumpsys:
The dumpsystool runs on the device and provides information about the status of system services.
该dumpsys工具在设备上运行,并提供有关的系统服务的状态信息。
To get a list of available services use
要获取可用服务的列表,请使用
adb shell dumpsys -l
回答by Engin OZTURK
i use dumpsysto catch if app is crashed and process is still active. situation i used it is to find about remote machine app is crashed or not.
我使用dumpsys来捕捉应用程序是否崩溃并且进程是否仍然处于活动状态。我使用它的情况是查找有关远程机器应用程序是否崩溃的信息。
dumpsys | grep myapp | grep "Application Error"
or
或者
adb shell dumpsys | grep myapp | grep Error
or anything that helps...etc
或任何有助于...等的东西
if app is not running you will get nothing as result. When app is stoped messsage is shown on screen by android, process is still active and if you check via "ps" command or anything else, you will see process state is not showing any error or crash meaning. But when you click button to close message, app process will cleaned from process list. so catching crash state without any code in application is hard to find. but dumpsyshelps you.
如果应用程序未运行,您将一无所获。当应用程序停止时,android 在屏幕上显示消息,进程仍然处于活动状态,如果您通过“ ps”命令或其他任何检查,您将看到进程状态没有显示任何错误或崩溃的含义。但是当您单击按钮关闭消息时,应用程序进程将从进程列表中清除。因此很难找到在应用程序中没有任何代码的情况下捕获崩溃状态。但是dumpsys可以帮助您。