Fix: [ALAS] Launch parameters on waydroid

(cherry picked from commit 886736de45ceac0f23250c9aa27d1cb516f0311b)
This commit is contained in:
LmeSzinc 2024-08-11 00:15:39 +08:00
parent 1f98932bc8
commit e89c8e7013
4 changed files with 21 additions and 4 deletions

View File

@ -307,6 +307,13 @@ class Connection(ConnectionAttr):
return True
return False
@cached_property
@retry
def is_waydroid(self):
res = self.adb_getprop('ro.product.brand')
logger.attr('ro.product.brand', res)
return 'waydroid' in res.lower()
@cached_property
@retry
def nemud_app_keep_alive(self) -> str:

View File

@ -163,6 +163,10 @@ class ConnectionAttr:
def is_network_device(self):
return bool(re.match(r'\d+\.\d+\.\d+\.\d+:\d+', self.serial))
@cached_property
def is_local_network_device(self):
return bool(re.match(r'192\.168\.\d+\.\d+:\d+', self.serial))
@cached_property
def is_over_http(self):
return bool(re.match(r"^https?://", self.serial))

View File

@ -303,8 +303,11 @@ class Adb(Connection):
logger.error(result)
raise PackageNotInstalled(package_name)
ret = self.adb_shell(['am', 'start', '-a', 'android.intent.action.MAIN', '-c',
'android.intent.category.LAUNCHER', '-n', f'{package_name}/{activity_name}'])
cmd = ['am', 'start', '-a', 'android.intent.action.MAIN', '-c',
'android.intent.category.LAUNCHER', '-n', f'{package_name}/{activity_name}']
if self.is_local_network_device and self.is_waydroid:
cmd += ['--windowingMode', '4']
ret = self.adb_shell(cmd)
# Invalid activity
# Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=... }
# Error type 3

View File

@ -288,8 +288,11 @@ class Uiautomator2(Connection):
raise
activity_name = info['mainActivity']
ret = self.u2.shell(['am', 'start', '-a', 'android.intent.action.MAIN', '-c',
'android.intent.category.LAUNCHER', '-n', f'{package_name}/{activity_name}'])
cmd = ['am', 'start', '-a', 'android.intent.action.MAIN', '-c',
'android.intent.category.LAUNCHER', '-n', f'{package_name}/{activity_name}']
if self.is_local_network_device and self.is_waydroid:
cmd += ['--windowingMode', '4']
ret = self.u2.shell(cmd)
# Invalid activity
# Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=... }
# Error type 3