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:
@@ -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.
|
||||
|
||||
|
Reference in New Issue
Block a user