OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Provisions Android devices with settings required for bots. | 7 """Provisions Android devices with settings required for bots. |
8 | 8 |
9 Usage: | 9 Usage: |
10 ./provision_devices.py [-d <device serial number>] | 10 ./provision_devices.py [-d <device serial number>] |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 except errors.DeviceUnresponsiveError: | 139 except errors.DeviceUnresponsiveError: |
140 pass | 140 pass |
141 for device_serial in devices: | 141 for device_serial in devices: |
142 device.WaitUntilFullyBooted(timeout=90) | 142 device.WaitUntilFullyBooted(timeout=90) |
143 | 143 |
144 # Provision devices | 144 # Provision devices |
145 for device_serial in devices: | 145 for device_serial in devices: |
146 device = device_utils.DeviceUtils(device_serial) | 146 device = device_utils.DeviceUtils(device_serial) |
147 device.old_interface.EnableAdbRoot() | 147 device.old_interface.EnableAdbRoot() |
148 _ConfigureLocalProperties(device) | 148 _ConfigureLocalProperties(device) |
149 device_settings.ConfigureContentSettingsDict( | 149 device_settings_map = device_settings.DETERMINISTIC_DEVICE_SETTINGS |
150 device, device_settings.DETERMINISTIC_DEVICE_SETTINGS) | 150 if options.disable_location: |
| 151 device_settings_map.update(device_settings.DISABLE_LOCATION_SETTING) |
| 152 else: |
| 153 device_settings_map.update(device_settings.ENABLE_LOCATION_SETTING) |
| 154 device_settings.ConfigureContentSettingsDict(device, device_settings_map) |
151 if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower(): | 155 if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower(): |
152 # TODO(tonyg): We eventually want network on. However, currently radios | 156 # TODO(tonyg): We eventually want network on. However, currently radios |
153 # can cause perfbots to drain faster than they charge. | 157 # can cause perfbots to drain faster than they charge. |
154 device_settings.ConfigureContentSettingsDict( | 158 device_settings.ConfigureContentSettingsDict( |
155 device, device_settings.NETWORK_DISABLED_SETTINGS) | 159 device, device_settings.NETWORK_DISABLED_SETTINGS) |
156 # Some perf bots run benchmarks with USB charging disabled which leads | 160 # Some perf bots run benchmarks with USB charging disabled which leads |
157 # to gradual draining of the battery. We must wait for a full charge | 161 # to gradual draining of the battery. We must wait for a full charge |
158 # before starting a run in order to keep the devices online. | 162 # before starting a run in order to keep the devices online. |
159 try: | 163 try: |
160 battery_info = device.old_interface.GetBatteryInfo() | 164 battery_info = device.old_interface.GetBatteryInfo() |
(...skipping 27 matching lines...) Expand all Loading... |
188 if options.auto_reconnect: | 192 if options.auto_reconnect: |
189 PushAndLaunchAdbReboot(devices, options.target) | 193 PushAndLaunchAdbReboot(devices, options.target) |
190 | 194 |
191 | 195 |
192 def main(argv): | 196 def main(argv): |
193 logging.basicConfig(level=logging.INFO) | 197 logging.basicConfig(level=logging.INFO) |
194 | 198 |
195 parser = optparse.OptionParser() | 199 parser = optparse.OptionParser() |
196 parser.add_option('--skip-wipe', action='store_true', default=False, | 200 parser.add_option('--skip-wipe', action='store_true', default=False, |
197 help="Don't wipe device data during provisioning.") | 201 help="Don't wipe device data during provisioning.") |
| 202 parser.add_option('--disable-location', action='store_true', default=False, |
| 203 help="Disallow Google location services on devices.") |
198 parser.add_option('-d', '--device', | 204 parser.add_option('-d', '--device', |
199 help='The serial number of the device to be provisioned') | 205 help='The serial number of the device to be provisioned') |
200 parser.add_option('-t', '--target', default='Debug', help='The build target') | 206 parser.add_option('-t', '--target', default='Debug', help='The build target') |
201 parser.add_option( | 207 parser.add_option( |
202 '-r', '--auto-reconnect', action='store_true', | 208 '-r', '--auto-reconnect', action='store_true', |
203 help='Push binary which will reboot the device on adb disconnections.') | 209 help='Push binary which will reboot the device on adb disconnections.') |
204 options, args = parser.parse_args(argv[1:]) | 210 options, args = parser.parse_args(argv[1:]) |
205 constants.SetBuildType(options.target) | 211 constants.SetBuildType(options.target) |
206 | 212 |
207 if args: | 213 if args: |
208 print >> sys.stderr, 'Unused args %s' % args | 214 print >> sys.stderr, 'Unused args %s' % args |
209 return 1 | 215 return 1 |
210 | 216 |
211 ProvisionDevices(options) | 217 ProvisionDevices(options) |
212 | 218 |
213 | 219 |
214 if __name__ == '__main__': | 220 if __name__ == '__main__': |
215 sys.exit(main(sys.argv)) | 221 sys.exit(main(sys.argv)) |
OLD | NEW |