Fix: Starting from cloud main page

This commit is contained in:
LmeSzinc 2024-05-28 23:31:47 +08:00
parent 60cee618a7
commit a8fa072aab
3 changed files with 33 additions and 2 deletions

View File

@ -57,6 +57,11 @@ class UI(MainPage):
def rotation_check(): def rotation_check():
self.device.get_orientation() self.device.get_orientation()
@run_once
def cloud_login():
from tasks.login.login import Login
Login(config=self.config, device=self.device).cloud_login()
timeout = Timer(10, count=20).start() timeout = Timer(10, count=20).start()
while 1: while 1:
if skip_first_screenshot: if skip_first_screenshot:
@ -101,6 +106,7 @@ class UI(MainPage):
app_check() app_check()
minicap_check() minicap_check()
rotation_check() rotation_check()
cloud_login()
# Unknown page, need manual switching # Unknown page, need manual switching
logger.warning("Unknown ui page") logger.warning("Unknown ui page")

View File

@ -367,6 +367,31 @@ class LoginAndroidCloud(ModuleBase):
logger.error('Failed to enter cloud game after 3 trials') logger.error('Failed to enter cloud game after 3 trials')
return False return False
def is_in_cloud_page(self):
if self.appear(XPath.START_GAME):
logger.info('Cloud game is in main page')
return True
elif self.appear(XPath.FLOAT_DELAY):
logger.info('Cloud game is in game with float window expanded')
return True
elif self.appear(XPath.POPUP_CONFIRM):
logger.info('Cloud game have a popup')
return True
logger.info('Not in cloud page')
return False
def cloud_login(self):
if not self.config.is_cloud_game:
return False
self.device.dump_hierarchy()
if self.is_in_cloud_page():
self.cloud_ensure_ingame()
return True
return False
def cloud_keep_alive(self): def cloud_keep_alive(self):
""" """
Randomly do something to prevent being kicked Randomly do something to prevent being kicked

View File

@ -91,7 +91,7 @@ class Login(UI, LoginAndroidCloud):
self.cloud_ensure_ingame() self.cloud_ensure_ingame()
else: else:
self.device.app_start() self.device.app_start()
self.handle_app_login() self.handle_app_login()
def app_restart(self): def app_restart(self):
logger.hr('App restart') logger.hr('App restart')
@ -100,7 +100,7 @@ class Login(UI, LoginAndroidCloud):
self.cloud_ensure_ingame() self.cloud_ensure_ingame()
else: else:
self.device.app_start() self.device.app_start()
self.handle_app_login() self.handle_app_login()
self.config.task_delay(server_update=True) self.config.task_delay(server_update=True)
def cloud_start(self): def cloud_start(self):