From 07294251c84ebffae3186632b00d2d5e9fa004e5 Mon Sep 17 00:00:00 2001 From: Metin Kaya Date: Fri, 5 Jan 2024 12:08:58 +0000 Subject: [PATCH] target: Handle dozing case in checking Android screen state is_screen_on() should also check if the screen is in 'Dozing' state. If the device is dozing, then is_screen_on() should return false. Without this patch, is_screen_on() throws 'Could not establish screen state' exception if the device is idling (screen is completely off). Signed-off-by: Metin Kaya --- devlib/target.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/devlib/target.py b/devlib/target.py index 60af5c7..fdef1bd 100644 --- a/devlib/target.py +++ b/devlib/target.py @@ -68,7 +68,7 @@ import devlib.utils.asyn as asyn FSTAB_ENTRY_REGEX = re.compile(r'(\S+) on (.+) type (\S+) \((\S+)\)') -ANDROID_SCREEN_STATE_REGEX = re.compile('(?:mPowerState|mScreenOn|mWakefulness|Display Power: state)=([0-9]+|true|false|ON|OFF|DOZE|Asleep|Awake)', +ANDROID_SCREEN_STATE_REGEX = re.compile('(?:mPowerState|mScreenOn|mWakefulness|Display Power: state)=([0-9]+|true|false|ON|OFF|DOZE|Dozing|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])') @@ -2220,6 +2220,8 @@ class AndroidTarget(Target): if match: if 'DOZE' in match.group(1).upper(): return True + if match.group(1) == 'Dozing': + return False if match.group(1) == 'Asleep': return False if match.group(1) == 'Awake':