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():
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()
while 1:
if skip_first_screenshot:
@ -101,6 +106,7 @@ class UI(MainPage):
app_check()
minicap_check()
rotation_check()
cloud_login()
# Unknown page, need manual switching
logger.warning("Unknown ui page")

View File

@ -367,6 +367,31 @@ class LoginAndroidCloud(ModuleBase):
logger.error('Failed to enter cloud game after 3 trials')
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):
"""
Randomly do something to prevent being kicked