Skip to content

Commit

Permalink
isscreenon interface compatible with android 10
Browse files Browse the repository at this point in the history
(cherry picked from commit 91d263e844698a6328a5f2421112d5140e9c0c45)
  • Loading branch information
yimelia committed Jun 28, 2020
1 parent 1300359 commit b5ec905
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions airtest/core/android/adb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit b5ec905

Please sign in to comment.