Keywords: Android | ADB | dumpsys | system_debugging | performance_monitoring
Abstract: This paper provides an in-depth exploration of the dumpsys tool in Android ADB shell, detailing its core functionalities, system service monitoring capabilities, and practical application scenarios. By analyzing critical system data including battery status, Wi-Fi information, CPU usage, and memory statistics, the article demonstrates the significant role of dumpsys in Android development and debugging. Complete command lists and specific operation examples are provided to help developers efficiently utilize this system diagnostic tool for performance optimization and issue troubleshooting.
Overview of dumpsys Tool
dumpsys is a powerful diagnostic tool running on Android devices, specifically designed to output status information of system services. This tool provides rich system data in string format, offering crucial evidence for developers to analyze and optimize application performance.
Core Functions and Advantages
The primary value of dumpsys manifests in several aspects: firstly, it can obtain complex system information in concise string format, significantly simplifying the data collection process. Secondly, by extracting key metrics such as CPU usage, memory occupancy, battery status, and storage statistics, developers can generate visual charts to precisely assess the impact of their applications on overall device performance.
Complete System Service Commands
To obtain the complete list of subsystem services supported by dumpsys, execute the following command:
dumpsys | grep "DUMP OF SERVICE"
This command outputs the comprehensive service inventory, including:
- SurfaceFlinger: Graphics composition service
- accessibility: Accessibility services
- account: Account management service
- activity: Activity manager
- alarm: Alarm service
- audio: Audio services
- battery: Battery service
- cpuinfo: CPU information
- meminfo: Memory information
- wifi: Wireless network service
- window: Window manager
Practical Command Examples and Output Analysis
Battery Status Monitoring
Obtain complete battery statistics:
adb shell dumpsys battery
Typical output includes:
Current Battery Service state:
AC powered: false
USB powered: true
status: 5
health: 2
level: 100
scale: 100
voltage: 4201
temperature: 271
technology: Li-poly
The temperature field displays battery temperature, while the technology field indicates battery technology type.
Wireless Network Information Retrieval
Query Wi-Fi connection status and configuration:
adb shell dumpsys wifi
Output information covers:
Wi-Fi is enabled
SSID: XXXXXXX
BSSID: xx:xx:xx:xx:xx:xx
MAC: xx:xx:xx:xx:xx:xx
Supplicant state: COMPLETED
RSSI: -60
Link speed: 54
ipaddr 192.168.1.xxx
This data is crucial for network connection故障诊断 and performance optimization.
CPU Usage Analysis
Monitor system CPU load and process resource consumption:
adb shell dumpsys cpuinfo
Output example:
Load: 0.08 / 0.4 / 0.64
CPU usage from 42816ms to 34683ms ago:
system_server: 1% = 1% user + 0% kernel / faults: 16 minor
TOTAL: 6% = 1% user + 3% kernel + 0% irq
This information helps identify CPU-intensive processes and system load conditions.
Memory Usage Statistics
View memory occupancy of specific applications:
adb shell dumpsys meminfo 'your apps package name'
Detailed output includes:
** 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
(Pss): 532 80 2479 3091
(shared dirty): 932 2004 6060 8996
(priv dirty): 512 36 1872 2420
To view memory information for all processes, use:
adb shell dumpsys meminfo
Advanced Usage Techniques
Many dumpsys subcommands support -help parameter for detailed usage instructions:
adb shell dumpsys activity -h
adb shell dumpsys window -h
adb shell dumpsys meminfo -h
Available service lists can be obtained through service command:
adb shell service -l
Permission Requirements and Best Practices
Using dumpsys tool requires adding corresponding permissions in AndroidManifest.xml:
<uses-permission android:name="android.permission.DUMP" />
Developers are advised to systematically test various dumpsys commands, deeply understand the status information of each system service, thereby comprehensively enhancing application debugging and performance optimization capabilities.