| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 # swithcing from AndroidCommands. | 124 # swithcing from AndroidCommands. |
| 125 if options.device is not None: | 125 if options.device is not None: |
| 126 devices = [options.device] | 126 devices = [options.device] |
| 127 else: | 127 else: |
| 128 devices = android_commands.GetAttachedDevices() | 128 devices = android_commands.GetAttachedDevices() |
| 129 for device_serial in devices: | 129 for device_serial in devices: |
| 130 device = device_utils.DeviceUtils(device_serial) | 130 device = device_utils.DeviceUtils(device_serial) |
| 131 device.old_interface.EnableAdbRoot() | 131 device.old_interface.EnableAdbRoot() |
| 132 WipeDeviceData(device) | 132 WipeDeviceData(device) |
| 133 try: | 133 try: |
| 134 device_utils.DeviceUtils.parallel(devices).old_interface.Reboot(True) | 134 device_utils.DeviceUtils.parallel(devices).Reboot(True) |
| 135 except errors.DeviceUnresponsiveError: | 135 except errors.DeviceUnresponsiveError: |
| 136 pass | 136 pass |
| 137 for device_serial in devices: | 137 for device_serial in devices: |
| 138 device = device_utils.DeviceUtils(device_serial) | 138 device = device_utils.DeviceUtils(device_serial) |
| 139 device.WaitUntilFullyBooted(timeout=90) | 139 device.WaitUntilFullyBooted(timeout=90) |
| 140 device.old_interface.EnableAdbRoot() | 140 device.old_interface.EnableAdbRoot() |
| 141 _ConfigureLocalProperties(device) | 141 _ConfigureLocalProperties(device) |
| 142 device_settings.ConfigureContentSettingsDict( | 142 device_settings.ConfigureContentSettingsDict( |
| 143 device, device_settings.DETERMINISTIC_DEVICE_SETTINGS) | 143 device, device_settings.DETERMINISTIC_DEVICE_SETTINGS) |
| 144 # TODO(tonyg): We eventually want network on. However, currently radios | 144 # TODO(tonyg): We eventually want network on. However, currently radios |
| 145 # can cause perfbots to drain faster than they charge. | 145 # can cause perfbots to drain faster than they charge. |
| 146 if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower(): | 146 if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower(): |
| 147 device_settings.ConfigureContentSettingsDict( | 147 device_settings.ConfigureContentSettingsDict( |
| 148 device, device_settings.NETWORK_DISABLED_SETTINGS) | 148 device, device_settings.NETWORK_DISABLED_SETTINGS) |
| 149 device.old_interface.RunShellCommandWithSU('date -u %f' % time.time()) | 149 device.old_interface.RunShellCommandWithSU('date -u %f' % time.time()) |
| 150 try: | 150 try: |
| 151 device_utils.DeviceUtils.parallel(devices).old_interface.Reboot(True) | 151 device_utils.DeviceUtils.parallel(devices).Reboot(True) |
| 152 except errors.DeviceUnresponsiveError: | 152 except errors.DeviceUnresponsiveError: |
| 153 pass | 153 pass |
| 154 for device_serial in devices: | 154 for device_serial in devices: |
| 155 device = device_utils.DeviceUtils(device_serial) | 155 device = device_utils.DeviceUtils(device_serial) |
| 156 device.WaitUntilFullyBooted(timeout=90) | 156 device.WaitUntilFullyBooted(timeout=90) |
| 157 (_, props) = device.old_interface.GetShellCommandStatusAndOutput('getprop') | 157 (_, props) = device.old_interface.GetShellCommandStatusAndOutput('getprop') |
| 158 for prop in props: | 158 for prop in props: |
| 159 print prop | 159 print prop |
| 160 if options.auto_reconnect: | 160 if options.auto_reconnect: |
| 161 PushAndLaunchAdbReboot(devices, options.target) | 161 PushAndLaunchAdbReboot(devices, options.target) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 179 if args: | 179 if args: |
| 180 print >> sys.stderr, 'Unused args %s' % args | 180 print >> sys.stderr, 'Unused args %s' % args |
| 181 return 1 | 181 return 1 |
| 182 | 182 |
| 183 if options.wipe: | 183 if options.wipe: |
| 184 devices = android_commands.GetAttachedDevices() | 184 devices = android_commands.GetAttachedDevices() |
| 185 for device_serial in devices: | 185 for device_serial in devices: |
| 186 device = device_utils.DeviceUtils(device_serial) | 186 device = device_utils.DeviceUtils(device_serial) |
| 187 WipeDeviceData(device) | 187 WipeDeviceData(device) |
| 188 try: | 188 try: |
| 189 (device_utils.DeviceUtils.parallel(devices) | 189 device_utils.DeviceUtils.parallel(devices).Reboot(True) |
| 190 .old_interface.Reboot(True).pFinish(None)) | |
| 191 except errors.DeviceUnresponsiveError: | 190 except errors.DeviceUnresponsiveError: |
| 192 pass | 191 pass |
| 193 else: | 192 else: |
| 194 ProvisionDevices(options) | 193 ProvisionDevices(options) |
| 195 | 194 |
| 196 | 195 |
| 197 if __name__ == '__main__': | 196 if __name__ == '__main__': |
| 198 sys.exit(main(sys.argv)) | 197 sys.exit(main(sys.argv)) |
| OLD | NEW |