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 |
| 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.old_interface.GetBatteryInfo() |
| 160 except Exception as e: |
| 161 battery_info = {} |
| 162 logging.error('Unable to obtain battery info for %s, %s', |
| 163 device_serial, e) |
| 164 |
| 165 while int(battery_info.get('level', 100)) < 95: |
| 166 if not device.old_interface.IsDeviceCharging(): |
| 167 if device.old_interface.CanControlUsbCharging(): |
| 168 device.old_interface.EnableUsbCharging() |
| 169 else: |
| 170 logging.error('Device is not charging') |
| 171 break |
| 172 logging.info('Waiting for device to charge. Current level=%s', |
| 173 battery_info.get('level', 0)) |
| 174 time.sleep(60) |
| 175 battery_info = device.old_interface.GetBatteryInfo() |
155 device.old_interface.RunShellCommandWithSU('date -u %f' % time.time()) | 176 device.old_interface.RunShellCommandWithSU('date -u %f' % time.time()) |
156 try: | 177 try: |
157 device_utils.DeviceUtils.parallel(devices).Reboot(True) | 178 device_utils.DeviceUtils.parallel(devices).Reboot(True) |
158 except errors.DeviceUnresponsiveError: | 179 except errors.DeviceUnresponsiveError: |
159 pass | 180 pass |
160 for device_serial in devices: | 181 for device_serial in devices: |
161 device = device_utils.DeviceUtils(device_serial) | 182 device = device_utils.DeviceUtils(device_serial) |
162 device.WaitUntilFullyBooted(timeout=90) | 183 device.WaitUntilFullyBooted(timeout=90) |
163 (_, props) = device.old_interface.GetShellCommandStatusAndOutput('getprop') | 184 (_, props) = device.old_interface.GetShellCommandStatusAndOutput('getprop') |
164 for prop in props: | 185 for prop in props: |
(...skipping 19 matching lines...) Expand all Loading... |
184 | 205 |
185 if args: | 206 if args: |
186 print >> sys.stderr, 'Unused args %s' % args | 207 print >> sys.stderr, 'Unused args %s' % args |
187 return 1 | 208 return 1 |
188 | 209 |
189 ProvisionDevices(options) | 210 ProvisionDevices(options) |
190 | 211 |
191 | 212 |
192 if __name__ == '__main__': | 213 if __name__ == '__main__': |
193 sys.exit(main(sys.argv)) | 214 sys.exit(main(sys.argv)) |
OLD | NEW |