File tree Expand file tree Collapse file tree
src/com/dtmilano/android/adb Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33from setuptools import setup , find_packages
44
55setup (name = 'androidviewclient' ,
6- version = '5.0 .0' ,
6+ version = '5.1 .0' ,
77 description = '''AndroidViewClient is a 100% pure python tool that
88 simplifies test script creation providing higher level operations and the ability of
99 obtaining the tree of Views present at any given moment on the device or emulator screen.
Original file line number Diff line number Diff line change 1717@author: Diego Torres Milano
1818'''
1919
20- __version__ = '5.0 .0'
20+ __version__ = '5.1 .0'
2121
2222import sys
2323import warnings
@@ -391,7 +391,8 @@ def type(self, text):
391391 self .shell (u'input text "%s"' % text )
392392
393393 def wake (self ):
394- self .shell ('input keyevent POWER' )
394+ if not self .isScreenOn ():
395+ self .shell ('input keyevent POWER' )
395396
396397 def isLocked (self ):
397398 '''
@@ -406,6 +407,19 @@ def isLocked(self):
406407 return (m .group (1 ) == 'true' )
407408 raise RuntimeError ("Couldn't determine screen lock state" )
408409
410+ def isScreenOn (self ):
411+ '''
412+ Checks if the screen is ON.
413+
414+ @return True if the device screen is ON
415+ '''
416+
417+ screenOnRE = re .compile ('mScreenOnFully=(true|false)' )
418+ m = screenOnRE .search (self .shell ('dumpsys window policy' ))
419+ if m :
420+ return (m .group (1 ) == 'true' )
421+ raise RuntimeError ("Couldn't determine screen ON state" )
422+
409423 def unlock (self ):
410424 '''
411425 Unlocks the screen of the device.
You can’t perform that action at this time.
0 commit comments