1717@author: Diego Torres Milano
1818'''
1919
20- __version__ = '2.3.18 '
20+ __version__ = '2.3.19 '
2121
2222import sys
2323import subprocess
@@ -940,7 +940,7 @@ class ViewClient:
940940 No service is started.
941941 '''
942942
943- def __init__ (self , device , serialno , adb = None , autodump = True , forceviewserveruse = False , localport = VIEW_SERVER_PORT , remoteport = VIEW_SERVER_PORT , startviewserver = True ):
943+ def __init__ (self , device , serialno , adb = None , autodump = True , forceviewserveruse = False , localport = VIEW_SERVER_PORT , remoteport = VIEW_SERVER_PORT , startviewserver = True , ignoreuiautomatorkilled = False ):
944944 '''
945945 Constructor
946946
@@ -962,6 +962,8 @@ def __init__(self, device, serialno, adb=None, autodump=True, forceviewserveruse
962962 emulator
963963 @type startviewserver: boolean
964964 @param startviewserver: Whether to start the B{global} ViewServer
965+ @type ignoreuiautomatorkilled: boolean
966+ @param ignoreuiautomatorkilled: Ignores received B{Killed} message from C{uiautomator}
965967 '''
966968
967969 if not device :
@@ -1034,6 +1036,11 @@ def __init__(self, device, serialno, adb=None, autodump=True, forceviewserveruse
10341036 ''' Force the use of ViewServer even if the conditions to use UiAutomator are satisfied '''
10351037 self .useUiAutomator = (self .build [VERSION_SDK_PROPERTY ] >= 16 ) and not forceviewserveruse # jelly bean 4.1 & 4.2
10361038 ''' If UIAutomator is supported by the device it will be used '''
1039+ self .ignoreUiAutomatorKilled = ignoreuiautomatorkilled
1040+ ''' On some devices (i.e. Nexus 7 running 4.2.2) uiautomator is killed just after generating
1041+ the dump file. In many cases the file is already complete so we can ask to ignore the 'Killed'
1042+ message by setting L{ignoreuiautomatorkilled} to C{True}
1043+ '''
10371044
10381045 if self .useUiAutomator :
10391046 self .textProperty = TEXT_PROPERTY_UI_AUTOMATOR
@@ -1638,7 +1645,10 @@ def dump(self, window=-1, sleep=1):
16381645 if not output :
16391646 raise RuntimeError ('ERROR: Getting UIAutomator dump' )
16401647 if not re .search ('dumped' , output ):
1641- raise RuntimeError ("ERROR: UIAutomator dump output doesn't contain 'dumped' (%s)" % output )
1648+ if re .search ('Killed' , output ) and self .ignoreUiAutomatorKilled :
1649+ pass
1650+ else :
1651+ raise RuntimeError ("ERROR: UIAutomator dump output doesn't contain 'dumped' (%s)" % output )
16421652 received = self .device .shell ('cat %s 2>/dev/null' % windowDump )
16431653 if received :
16441654 received = received .encode ('ascii' , 'ignore' )
0 commit comments