OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import collections | 6 import collections |
7 import logging | 7 import logging |
8 import optparse | 8 import optparse |
9 import os | 9 import os |
10 import sys | 10 import sys |
11 | 11 |
12 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), | 12 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), |
13 os.pardir, | 13 os.pardir, |
14 os.pardir, | 14 os.pardir, |
15 'build', | 15 'build', |
16 'android') | 16 'android') |
17 sys.path.append(BUILD_ANDROID_DIR) | 17 sys.path.append(BUILD_ANDROID_DIR) |
18 from pylib import android_commands | |
19 from pylib import constants | 18 from pylib import constants |
20 from pylib import flag_changer | 19 from pylib import flag_changer |
21 from pylib.device import device_errors | 20 from pylib.device import device_errors |
22 from pylib.device import device_utils | 21 from pylib.device import device_utils |
23 from pylib.device import intent | 22 from pylib.device import intent |
24 | 23 |
25 # Browser Constants | 24 # Browser Constants |
26 DEFAULT_BROWSER = 'chrome' | 25 DEFAULT_BROWSER = 'chrome' |
27 | 26 |
28 # Action Constants | 27 # Action Constants |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 sys.exit(1) | 80 sys.exit(1) |
82 | 81 |
83 if not options.browser in constants.PACKAGE_INFO.keys(): | 82 if not options.browser in constants.PACKAGE_INFO.keys(): |
84 option_parser.error('Unknown browser option ' + options.browser) | 83 option_parser.error('Unknown browser option ' + options.browser) |
85 | 84 |
86 package_info = constants.PACKAGE_INFO[options.browser] | 85 package_info = constants.PACKAGE_INFO[options.browser] |
87 | 86 |
88 package = package_info.package | 87 package = package_info.package |
89 activity = package_info.activity | 88 activity = package_info.activity |
90 | 89 |
91 devices = android_commands.GetAttachedDevices() | 90 devices = device_utils.DeviceUtils.HealthyDevices() |
92 if not devices: | 91 if not devices: |
93 raise device_errors.NoDevicesError() | 92 raise device_errors.NoDevicesError() |
94 elif len(devices) > 1: | 93 elif len(devices) > 1: |
95 logging.warning('Multiple devices attached. Using %s.' % devices[0]) | 94 logging.warning('Multiple devices attached. Using %s.', str(devices[0])) |
96 device = device_utils.DeviceUtils(devices[0]) | 95 device = devices[0] |
97 | 96 |
98 try: | 97 try: |
99 device.EnableRoot() | 98 device.EnableRoot() |
100 except device_errors.CommandFailedError as e: | 99 except device_errors.CommandFailedError as e: |
101 # Try to change the flags and start the activity anyway. | 100 # Try to change the flags and start the activity anyway. |
102 # TODO(jbudorick) Handle this exception appropriately after interface | 101 # TODO(jbudorick) Handle this exception appropriately after interface |
103 # conversions are finished. | 102 # conversions are finished. |
104 logging.error(str(e)) | 103 logging.error(str(e)) |
105 flags = flag_changer.FlagChanger(device, package_info.cmdline_file) | 104 flags = flag_changer.FlagChanger(device, package_info.cmdline_file) |
106 if ENABLE_TEST_INTENTS_FLAG not in flags.Get(): | 105 if ENABLE_TEST_INTENTS_FLAG not in flags.Get(): |
107 flags.AddFlags([ENABLE_TEST_INTENTS_FLAG]) | 106 flags.AddFlags([ENABLE_TEST_INTENTS_FLAG]) |
108 | 107 |
109 device.StartActivity(intent.Intent(package=package, activity=activity, | 108 device.StartActivity(intent.Intent(package=package, activity=activity, |
110 action=action)) | 109 action=action)) |
111 | 110 |
112 if __name__ == '__main__': | 111 if __name__ == '__main__': |
113 sys.exit(main(sys.argv)) | 112 sys.exit(main(sys.argv)) |
OLD | NEW |