Explore more with Android “adb shell dumpsys”

In this post I will be discussing about Android dumpsys command. What is dumpsys, why it is used, how to use it, etc.

Android dumpsys tool

What is Android dumpsys?

Android dumpsys is a tool build into the android os and provide lot of information about the status of the system service running on the device.

It is basically used for the development purpose and contains interesting informations. dumpsys command can be used from command line using Android debug bridge(ADB) to generate the detailed result of all the system services running on the connected device. With the help of this tool, you can inspect various things like RAM, input system, battery info, memory info etc.

Let’s see what all services can be dumped using the dumpsys tool.

View which services can be dumped using android dumpsys command

Different Android phone contains different dump services. To view the complete list of services supported by dumpsys, you can use the following command:

adb shell dumpsys -l

It will generate the output like this:

list dump services using android dumpsys tool
list dump services using android dumpsys tool

To view the list of system services running on your device, you can use the following command:

adb shell service list

It will generate the output like this:

list services using adb shell service list
list services using adb shell service list

Now, when you know the list of services that can be dumped, you can dump the details of the services that you want to specify. You can use the following command:

adb shell dumpsys 

For example to get the details of wifi service, you can use:

adb shell dumpsys wifi

Similarly you can get the details of other services as well like memory, storage, input, activity, etc.

# To get dump of input service use
adb shell dumpsys input
# To get the dump of memory information
adb shell dumpsys meminfo
# To get the dump of specific package
adb shell dumpsys package
e.g:
adb shell dumpsys package com.swetabh.checkprime

This will give the every bit of a details of the package like Scheme, list of activities it contains, list of actions it is registered for, what are the permissions  it has requested, what are the registered content providers, what is the signing keyset, etc.

dumpsys package command
dumpsys package command

In the above example I have used my own app, that has very limited information. You can try out by yourself, and check the information of any package that is installed on your device.

To see what all packages have been installed on your device, you can use this command:

adb shell pm list package 

Let’s see the dumpsys tool in action with some examples.

Use Android dumpsys to investigate wifi service

You can use the dumpsys tool to see what all information does wifi service contains. For this you have to use the below command:

adb shell dumpsys wifi

As this will dump all the information on the screen itself, it will better to write these information to a txt file.

adb shell dumpsys wifi > WifiDump.txt

 The output may varies depending on the version of your android OS used. The below section describes the type of information you will see. 

WifiController

WifiController manages the wifi states of our device for various modes such as normal, hotspot, airplane etc.

WifiController:
total records=61
rec[0]: time=09-26 05:09:56.840 processed=StaDisabledState org=StaDisabledState dest=<null> what=155655(0x26007)
rec[1]: time=09-26 12:37:52.088 processed=DefaultState org=StaDisabledState dest=StaDisabledState what=155657(0x26009)
rec[2]: time=09-26 12:37:52.556 processed=DefaultState org=StaDisabledState dest=<null> what=155657(0x26009)
rec[3]: time=09-26 12:41:41.712 processed=DefaultState org=StaDisabledState dest=StaDisabledState what=155657(0x26009)
. . .
curState=StaEnabledState
mPersistWifiState 1
mAirplaneModeOn false
mTxPkts 598
mRxPkts 434
mDataActivity 3
mRegisteredCallbacks 1

ActiveModeWarden

This class provides the implementation for different WiFi operating modes.

Dump of WifiActiveModeWarden
Current wifi mode: ClientModeActiveState
NumActiveModeManagers: 1
--Dump of ClientModeManager--
current StateMachine mode: StartedState
mClientInterfaceName: wlan0
mIfaceIsUp: true

WifiClientModeImpl

ClientModeImpl is responsible for handling event logic related to connectivity. Means whenever there is a change in connectivity, or get a response from server(in case of DHCP) all these things are handled here.

WifiClientModeImpl:
total records=4467
rec[0]: time=10-01 19:05:00.165 processed=ConnectModeState org=DisconnectedState dest= what=CMD_RESET_SIM_NETWORKS screen=on 1 0
rec[1]: time=10-01 19:05:00.165 processed=ConnectModeState org=DisconnectedState dest= what=CMD_RESET_SIM_NETWORKS screen=on 1 0
rec[2]: time=10-01 19:05:00.165 processed=ConnectModeState org=DisconnectedState dest= what=CMD_RESET_SIM_NETWORKS screen=on 1 0
rec[3]: time=10-01 19:05:00.165 processed=ConnectModeState org=DisconnectedState dest= what=CMD_RESET_SIM_NETWORKS screen=on 1 0
. . .
curState=ConnectedState
SupplicantStateTracker:
total records=10
rec[0]: time=09-27 09:50:16.239 processed=DefaultState org=UninitializedState dest=UninitializedState what=131183(0x2006f)
rec[1]: time=09-27 09:50:24.219 processed=DefaultState org=UninitializedState dest=HandshakeState what=147462(0x24006)
rec[2]: time=09-27 09:50:24.395 processed=DefaultState org=HandshakeState dest=CompletedState what=147462(0x24006)
. . .
curState=CompletedState
mAuthFailureInSupplicantBroadcast false
mAuthFailureReason 0
mNetworksDisabledDuringConnect false

