From c9edcd0a40a5be6bbe3ccc7c31a823b7e6ecfbbf Mon Sep 17 00:00:00 2001 From: YoursFunny Date: Mon, 6 Jul 2026 01:50:17 +0800 Subject: [PATCH] fix: allow Hermit on VMOS only --- module/device/connection_attr.py | 10 +++++++++- module/device/device.py | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/module/device/connection_attr.py b/module/device/connection_attr.py index 278c267..992786a 100644 --- a/module/device/connection_attr.py +++ b/module/device/connection_attr.py @@ -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 @@ -128,8 +129,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 @@ -148,6 +152,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:') diff --git a/module/device/device.py b/module/device/device.py index 1e336d3..11d8d13 100644 --- a/module/device/device.py +++ b/module/device/device.py @@ -137,6 +137,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):