mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-12 00:28:20 +08:00
Refactor: Abstract resolution_check_uiautomator2()
This commit is contained in:
@@ -227,13 +227,32 @@ class Uiautomator2(Connection):
|
||||
return hierarchy
|
||||
|
||||
@retry
|
||||
def window_size_uiautomator2(self) -> t.Tuple[int, int]:
|
||||
def resolution_uiautomator2(self) -> t.Tuple[int, int]:
|
||||
"""
|
||||
Returns:
|
||||
(width, height)
|
||||
"""
|
||||
return self.u2.window_size()
|
||||
|
||||
def resolution_check_uiautomator2(self):
|
||||
"""
|
||||
Alas does not actively check resolution but the width and height of screenshots.
|
||||
However, some screenshot methods do not provide device resolution, so check it here.
|
||||
|
||||
Raises:
|
||||
RequestHumanTakeover: If resolution is not 1280x720
|
||||
"""
|
||||
width, height = self.resolution_uiautomator2()
|
||||
logger.attr('Screen_size', f'{width}x{height}')
|
||||
if width == 1280 and height == 720:
|
||||
return True
|
||||
if width == 720 and height == 1280:
|
||||
return True
|
||||
|
||||
logger.critical(f'Resolution not supported: {width}x{height}')
|
||||
logger.critical('Please set emulator resolution to 1280x720')
|
||||
raise RequestHumanTakeover
|
||||
|
||||
@retry
|
||||
def proc_list_uiautomato2(self) -> t.List[ProcessInfo]:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user