1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-09-08 14:22:35 +01:00

Add network connectivity check

Add a more general check that pings a network host rather than checking
the status of dumpsys wifi. This is because not all devices are
connected via wifi.
This commit is contained in:
John Richardson
2016-06-02 12:35:37 +01:00
parent 4bc8aab324
commit 69db2f2f41
7 changed files with 30 additions and 3 deletions

View File

@@ -649,9 +649,18 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
except KeyError:
return None
def is_wifi_connected(self):
self.logger.debug('Checking for wi-fi connectivity.')
return self.execute('dumpsys wifi| grep curState=ConnectedState')
def is_network_connected(self):
network_host = 'www.google.com'
self.logger.debug('Checking for internet connectivity.')
output = adb_shell(self.adb_name, 'ping -q -w 1 -c 1 {}'.format(network_host),
timeout=self.default_timeout)
if not 'unknown host' in output:
self.logger.debug('Found network host {}'.format(network_host))
return True
else:
self.logger.debug('Cannot find network host {}'.format(network_host))
return False
# Internal methods: do not use outside of the class.