mLinkProperties {InterfaceName: wlan0 LinkAddresses: [ fe80::2c17:46ff:fe8d:fd91/64,2409:4064:b8a:a8c3:2c17:46ff:fe8d:fd91/64,2409:4064:b8a:a8c3:bdbf:387a:f3bb:2f29/64,192.168.43.214/24 ] DnsAddresses: [ /2405:200:800::1,/192.168.43.1 ] Domains: null MTU: 0 TcpBufferSizes: 524288,1048576,2097152,262144,524288,1048576 Routes: [ fe80::/64 -> :: wlan0,::/0 -> fe80::5036:af8:32c2:ea55 wlan0,2409:4064:b8a:a8c3::/64 -> :: wlan0,192.168.43.0/24 -> 0.0.0.0 wlan0,0.0.0.0/0 -> 192.168.43.1 wlan0 ]}
mWifiInfo SSID: Redmi, BSSID: ac:c1:ee:9e:ff:d9, MAC: 2e:17:46:8d:fd:91, Supplicant state: COMPLETED, Wifi Generation: 4, TWT support: false, Eight Max VHT Spatial streams support: false, RSSI: -52, Link speed: 72Mbps, Tx Link speed: 72Mbps, Rx Link speed: 72Mbps, Frequency: 2412MHz, Net ID: 7, Metered hint: true, score: 60
mDhcpResults android.net.DhcpResults@14feda8 DHCP server /192.168.43.1 Vendor info ANDROID_METERED lease 3600 seconds Servername
mNetworkInfo [type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
mLastSignalLevel 4
mLastBssid ac:c1:ee:9e:ff:d9
mLastNetworkId 7
mOperationalMode 1
mUserWantsSuspendOpt true
mSuspendOptNeedsDisabled 4
mRevertCountryCodeOnCellularLoss: false
mDefaultCountryCode: IN
mDriverCountryCode: IN
mTelephonyCountryCode: IN
mTelephonyCountryTimestamp: 09-27 19:21:53.203
mDriverCountryTimestamp: 10-01 19:05:00.110
mReadyTimestamp: 10-01 19:05:04.749
mReady: false
{WifiNetworkFactory - mSerialNumber=5, ScoreFilter=60, Filter=[ Transports: WIFI Capabilities: NOT_METERED&INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN&NOT_ROAMING&NOT_CONGESTED LinkUpBandwidth>=1048576Kbps LinkDnBandwidth>=1048576Kbps Specifier: <android.net.MatchAllNetworkSpecifier@0>], requests=21, refCount=0}
{NetworkRequest [ REQUEST id=1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ], score=60, requested=true}
{NetworkRequest [ REQUEST id=6, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ], score=60, requested=true}

WifiConfigManager

This class provides APIs to manage configured wifi networks. It deals with maintaining the list of the configured network for quick access, saving the configuration when required, supports WifiManager public APIs for adding, removing or disabling any network.

Dump of WifiConfigManager
WifiConfigManager - Log Begin ----
2020-09-26T05:09:57.711 - clearInternalData: Clearing all internal data
2020-09-27T09:50:27.292 - setNetworkSelectionStatus: configKey="Realme 2"WPA_PSK networkStatus=NETWORK_SELECTION_ENABLED disableReason=NETWORK_SELECTION_ENABLE at=time=09-27 09:50:27.292
2020-10-01T19:05:23.796 - setNetworkSelectionStatus: configKey="Redmi"WPA_PSK networkStatus=NETWORK_SELECTION_ENABLED disableReason=NETWORK_SELECTION_ENABLE at=time=10-01 19:05:23.795
WifiConfigManager - Log End ----
WifiConfigManager - Configured networks Begin ----
ID: 0 SSID: "ANAND" PROVIDER-NAME: null BSSID: null FQDN: null PRIO: 0 HIDDEN: false PMF: false OWE Transition mode Iface: null
NetworkSelectionStatus NETWORK_SELECTION_ENABLED
hasEverConnected: true
numAssociation 1452
creation time=06-03 20:49:42.439
validatedInternetAccess trusted
macRandomizationSetting: 0
mRandomizedMacAddress: 26:14:b0:0a:0b:92
KeyMgmt: WPA_PSK Protocols: WPA RSN
AuthAlgorithms: OPEN
PairwiseCiphers: TKIP CCMP GCMP_256
GroupCiphers: WEP40 WEP104 TKIP CCMP GCMP_256
GroupMgmtCiphers:
SuiteBCiphers:
PSK/SAE: *
Enterprise config:

DPP config:
IP config:
IP assignment: DHCP
Proxy settings: NONE
cuid=1000 cname=android.uid.system:1000 luid=1000 lname=android.uid.system:1000 lcuid=1000 userApproved=USER_UNSPECIFIED noInternetAccessExpected=false
recentFailure: Association Rejection code: 0
ShareThisAp: false

ID: 1 SSID: "ZEWireless" PROVIDER-NAME: null BSSID: null FQDN: null PRIO: 0 HIDDEN: false PMF: false OWE Transition mode Iface: null
NetworkSelectionStatus NETWORK_SELECTION_ENABLED
hasEverConnected: true
numAssociation 1046
creation time=06-20 15:01:12.012
validatedInternetAccess trusted
macRandomizationSetting: 0
mRandomizedMacAddress: 1e:de:de:d7:c8:96
KeyMgmt: WPA_PSK Protocols: WPA RSN
AuthAlgorithms: OPEN
PairwiseCiphers: TKIP CCMP GCMP_256
GroupCiphers: WEP40 WEP104 TKIP CCMP GCMP_256
. . .
WifiConfigManager - Configured networks End ----
WifiConfigManager - Next network ID to be allocated 9
WifiConfigManager - Last selected network ID -1
WifiConfigManager - PNO scan frequency culling enabled = true
WifiConfigManager - PNO scan recency sorting enabled = true
Dump of WifiConfigStore
WifiConfigStore - Store Data Begin ----
StoreData => Name: NetworkList, File Id: 0, File Name: WifiConfigStore.xml
StoreData => Name: NetworkList, File Id: 1, File Name: WifiConfigStore.xml
StoreData => Name: DeletedEphemeralSSIDList, File Id: 1, File Name: WifiConfigStore.xml
StoreData => Name: MacAddressMap, File Id: 0, File Name: WifiConfigStore.xml
StoreData => Name: NetworkSuggestionMap, File Id: 2, File Name: WifiConfigStoreNetworkSuggestions.xml
StoreData => Name: PasspointConfigData, File Id: 1, File Name: WifiConfigStore.xml
StoreData => Name: PasspointConfigData, File Id: 0, File Name: WifiConfigStore.xml
StoreData => Name: OpenNetworkNotifierBlacklistConfigData, File Id: 1, File Name: WifiConfigStore.xml
StoreData => Name: CarrierNetworkNotifierBlacklistConfigData, File Id: 1, File Name: WifiConfigStore.xml
StoreData => Name: NetworkRequestMap, File Id: 1, File Name: WifiConfigStore.xml
StoreData => Name: WakeupConfigStoreData, File Id: 1, File Name: WifiConfigStore.xml
WifiConfigStore - Store Data End ----

There are many other information you will get from this service.

Use Android dumpsys to inspect Battery stats

Using the batterystats command in dumpsys tool will give you tons of information. This generates an interesting statistical data about battery usage on a device. You can check out by yourself what information this command generates.

adb shell dumpsys batterystats

Using the below command you can see how much battery consumption has been done for a particular app since last charge.

adb shell dumpsys batterystats --charged <package_name>
# For example
adb shell dumpsys batterystats --charged com.whatsapp

The above command will show the battery stats of Whatsapp. I suggest you to check out this command once, you will be amazed to see the result. To know more about the option used in batterystats see the dumpsys official documenation

You can even also use the battery command to see the current power stats of your mobile device.

adb shell dumpsys battery

Use Android dumpsys to inspect Activity usage

Specifying the activity command to dumpsys will generate the dump associated with ActivityManager.

Let’s see what all options you will get with the activity command.

adb shell dumpsys activity -h
activity manager dumpsys command help
activity manager dumpsys command help

If you look at the result of the above command, you will see there are much information you can get from it. Starting from the activity stack state to all the states related to a given package.

Let’s see some of the options in action.

adb shell dumpsys activity p com.whatsapp

This command will dump the process state of the package. That includes, the package’s UID, PID, process record of the package, package’s last activity time, etc. Similarly you can use the other commands like this.

# Lists all the broadcast stats of the app
adb shell dumpsys activity b com.whatsapp

# List all the pending intent state of the app
adb shell dumpsys activity i com.whatsapp

# List all the activity status of the app
adb shell dumpsys activity a com.whatsapp

# Get details of low memory killer on the device
adb shell dumpsys activity lmk

Additionally, when you know the PID of the app, you can get the GID(Group ID) of the process where it is located.

adb shell ps 30850
Result:
USER PID PPID VSZ RSS WCHAN ADDR S NAME
u0_a134 30850 3040 6620056 138320 0 0 S com.whatsapp

Here 30850 is the PID of WhatsApp application in my phone. This ID can vary from phone to phone. The dumpsys tool has many other options , you can explore these in the dumpsys developer documentation.

Conclusion

The dumpsys tool collects comprehensive statistics data about your app, device, services, etc since its start time, including frame rendering statistics. It is a developer tool and comes very much handy when analyzing bugs, to view relevant service information. If you like this post, please do share it on social media like Facebook or WhatsApp. If you have any suggestions or questions please do let me know in the comment section. Or if you want to know anything about any app or software for your own purpose, write us to support@gizmomind.com, and please like our Facebook page.

Swetabh

Swetabh is an Android Developer and a Tech enthusiast. His enthusiasm drives him to know about various technologies. Now he wanted to share his knowledge to other enthusiast who are passionate to know-how and become a GIZMOMIND.

Leave a Reply