1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-04-03 00:41:13 +08:00

Feat: Restart emulator on its network disconnection

This commit is contained in:
positnuec
2026-03-30 21:38:28 +08:00
parent 8a7c9f3115
commit bf03867f0b
4 changed files with 51 additions and 7 deletions

View File

@@ -433,3 +433,20 @@ class Adb(Connection):
# Parse with lxml
hierarchy = etree.fromstring(content)
return hierarchy
@retry
def is_network_available(self) -> bool:
"""
Check if emulator internet connection is available by pinging public DNS.
Returns:
bool: True if network is available
"""
options = ['-c', '4']
if self.is_mumu12_family:
options.extend(['-i', '0.2'])
for ip in ['223.5.5.5', '8.8.8.8']:
result = self.adb_shell(['ping', *options, ip]).lower()
if 'ttl=' in result:
return True
return False