Chromium Code Reviews| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 for device_serial in devices: | 140 for device_serial in devices: |
| 141 device.WaitUntilFullyBooted(timeout=90) | 141 device.WaitUntilFullyBooted(timeout=90) |
| 142 | 142 |
| 143 # Provision devices | 143 # Provision devices |
| 144 for device_serial in devices: | 144 for device_serial in devices: |
| 145 device = device_utils.DeviceUtils(device_serial) | 145 device = device_utils.DeviceUtils(device_serial) |
| 146 device.old_interface.EnableAdbRoot() | 146 device.old_interface.EnableAdbRoot() |
| 147 _ConfigureLocalProperties(device) | 147 _ConfigureLocalProperties(device) |
| 148 device_settings.ConfigureContentSettingsDict( | 148 device_settings.ConfigureContentSettingsDict( |
| 149 device, device_settings.DETERMINISTIC_DEVICE_SETTINGS) | 149 device, device_settings.DETERMINISTIC_DEVICE_SETTINGS) |
| 150 # TODO(tonyg): We eventually want network on. However, currently radios | |
| 151 # can cause perfbots to drain faster than they charge. | |
| 152 if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower(): | 150 if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower(): |
| 151 # TODO(tonyg): We eventually want network on. However, currently radios | |
| 152 # can cause perfbots to drain faster than they charge. | |
| 153 device_settings.ConfigureContentSettingsDict( | 153 device_settings.ConfigureContentSettingsDict( |
| 154 device, device_settings.NETWORK_DISABLED_SETTINGS) | 154 device, device_settings.NETWORK_DISABLED_SETTINGS) |
| 155 # Some perf bots run benchmarks with USB charging disabled which leads | |
|
jbudorick
2014/06/13 16:43:56
Would we want to try to enable USB charging here i
| |
| 156 # to gradual draining of the battery. We must wait for a full charge | |
| 157 # before starting a run in order to keep the devices online. | |
| 158 try: | |
| 159 battery_info = device_adb.old_interface.GetBatteryInfo() | |
| 160 except Exception as e: | |
| 161 battery_info = {} | |
| 162 logging.error('Unable to obtain battery info for %s, %s', serial, e) | |
| 163 | |
| 164 while int(battery_info.get('level', 0)) < 95: | |
| 165 if (not battery_info.get('AC powered', None) == 'true' and | |
| 166 not battery_info.get('USB powered', None) == 'true' and | |
| 167 not battery_info.get('Wireless powered', None) == 'true'): | |
| 168 logging.error('Device is not charging') | |
| 169 break | |
| 170 logging.info('Waiting for device to charge. Current level=', | |
| 171 battery_info.get('level', 0)) | |
| 172 time.sleep(60) | |
| 173 battery_info = device.old_interface.GetBatteryInfo() | |
| 155 device.old_interface.RunShellCommandWithSU('date -u %f' % time.time()) | 174 device.old_interface.RunShellCommandWithSU('date -u %f' % time.time()) |
| 156 try: | 175 try: |
| 157 device_utils.DeviceUtils.parallel(devices).Reboot(True) | 176 device_utils.DeviceUtils.parallel(devices).Reboot(True) |
| 158 except errors.DeviceUnresponsiveError: | 177 except errors.DeviceUnresponsiveError: |
| 159 pass | 178 pass |
| 160 for device_serial in devices: | 179 for device_serial in devices: |
| 161 device = device_utils.DeviceUtils(device_serial) | 180 device = device_utils.DeviceUtils(device_serial) |
| 162 device.WaitUntilFullyBooted(timeout=90) | 181 device.WaitUntilFullyBooted(timeout=90) |
| 163 (_, props) = device.old_interface.GetShellCommandStatusAndOutput('getprop') | 182 (_, props) = device.old_interface.GetShellCommandStatusAndOutput('getprop') |
| 164 for prop in props: | 183 for prop in props: |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 184 | 203 |
| 185 if args: | 204 if args: |
| 186 print >> sys.stderr, 'Unused args %s' % args | 205 print >> sys.stderr, 'Unused args %s' % args |
| 187 return 1 | 206 return 1 |
| 188 | 207 |
| 189 ProvisionDevices(options) | 208 ProvisionDevices(options) |
| 190 | 209 |
| 191 | 210 |
| 192 if __name__ == '__main__': | 211 if __name__ == '__main__': |
| 193 sys.exit(main(sys.argv)) | 212 sys.exit(main(sys.argv)) |
| OLD | NEW |