Preface

Dumpsys is a tool to gather various information from Android device and tell you its system status. All you have to do is to execute a command – "adb shell dumpsys" on your computer with J2SDK and Android SDK.  Let’s take a look on it.

Description

After executing the command of "adb shell dumpsys", there’re various service messages are outputted as follows. (In this case, I used an Android device to depict how to get the information and what they stand for.)

 
Currently running services:

  accessibility

  account

  activity

  alarm

  apn_settings_policy

  application_policy

  appwidget

  audio

  backup

  battery

  batteryinfo

  bluetooth

  bluetooth_a2dp

  bluetooth_avrcp

  bluetooth_policy

  browser_policy

  clipboard

  clipboardEx

  connectivity

  content

  country_detector

  cpuinfo

  CustomFrequencyManagerService

  date_time_policy

  device_info

  device_policy

  devicestoragemonitor

  DirEncryptService

  diskstats

  drm.drmManager

  dropbox

  eas_account_policy

  email_account_policy

  enterprise_policy

  enterprise_vpn_policy

  entropy

  firewall_policy

  FMPlayer

  gfxinfo

  hardware

  input_method

  iphonesubinfo

  isms

  location

  location_policy

  mdm.remotedesktop

  media.audio_flinger

  media.audio_policy

  media.camera

  media.player

  media.yamahaplayer

  meminfo

  mini_mode_app_manager

  misc_policy

  motion_recognition

  mount

  netpolicy

  netstats

  network_management

  notification

  package

  password_policy

  permission

  phone

  phone_restriction_policy

  phoneext

  power

  remoteinjection

  restriction_policy

  roaming_policy

  samplingprofiler

  search

  SecTVOutService

  security_policy

  sensorservice

  shutdownlogger

  simphonebook

  statusbar

  SurfaceFlinger

  telephony.registry

  textservices

  throttle

  tvoutservice

  TvoutService_C

  uimode

  usagestats

  usb

  vibrator

  voip

  vpn_policy

  wallpaper

  wifi

  wifi_policy

  wifip2p

  window

In above list, we see that there’re various functional services are running on Android device. When debug engineering is necessary, we could get a lot of useful information from dumpsys for debugging purpose. 

We’ve discussed the MonkeyRunner Control with Jython script in separate article. We can check the testing result by comparing image. However, we always hope to acquire more clues to point out the root cause of problem.

Typically, I illustrate two situations. First one is when the problem is caused by up layer (Framework layer or UI representation), but it’s work normally at lower layer ( E.g. driver). For instance, when trying to switch Bluetooth On, you may observe the icon on UI which remains Off state. But the driver of Bluetooth has been powered on. In another situation we can think about is oppositive to last case

Now we have another choice to make result more accurately. Fortunately, we can monitor both  system status by using parameter inspection from outputted information of dumpsys on Android device and UI comparison by using MonkeyRunner manner as the necessary testing criteria.  


Usage dumpsys [running_service_name]

In case nothing is followed by dumpsys, the dumpsys will output all the information of running services.


What information can be found in Dumpsys ?

Dumpsys outputs various message to depict system status of an Android device. Let’s talk about some frequent used messages. 

When you need power relative information, you can get them by following information.

Battery Information from Dumpsys

Execute the command of "adb shell dumpsys battery", you may see the following information.

Current Battery Service state:   AC powered: false   USB powered: true   status: 2   health: 2   present: true   level: 100   scale: 100   voltage:4191   temperature: 350   technology: Li-ion

From above information, you can get the information, including type of power source, battery capacity, measured battery voltage, measured temperature and so on.

The definitions of each parameter from battery information  are as follows,

AC powered:false (Power source) USB powered:true (Power source) status:5 (see next section) health:2 (see next section) present:true (indicating whether a battery is present.) level:100 (returns battery level as a percentage) scale:100 (maximum battery level) voltage: 4195 (an integer containing the current battery voltage level) temperature: 380 (an integer containing the current battery temperature) technology: Li-ion (technology of the current battery)

With respect to status in battery information, the definition of value is as follows, Defined in android.os.BatteryManager BATTERY_STATUS_UNKNOWN (0×00000001) BATTERY_STATUS_CHARGING (0×00000002) BATTERY_STATUS_DISCHARGING (0×00000003) BATTERY_STATUS_NOT_CHARGING (0×00000004) BATTERY_STATUS_FULL (0×00000005)

