@@ -63,24 +63,27 @@ UNIT_TEST = 'unit-test'
6363USE_JAR = 'use-jar'
6464USE_DICTIONARY = 'use-dictionary'
6565AUTO_REGEXPS = 'auto-regexps'
66+ START_ACTIVITY = 'start-activity'
6667OUTPUT = 'output'
6768WINDOW = 'window'
6869
6970USAGE = 'usage: %s [OPTION]... [serialno]'
7071# -u,-s,-p,-v eaten by monkeyrunner
71- SHORT_OPTS = 'HVIFSw:i:t:d:rCUj:D:R:o:'
72+ SHORT_OPTS = 'HVIFSw:i:t:d:rCUj:D:R:a: o:'
7273LONG_OPTS = [HELP, VERBOSE, IGNORE_SECURE_DEVICE, FORCE_VIEW_SERVER_USE, DO_NOT_START_VIEW_SERVER,
7374 WINDOW + '=',
7475 FIND_VIEWS_BY_ID + '=', FIND_VIEWS_WITH_TEXT + '=', FIND_VIEWS_WITH_CONTENT_DESCRIPTION + '=',
7576 USE_REGEXPS, VERBOSE_COMMENTS, UNIT_TEST,
7677 USE_JAR + '=', USE_DICTIONARY + '=', AUTO_REGEXPS + '=',
78+ START_ACTIVITY + '=',
7779 OUTPUT + '=']
7880LONG_OPTS_ARG = {WINDOW: 'WINDOW', FIND_VIEWS_BY_ID: 'BOOL', FIND_VIEWS_WITH_TEXT: 'BOOL', FIND_VIEWS_WITH_CONTENT_DESCRIPTION: 'BOOL',
7981 USE_JAR: 'BOOL', USE_DICTIONARY: 'BOOL', AUTO_REGEXPS: 'LIST',
82+ START_ACTIVITY: 'ACTIVITY',
8083 OUTPUT: 'STR'}
8184OPTS_HELP = {
8285 'H': 'prints this help',
83- 'w': 'use WINDOW content (defualt : -1, all windows)',
86+ 'w': 'use WINDOW content (default : -1, all windows)',
8487 'i': 'whether to use findViewById() in script',
8588 't': 'whether to use findViewWithText() in script',
8689 'd': 'whether to use findViewWithContentDescription',
@@ -89,6 +92,7 @@ OPTS_HELP = {
8992 'j': 'use jar and appropriate shebang to run script',
9093 'D': 'use a dictionary to store the Views found',
9194 'R': 'auto regexps (i.e. clock)',
95+ 'a': 'starts Activity before dump',
9296 'o': 'output filename',
9397 }
9498
@@ -328,6 +332,8 @@ for o, a in optlist:
328332 if r not in AUTO_REGEXPS_RES:
329333 error("invalid auto regexp: %s\n" % (r))
330334 usage()
335+ elif o in ['a', START_ACTIVITY]:
336+ options[START_ACTIVITY] = a
331337 elif o in ['o', OUTPUT]:
332338 options[OUTPUT] = a
333339
@@ -391,7 +397,15 @@ from com.dtmilano.android.viewclient import ViewClient
391397
392398from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
393399
394- device, serialno = ViewClient.connectToDeviceOrExit()
400+ device, serialno = ViewClient.connectToDeviceOrExit()\
401+ '''
402+
403+ if options[START_ACTIVITY]:
404+ print '''
405+ device.startActivity(component='%s')\
406+ ''' % options[START_ACTIVITY]
407+
408+ print '''\
395409vc = ViewClient(device, serialno, autodump=False)
396410vc.dump(window=%s)
397411''' % (options[WINDOW] if type(options[WINDOW]).__name__ == 'str' and options[WINDOW][0] in '-0123456789' else "'%s'" % options[WINDOW])
0 commit comments