From d48427abb21825c651d0abc8bced21b2fc1cfe34 Mon Sep 17 00:00:00 2001 From: YoursFunny Date: Sun, 5 Jul 2026 18:49:35 +0800 Subject: [PATCH] refactor: cache `nemud.app_keep_alive` --- module/device/connection.py | 9 +++++++-- module/device/connection_attr.py | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/module/device/connection.py b/module/device/connection.py index e72b687..241c0aa 100644 --- a/module/device/connection.py +++ b/module/device/connection.py @@ -271,15 +271,20 @@ class Connection(ConnectionAttr): return True return False + @cached_property + def nemud_app_keep_alive(self) -> str: + res = self.adb_getprop('nemud.app_keep_alive') + return res + @retry def check_mumu_app_keep_alive(self): if not self.is_mumu_family: return False - res = self.adb_getprop('nemud.app_keep_alive') + res = self.nemud_app_keep_alive logger.attr('nemud.app_keep_alive', res) if res == '': - # Empry property, might not be a mumu emulator or might be an old mumu + # Empty property, probably MuMu6 or MuMu12 version < 3.5.6 return True elif res == 'false': # Disabled diff --git a/module/device/connection_attr.py b/module/device/connection_attr.py index cfa78a9..6bf50f6 100644 --- a/module/device/connection_attr.py +++ b/module/device/connection_attr.py @@ -7,7 +7,6 @@ from adbutils import AdbClient, AdbDevice from module.base.decorator import cached_property from module.config.config import AzurLaneConfig -from module.config.utils import deep_iter from module.exception import RequestHumanTakeover from module.logger import logger @@ -127,7 +126,12 @@ class ConnectionAttr: def is_mumu_family(self): # 127.0.0.1:7555 # 127.0.0.1:16384 + 32*n - return self.serial == '127.0.0.1:7555' or self.serial.startswith('127.0.0.1:16') + return self.serial == '127.0.0.1:7555' or self.is_mumu12_family + + @cached_property + def is_mumu12_family(self): + # 127.0.0.1:16384 + 32*n + return len(self.serial) == 15 and self.serial.startswith('127.0.0.1:16') @cached_property def is_emulator(self):