With respect to health in battery information, the definition of value is as follows, Defined in android.os.BatteryManager BATTERY_HEALTH_UNKNOWN (0×00000001) BATTERY_HEALTH_GOOD (0×00000002) BATTERY_HEALTH_OVERHEAT (0×00000003) BATTERY_HEALTH_DEAD (0×00000004) BATTERY_HEALTH_OVER_VOLTAGE (0×00000005) BATTERY_HEALTH_UNSPECIFIED_FAILURE(0×00000006) BATTERY_HEALTH_COLD (0×00000007)

When you need to get the information from Bluetooth you can use following information.

Bluetooth Information from Dumpsys

Execute the command of "adb shell dumpsys bluetooth", you may see the following information.

DUMP OF SERVICE bluetooth:  mIsAirplaneSensitive = true  mIsAirplaneToggleable = true  Local address = 00:07:0B:16:23:AC  Local name = MyBTPhone  isDiscovering() = false

The definitions of Bluetooth information for each parameter are as follows,

Parameter Value Definition
mIsAirplaneSensitive true | false Airplane mode can prevent Bluetooth radio from being turned on
mIsAirplaneToggleable true | false Airplane mode can prevent Bluetooth radio from being turned on
Local name   Bluetooth device name
Local address   Bluetooth Address
isDiscovering true|false Discoverable for Bluetooth

The following information will tell you what the status for telecom is.


telephony.registry Information from Dumpsys

Execute the command of "adb shell dumpsys telephony.registry", you may see the following information.

DUMP OF SERVICE telephony.registry:

last known state:

  mCallState=0

  mCallIncomingNumber=

  mServiceState=0 home TTT TTT 46999  HSDPA:9 CSS not supported -1 -1 RoamInd=-1 DefRoamInd=-1 EmergOnly=false

  mSignalStrength=SignalStrength: 19 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 gsm|lte 4

  mMessageWaiting=false

  mCallForwarding=false

  mDataActivity=0

  mDataConnectionState=0

  mDataConnectionPossible=true

  mDataConnectionReason=dataDisabled

  mDataConnectionApn=

  mDataConnectionLinkProperties=null

  mDataConnectionLinkCapabilities=null

  mCellLocation=Bundle[mParcelledData.dataSize=76]

registrations: count=8

Note, the information telephony.registry provided is the last know state. It means it may not the state that device is running.

The definitions of telephony.registry information for each parameter are as follows,

