From 809d987f847fb3b215a6c521e6d408f19cd8768f Mon Sep 17 00:00:00 2001 From: Valentin Schneider Date: Fri, 19 Oct 2018 18:29:08 +0100 Subject: [PATCH] AndroidTarget: Change screen resolution acquisition method The current regexp doesn't seem to work anymore on a more recent Android version (current master which reports 'Q'). Looking at other means of getting the screen resolution, this one: [1] seems to have been there for some time already (2014), and works with the current version. [1]: https://stackoverflow.com/a/26185910/5096023 --- devlib/target.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/devlib/target.py b/devlib/target.py index c32653e..f6e2331 100644 --- a/devlib/target.py +++ b/devlib/target.py @@ -43,8 +43,7 @@ from devlib.utils.types import integer, boolean, bitmask, identifier, caseless_s FSTAB_ENTRY_REGEX = re.compile(r'(\S+) on (.+) type (\S+) \((\S+)\)') ANDROID_SCREEN_STATE_REGEX = re.compile('(?:mPowerState|mScreenOn|Display Power: state)=([0-9]+|true|false|ON|OFF)', re.IGNORECASE) -ANDROID_SCREEN_RESOLUTION_REGEX = re.compile(r'mUnrestrictedScreen=\(\d+,\d+\)' - r'\s+(?P\d+)x(?P\d+)') +ANDROID_SCREEN_RESOLUTION_REGEX = re.compile(r'cur=(?P\d+)x(?P\d+)') DEFAULT_SHELL_PROMPT = re.compile(r'^.*(shell|root|juno)@?.*:[/~]\S* *[#$] ', re.MULTILINE) KVERSION_REGEX = re.compile( @@ -1042,7 +1041,7 @@ class AndroidTarget(Target): @property @memoized def screen_resolution(self): - output = self.execute('dumpsys window') + output = self.execute('dumpsys window displays') match = ANDROID_SCREEN_RESOLUTION_REGEX.search(output) if match: return (int(match.group('width')),