From cd06f0b3e2f23e8ae40de9e33817a7097bdacd22 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Thu, 21 Mar 2024 19:04:49 +0800 Subject: [PATCH] Fix: [ALAS] Enhance auto device detection, ignore 127.0.0.1:7555 from MuMu 12 --- module/device/connection.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/module/device/connection.py b/module/device/connection.py index f62149b4c..e84c66946 100644 --- a/module/device/connection.py +++ b/module/device/connection.py @@ -84,6 +84,11 @@ class AdbDeviceWithStatus(AdbDevice): def __bool__(self): return True + @cached_property + def may_mumu12_family(self): + # 127.0.0.1:16XXX + return len(self.serial) == 15 and self.serial.startswith('127.0.0.1:16') + class Connection(ConnectionAttr): def __init__(self, config): @@ -780,7 +785,16 @@ class Connection(ConnectionAttr): raise RequestHumanTakeover elif available.count == 1: logger.info(f'Auto device detection found only one device, using it') - self.serial = devices[0].serial + self.serial = available[0].serial + del_cached_property(self, 'adb') + elif available.count == 2 \ + and available.select(serial='127.0.0.1:7555') \ + and available.select(may_mumu12_family=True): + logger.info(f'Auto device detection found MuMu12 device, using it') + # For MuMu12 serials like 127.0.0.1:7555 and 127.0.0.1:16384 + # ignore 7555 use 16384 + remain = available.select(may_mumu12_family=True).first_or_none() + self.serial = remain.serial del_cached_property(self, 'adb') else: logger.critical('Multiple devices found, auto device detection cannot decide which to choose, '