Parameter Definition/Value
mCallState Call State
0 – CALL_STATE_IDLE(No activity.)
1 – CALL_STATE_RINGING
2 – CALL_STATE_OFFHOOK
mCallIncomingNumber Last incoming call number
mServiceState Radio service State
0 – STATE_IN_SERVICE(Normal operation condition, the phone is registered with an operator either in home network or in roaming. )
1 – STATE_OUT_OF_SERVICE (Phone is not registered with any operator, the phone can be currently searching a new operator to register to, or not searching to registration at all, or registration is denied, or radio signal is not available. )
2 – STATE_EMERGENCY_ONLY (The phone is registered and locked. Only emergency numbers are allowed. )
3 – STATE_POWER_OFF(Radio of telephony is explicitly powered off.)
SignalStrength Radio Signal Strength (RSSI)
mMessageWaiting Radio Message Waiting
true | false
mCallForwarding Radio Call Forwarding
true | false
mDataActivity 0 – Radio Data Call Activity: DATA_ACTIVITY_NONE(No traffic.)
1- DATA_ACTIVITY_IN(Currently receiving IP PPP traffic.)
2 – DATA_ACTIVITY_OUT(Currently sending IP PPP traffic.)
3 – DATA_ACTIVITY_INOUT(Currently both sending and receiving IP 
mDataConnectionState Radio Data Connection State
0 – DATA_DISCONNECTED (Disconnected. IP traffic not available. )
1- DATA_CONNECTING(Currently setting up a data connection.)
2 – DATA_CONNECTED (Connected. IP traffic should be available.)
3 – DATA_SUSPENDED (Suspended. The connection is up, but IP traffic is temporarily unavailable. For example, in a 2G network, data activity may be suspended when a voice call arrives.)
mActiveDataConnectionState Radio Data Connection State
0 – DATA_DISCONNECTED (Disconnected. IP traffic not available. )
1- DATA_CONNECTING(Currently setting up a data connection.)
2 – DATA_CONNECTED (Connected. IP traffic should be available.)
3 – DATA_SUSPENDED (Suspended. The connection is up, but IP traffic is temporarily unavailable. For example, in a 2G network, data activity may be suspended when a voice call arrives.)
mDataConnectionPossible Active Radio Data Connection
true | false
mDataConnectionReason Reason for data Connection
mDataConnectionApn APN Name
mDataConnectionInterfaceName Name of data connection interface
mCellLocation Information of Cell Location
registrations: count Recording count of registration




When you want to know the status of WiFi, you can refer to following information.






WiFi Information from Dumpsys

Execute the command of "adb shell dumpsys wifi", you may see the following information.


DUMP OF SERVICE wifi:

Wi-Fi is enabled

Stay-awake conditions: 0

Internal state:

current HSM state: ConnectedState

mLinkProperties InterfaceName: wlan0 LinkAddresses: [1.1.2.3/24 ] Routes: [0.0.0.0/0 -> 1.1.2.6,] DnsAddresses: [1.1.2.1,] HttpProxy: [ProxyProperties.mHost == null]

mWifiInfo SSID: Google, BSSID: 00:08:0a:02:03:08, MAC: 00:00:00:00:00:80, Supplicant state: COMPLETED, RSSI: -63, Link speed: 13, Net ID: 1, Explicit connect: true

mDhcpInfoInternal addr: 1.1.2.3/24 mRoutes: 0.0.0.0/0 -> 1.1.2.6 |  dns: 1.1.2.6, dhcpServer: 1.1.2.6 leaseDuration: 7200

mNetworkInfo NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason:(unspecified), extra: (none), roaming: false, failover: false, isAvailable: true

mLastSignalLevel 3

mLastBssid 00:00:00:00:00:00

mLastNetworkId 1

mReconnectCount 0

mIsScanMode false

Supplicant status

bssid=00:00:00:00:00:00

ssid=Google

id=1

mode=station

pairwise_cipher=CCMP

group_cipher=CCMP

key_mgmt=WPA2-PSK

wpa_state=COMPLETED

ip_address=1.1.2.3

address=00:00:00:00:00:00



The definitions of wifi information for each parameter are as follows,

Parameter Value Definition
Wi-Fi is  disabled|connected
enabled|disconnected
Wi-Fi Radio State
Stay-awake conditions   Stay-awake conditions value
Internal state   Internal state
interface   Netowrk Interface
runState   Run State
SSID   Wi-Fi AP’s SSID
BSSID   BSSID of Wi-Fi AP
MAC   MAC Address for Wi-Fi
Supplicant state   Supplicant state for Wi-Fi
RSSI   RSSI for Wi-Fi
Link speed   Link speed for Wi-Fi
Net ID   Net ID for Wi-Fi
ipaddr   Obtained IP Address for Wi-Fi
gateway   Gateway for Wi-Fi
netmask   Netmask for Wi-Fi
dns1   Primary DNS for WiFi
dns2   Secondary DNS for WiFi
DHCP server   DHCP address for WiFi
scanModeActive true | false Scan Mode Active for Wi-Fi
haveIpAddress true | false Have IP Address for Wi-Fi
obtainingIpAddress true | false Obtaining IpAddress for Wi-Fi
lastSignalLevel   Last Signal Level for Wi-Fi
explicitlyDisabled   Explicitly Disabled for Wi-Fi


There’re more information you can get from dumpsys for your purpose. Aforementioned has provided you a good start on how to get them. Now, it’s your turn.

When you want to know what network interface you are using, you can look at following information.


Connectivity Information from Dumpsys

Execute the command of "adb shell dumpsys connectivity", you may see the following information.

DUMP OF SERVICE connectivity:

NetworkInfo: type: mobile[UMTS], state: DISCONNECTED/DISCONNECTED, reason: dataDisabled, extra: vivi, roaming: false, failover: false, isAvailable: true

Mobile data state: DISCONNECTED

Data enabled: user=true, policy=true

Active network: WIFI

NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), roaming: false, failover: false, isAvailable: true

android.net.wifi.WifiStateTracker@00000000

The definitions of connectivity information for each parameter are as follows,

Parameter Value Definition
Active network WiFi | UMTS Check if Active Network is transmitted by WiFi or UMTS
NetworkInfo: type: mobile   NetworkInfo: type for mobile: HSDPA|UMTS
state UNKNOW / IDEL  Radio State
CONNECTED|CONNECTED
DISCONNECTED|DISCONNECTED
Extra   NetworkInfo: Carrier Name
roaming true | false Roaming state
failover true | false  
isAvailable true | false Check if Mobile network is available


How Jython and MonkeyRunner use these information to do automated testings ?

Using shell command in MonkeyRunner and executing dumpsys service_name, you can get the particular information from it and parse/filter those information by Jython Script. Hence, you can use these information for your testing or control purpose.


Reference Dumpsys,  http://source.android.com/tech/input/dumpsys.html

創作者介紹
創作者 shadow 的頭像
shadow

資訊園

shadow 發表在 痞客邦 留言(0) 人氣()