From d6a2ed82472996fc18890115a37d8eeaa5920e58 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 27 Sep 2021 14:45:55 -0700 Subject: [PATCH] Teach the script to understand "dumpsys power" output from newer Android versions. Newer Android versions do not include any of the attributes that we're currently looking for in the "dumpsys power" output. Instead they have "mWakefulness" which can either be "Asleep" or "Awake". Adjust the regex to look for that attribute as well. --- devlib/target.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/devlib/target.py b/devlib/target.py index f30a420..d0bf9fe 100644 --- a/devlib/target.py +++ b/devlib/target.py @@ -61,7 +61,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|DOZE)', +ANDROID_SCREEN_STATE_REGEX = re.compile('(?:mPowerState|mScreenOn|mWakefulness|Display Power: state)=([0-9]+|true|false|ON|OFF|DOZE|Asleep|Awake)', re.IGNORECASE) ANDROID_SCREEN_RESOLUTION_REGEX = re.compile(r'cur=(?P\d+)x(?P\d+)') ANDROID_SCREEN_ROTATION_REGEX = re.compile(r'orientation=(?P[0-3])') @@ -1792,6 +1792,10 @@ class AndroidTarget(Target): if match: if 'DOZE' in match.group(1).upper(): return True + if match.group(1) == 'Asleep': + return False + if match.group(1) == 'Awake': + return True return boolean(match.group(1)) else: raise TargetStableError('Could not establish screen state.')