Add: Screen size check

This commit is contained in:
LmeSzinc 2020-05-29 22:42:47 +08:00
parent c01a075554
commit a8333f55d4

View File

@ -18,6 +18,7 @@ class Connection:
self.serial = str(self.config.SERIAL)
self.device = self.connect(self.serial)
self.disable_uiautomator2_auto_quit()
self.check_screen_size()
@staticmethod
def adb_command(cmd, serial=None):
@ -61,3 +62,19 @@ class Connection:
def disable_uiautomator2_auto_quit(self, port=7912, expire=300000):
self.adb_command(['forward', 'tcp:%s' % port, 'tcp:%s' % port], serial=self.serial)
requests.post('http://127.0.0.1:%s/newCommandTimeout' % port, data=str(expire))
def check_screen_size(self):
info = self.device._request("get", '/info').json()
width, height = info['display']['width'], info['display']['height']
if height > width:
width, height = height, width
logger.attr('Screen_size', f'{width}x{height}')
if width == 1280 and height == 720:
return True
else:
logger.warning(f'Not supported screen size: {width}x{height}')
logger.warning('Alas requires 1280x720')
logger.hr('Script end')
exit(1)