Merge pull request #580 from LmeSzinc/dev

Bug fix
This commit is contained in:
LmeSzinc 2024-07-19 15:38:32 +08:00 committed by GitHub
commit e2d44fa989
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 5 deletions

View File

@ -15,8 +15,7 @@ from module.base.decorator import Config, cached_property, del_cached_property,
from module.base.utils import SelectedGrids, ensure_time
from module.device.connection_attr import ConnectionAttr
from module.device.env import IS_LINUX, IS_MACINTOSH, IS_WINDOWS
from module.device.method.utils import (
PackageNotInstalled, RETRY_TRIES, get_serial_pair, handle_adb_error,
from module.device.method.utils import (PackageNotInstalled, RETRY_TRIES, get_serial_pair, handle_adb_error,
possible_reasons, random_port, recv_all, remove_shell_warning, retry_sleep)
from module.exception import EmulatorNotRunningError, RequestHumanTakeover
from module.logger import logger

View File

@ -7,6 +7,7 @@ from adbutils import AdbClient, AdbDevice
from module.base.decorator import cached_property
from module.config.config import AzurLaneConfig
from module.device.method.utils import get_serial_pair
from module.exception import RequestHumanTakeover
from module.logger import logger
@ -127,8 +128,11 @@ class ConnectionAttr:
@cached_property
def port(self) -> int:
port_serial, _ = get_serial_pair(self.serial)
if port_serial is None:
port_serial = self.serial
try:
return int(self.serial.split(':')[1])
return int(port_serial.split(':')[1])
except (IndexError, ValueError):
return 0
@ -147,6 +151,10 @@ class ConnectionAttr:
def is_nox_family(self):
return 62001 <= self.port <= 63025
@cached_property
def is_vmos(self):
return 5667 <= self.port <= 5699
@cached_property
def is_emulator(self):
return self.serial.startswith('emulator-') or self.serial.startswith('127.0.0.1:')

View File

@ -3,6 +3,7 @@ import itertools
from lxml import etree
from module.device.env import IS_WINDOWS
# Patch pkg_resources before importing adbutils and uiautomator2
from module.device.pkg_resources import get_distribution
@ -86,7 +87,7 @@ class Device(Screenshot, Control, AppControl):
raise
# Auto-fill emulator info
if self.config.EmulatorInfo_Emulator == 'auto':
if IS_WINDOWS and self.config.EmulatorInfo_Emulator == 'auto':
_ = self.emulator_instance
# SRC only, use nemu_ipc if available
@ -138,6 +139,10 @@ class Device(Screenshot, Control, AppControl):
# if self.config.Emulator_ScreenshotMethod != 'nemu_ipc' and self.config.Emulator_ControlMethod == 'nemu_ipc':
# logger.warning('When not using nemu_ipc, both screenshot and control should not use nemu_ipc')
# self.config.Emulator_ControlMethod = 'minitouch'
# Allow Hermit on VMOS only
if self.config.Emulator_ControlMethod == 'Hermit' and not self.is_vmos:
logger.warning('ControlMethod is allowed on VMOS only')
self.config.Emulator_ControlMethod = 'minitouch'
pass
def screenshot(self):

View File

@ -52,6 +52,7 @@ class Fuel(UI):
continue
self._fuel_wait_leave()
self.interval_reset([POPUP_CONFIRM, POPUP_CANCEL], interval=2)
def _fuel_cancel(self, skip_first_screenshot=True):
"""
@ -75,6 +76,7 @@ class Fuel(UI):
continue
self._fuel_wait_leave()
self.interval_reset([POPUP_CONFIRM, POPUP_CANCEL], interval=2)
def _fuel_wait_leave(self):
# Blur disappears before popup
@ -189,6 +191,7 @@ class Fuel(UI):
if use <= 0:
logger.info("Fuel remain is under the reserve threshold, stop using fuel")
self._fuel_cancel()
return False
skip_first_screenshot = True
while 1: