зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1615280 - [mozdevice] ADBDevice.get_top_activity() should use dumpsys window on Android 10, r=gbrown,snorp.
Differential Revision: https://phabricator.services.mozilla.com/D62975 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
9c7c1e5027
Коммит
330b580f32
|
@ -2990,13 +2990,21 @@ class ADBDevice(ADBCommand):
|
||||||
:raises: * ADBTimeoutError
|
:raises: * ADBTimeoutError
|
||||||
* ADBError
|
* ADBError
|
||||||
"""
|
"""
|
||||||
|
if self.version < version_codes.Q:
|
||||||
|
return self._get_top_activity_P(timeout=timeout)
|
||||||
|
return self._get_top_activity_Q(timeout=timeout)
|
||||||
|
|
||||||
|
def _get_top_activity_P(self, timeout=None):
|
||||||
|
"""Returns the name of the top activity (focused app) reported by dumpsys
|
||||||
|
for Android 9 and earlier.
|
||||||
|
"""
|
||||||
package = None
|
package = None
|
||||||
data = None
|
data = None
|
||||||
cmd = "dumpsys window windows"
|
cmd = "dumpsys window windows"
|
||||||
try:
|
try:
|
||||||
data = self.shell_output(cmd, timeout=timeout)
|
data = self.shell_output(cmd, timeout=timeout)
|
||||||
except Exception:
|
except Exception:
|
||||||
# dumpsys intermittently fails on some platforms (4.3 arm emulator)
|
# dumpsys intermittently fails on some platforms.
|
||||||
return package
|
return package
|
||||||
m = re.search('mFocusedApp(.+)/', data)
|
m = re.search('mFocusedApp(.+)/', data)
|
||||||
if not m:
|
if not m:
|
||||||
|
@ -3012,6 +3020,30 @@ class ADBDevice(ADBCommand):
|
||||||
self._logger.debug('get_top_activity: %s' % str(package))
|
self._logger.debug('get_top_activity: %s' % str(package))
|
||||||
return package
|
return package
|
||||||
|
|
||||||
|
def _get_top_activity_Q(self, timeout=None):
|
||||||
|
"""Returns the name of the top activity (focused app) reported by dumpsys
|
||||||
|
for Android 10 and later.
|
||||||
|
"""
|
||||||
|
package = None
|
||||||
|
data = None
|
||||||
|
cmd = "dumpsys window"
|
||||||
|
try:
|
||||||
|
data = self.shell_output(cmd, timeout=timeout)
|
||||||
|
except Exception:
|
||||||
|
# dumpsys intermittently fails on some platforms (4.3 arm emulator)
|
||||||
|
return package
|
||||||
|
m = re.search('mFocusedApp=AppWindowToken{\w+ token=Token{'
|
||||||
|
'\w+ ActivityRecord{\w+ w+ (\w+)/w+ \w+}}}', data)
|
||||||
|
if m:
|
||||||
|
line = m.group(1)
|
||||||
|
# Extract package name: string of non-whitespace ending in forward slash
|
||||||
|
m = re.search('(\S+)/', line)
|
||||||
|
if m:
|
||||||
|
package = m.group(1)
|
||||||
|
if self._verbose:
|
||||||
|
self._logger.debug('get_top_activity: %s' % str(package))
|
||||||
|
return package
|
||||||
|
|
||||||
# System control methods
|
# System control methods
|
||||||
|
|
||||||
def is_device_ready(self, timeout=None):
|
def is_device_ready(self, timeout=None):
|
||||||
|
|
|
@ -66,3 +66,5 @@ O = 26
|
||||||
O_MR1 = 27
|
O_MR1 = 27
|
||||||
# Pie
|
# Pie
|
||||||
P = 28
|
P = 28
|
||||||
|
# 10
|
||||||
|
Q = 29
|
||||||
|
|
Загрузка…
Ссылка в новой задаче