mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-27 16:45:37 +08:00
Fix: Disconnect offline device before connecting
This commit is contained in:
@@ -459,9 +459,24 @@ class Connection(ConnectionAttr):
|
|||||||
Returns:
|
Returns:
|
||||||
bool: If success
|
bool: If success
|
||||||
"""
|
"""
|
||||||
|
# Skip for emulator-5554
|
||||||
if 'emulator' in serial:
|
if 'emulator' in serial:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# Disconnect offline device before connecting
|
||||||
|
device = self.list_device().select(serial=serial).first_or_none()
|
||||||
|
if device:
|
||||||
|
if device.status == 'offline':
|
||||||
|
logger.warning(f'Device {serial} is offline, disconnect it before connecting')
|
||||||
|
self.adb_disconnect(serial)
|
||||||
|
elif device.status == 'unauthorized':
|
||||||
|
logger.error(f'Device {serial} is unauthorized, please accept ADB debugging on your device')
|
||||||
|
elif device.status == 'device':
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
|
logger.error(f'Device {serial} is is having a unknown status: {device.status}')
|
||||||
|
|
||||||
|
# Try to connect
|
||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
msg = self.adb_client.connect(serial)
|
msg = self.adb_client.connect(serial)
|
||||||
logger.info(msg)
|
logger.info(msg)
|
||||||
@@ -480,6 +495,8 @@ class Connection(ConnectionAttr):
|
|||||||
logger.info(msg)
|
logger.info(msg)
|
||||||
logger.warning('No such device exists, please restart the emulator or set a correct serial')
|
logger.warning('No such device exists, please restart the emulator or set a correct serial')
|
||||||
raise EmulatorNotRunningError
|
raise EmulatorNotRunningError
|
||||||
|
|
||||||
|
# Failed to connect
|
||||||
logger.warning(f'Failed to connect {serial} after 3 trial, assume connected')
|
logger.warning(f'Failed to connect {serial} after 3 trial, assume connected')
|
||||||
self.detect_device()
|
self.detect_device()
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user