From ba721f019f3a1d3231993b27ccc1954424bd7ef4 Mon Sep 17 00:00:00 2001 From: = Date: Sun, 28 Jun 2020 15:09:13 +0800 Subject: [PATCH] isscreenon interface compatible with android 10 (cherry picked from commit 91d263e844698a6328a5f2421112d5140e9c0c45) (cherry picked from commit b5ec9057062055abe315ba2a5361957e11f37d4f) --- airtest/core/android/adb.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/airtest/core/android/adb.py b/airtest/core/android/adb.py index fbd3e4a0..99441d2e 100644 --- a/airtest/core/android/adb.py +++ b/airtest/core/android/adb.py @@ -1059,18 +1059,17 @@ def is_screenon(self): True or False whether the screen is turned on or off """ - try: - screenOnRE = re.compile('mScreenOnFully=(true|false)') - m = screenOnRE.search(self.shell('dumpsys window policy')) - if m: - return (m.group(1) == 'true') - raise AirtestError("Couldn't determine screen ON state") - except Exception: + screenOnRE = re.compile('mScreenOnFully=(true|false)') + m = screenOnRE.search(self.shell('dumpsys window policy')) + if m: + return m.group(1) == 'true' + else: + # MIUI11 screenOnRE = re.compile('screenState=(SCREEN_STATE_ON|SCREEN_STATE_OFF)') m = screenOnRE.search(self.shell('dumpsys window policy')) if m: - return (m.group(1) == 'SCREEN_STATE_ON') - raise AirtestError("Couldn't determine screen ON state") + return m.group(1) == 'SCREEN_STATE_ON' + raise AirtestError("Couldn't determine screen ON state") def is_locked(self): """