From f959b53445c558551f617d561411950dff5f77db Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Wed, 11 Sep 2024 18:48:01 +0800 Subject: [PATCH] Fix: Share screenshot_method_override across tasks --- module/device/device.py | 6 ------ module/device/screenshot.py | 19 +++++++++++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/module/device/device.py b/module/device/device.py index 932240989..a4cd54424 100644 --- a/module/device/device.py +++ b/module/device/device.py @@ -93,12 +93,6 @@ class Device(Screenshot, Control, AppControl): if IS_WINDOWS and self.config.EmulatorInfo_Emulator == 'auto': _ = self.emulator_instance - # SRC only, use nemu_ipc if available - available = self.nemu_ipc_available() - logger.attr('nemu_ipc_available', available) - if available: - self.config.override(Emulator_ScreenshotMethod='nemu_ipc') - self.screenshot_interval_set() self.method_check() diff --git a/module/device/screenshot.py b/module/device/screenshot.py index 2dcd6fe88..b3bc69b6f 100644 --- a/module/device/screenshot.py +++ b/module/device/screenshot.py @@ -42,6 +42,15 @@ class Screenshot(Adb, WSA, DroidCast, AScreenCap, Scrcpy, NemuIpc): 'nemu_ipc': self.screenshot_nemu_ipc, } + @cached_property + def screenshot_method_override(self) -> str: + # SRC only, use nemu_ipc if available + available = self.nemu_ipc_available() + logger.attr('nemu_ipc_available', available) + if available: + return 'nemu_ipc' + return '' + def screenshot(self): """ Returns: @@ -51,10 +60,12 @@ class Screenshot(Adb, WSA, DroidCast, AScreenCap, Scrcpy, NemuIpc): self._screenshot_interval.reset() for _ in range(2): - method = self.screenshot_methods.get( - self.config.Emulator_ScreenshotMethod, - self.screenshot_adb - ) + if self.screenshot_method_override: + method = self.screenshot_method_override + else: + method = self.config.Emulator_ScreenshotMethod + method = self.screenshot_methods.get(method, self.screenshot_adb) + self.image = method() # if self.config.Emulator_ScreenshotDedithering: