fix: use search by emulator type first, which is more trustworthy

This commit is contained in:
2026-07-06 22:41:02 +08:00
parent bb1df87280
commit b431ab02d3
+13 -13
View File
@@ -181,6 +181,19 @@ class PlatformBase(Connection, EmulatorManagerBase):
logger.info(f'Found emulator instance: {instance}')
return instance
# Multiple instances in given serial, name and path, search by emulator
if emulator:
search_args['type'] = emulator
select = instances.select(**search_args)
if select.count == 0:
logger.warning(f'No emulator instances with {search_args}, type invalid')
search_args.pop('type')
elif select.count == 1:
instance = select[0]
logger.hr('Emulator instance', level=2)
logger.info(f'Found emulator instance: {instance}')
return instance
# Multiple instances in given serial, search by name
if name:
search_args['name'] = name
@@ -207,19 +220,6 @@ class PlatformBase(Connection, EmulatorManagerBase):
logger.info(f'Found emulator instance: {instance}')
return instance
# Multiple instances in given serial, name and path, search by emulator
if emulator:
search_args['type'] = emulator
select = instances.select(**search_args)
if select.count == 0:
logger.warning(f'No emulator instances with {search_args}, type invalid')
search_args.pop('type')
elif select.count == 1:
instance = select[0]
logger.hr('Emulator instance', level=2)
logger.info(f'Found emulator instance: {instance}')
return instance
# Still too many instances, search from running emulators
running = remove_duplicated_path(list(self.iter_running_emulator()))
logger.info('Running emulators')