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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 dir_path = '/'.join(path_list[:len(path_list)-1]) | 113 dir_path = '/'.join(path_list[:len(path_list)-1]) |
114 device.old_interface.RunShellCommandWithSU('mkdir -p %s' % dir_path) | 114 device.old_interface.RunShellCommandWithSU('mkdir -p %s' % dir_path) |
115 device.old_interface.RunShellCommand('echo %s > %s' % | 115 device.old_interface.RunShellCommand('echo %s > %s' % |
116 (adb_keys[0], constants.ADB_KEYS_FILE)) | 116 (adb_keys[0], constants.ADB_KEYS_FILE)) |
117 for adb_key in adb_keys[1:]: | 117 for adb_key in adb_keys[1:]: |
118 device.old_interface.RunShellCommand( | 118 device.old_interface.RunShellCommand( |
119 'echo %s >> %s' % (adb_key, constants.ADB_KEYS_FILE)) | 119 'echo %s >> %s' % (adb_key, constants.ADB_KEYS_FILE)) |
120 | 120 |
121 | 121 |
122 def ProvisionDevices(options): | 122 def ProvisionDevices(options): |
| 123 # TODO(jbudorick): Parallelize provisioning of all attached devices after |
| 124 # swithcing from AndroidCommands. |
123 if options.device is not None: | 125 if options.device is not None: |
124 devices = [options.device] | 126 devices = [options.device] |
125 else: | 127 else: |
126 devices = android_commands.GetAttachedDevices() | 128 devices = android_commands.GetAttachedDevices() |
127 for device_serial in devices: | 129 for device_serial in devices: |
128 device = device_utils.DeviceUtils(device_serial) | 130 device = device_utils.DeviceUtils(device_serial) |
129 device.old_interface.EnableAdbRoot() | 131 device.old_interface.EnableAdbRoot() |
130 WipeDeviceData(device) | 132 WipeDeviceData(device) |
131 try: | 133 try: |
132 (device_utils.DeviceUtils.parallel(devices) | 134 device_utils.DeviceUtils.parallel(devices).old_interface.Reboot(True) |
133 .old_interface.Reboot(True)) | |
134 except errors.DeviceUnresponsiveError: | 135 except errors.DeviceUnresponsiveError: |
135 pass | 136 pass |
136 for device_serial in devices: | 137 for device_serial in devices: |
137 device = device_utils.DeviceUtils(device_serial) | 138 device = device_utils.DeviceUtils(device_serial) |
138 device.WaitUntilFullyBooted(timeout=90) | 139 device.WaitUntilFullyBooted(timeout=90) |
139 device.old_interface.EnableAdbRoot() | 140 device.old_interface.EnableAdbRoot() |
140 _ConfigureLocalProperties(device) | 141 _ConfigureLocalProperties(device) |
141 device_settings.ConfigureContentSettingsDict( | 142 device_settings.ConfigureContentSettingsDict( |
142 device, device_settings.DETERMINISTIC_DEVICE_SETTINGS) | 143 device, device_settings.DETERMINISTIC_DEVICE_SETTINGS) |
143 # TODO(tonyg): We eventually want network on. However, currently radios | 144 # TODO(tonyg): We eventually want network on. However, currently radios |
144 # can cause perfbots to drain faster than they charge. | 145 # can cause perfbots to drain faster than they charge. |
145 if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower(): | 146 if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower(): |
146 device_settings.ConfigureContentSettingsDict( | 147 device_settings.ConfigureContentSettingsDict( |
147 device, device_settings.NETWORK_DISABLED_SETTINGS) | 148 device, device_settings.NETWORK_DISABLED_SETTINGS) |
148 device.old_interface.RunShellCommandWithSU('date -u %f' % time.time()) | 149 device.old_interface.RunShellCommandWithSU('date -u %f' % time.time()) |
| 150 try: |
| 151 device_utils.DeviceUtils.parallel(devices).old_interface.Reboot(True) |
| 152 except errors.DeviceUnresponsiveError: |
| 153 pass |
| 154 for device_serial in devices: |
| 155 device = device_utils.DeviceUtils(device_serial) |
| 156 device.WaitUntilFullyBooted(timeout=90) |
149 (_, props) = device.old_interface.GetShellCommandStatusAndOutput('getprop') | 157 (_, props) = device.old_interface.GetShellCommandStatusAndOutput('getprop') |
150 for prop in props: | 158 for prop in props: |
151 print prop | 159 print prop |
152 if options.auto_reconnect: | 160 if options.auto_reconnect: |
153 PushAndLaunchAdbReboot(devices, options.target) | 161 PushAndLaunchAdbReboot(devices, options.target) |
154 | 162 |
155 | 163 |
156 def main(argv): | 164 def main(argv): |
157 logging.basicConfig(level=logging.INFO) | 165 logging.basicConfig(level=logging.INFO) |
158 | 166 |
(...skipping 22 matching lines...) Expand all Loading... |
181 (device_utils.DeviceUtils.parallel(devices) | 189 (device_utils.DeviceUtils.parallel(devices) |
182 .old_interface.Reboot(True).pFinish(None)) | 190 .old_interface.Reboot(True).pFinish(None)) |
183 except errors.DeviceUnresponsiveError: | 191 except errors.DeviceUnresponsiveError: |
184 pass | 192 pass |
185 else: | 193 else: |
186 ProvisionDevices(options) | 194 ProvisionDevices(options) |
187 | 195 |
188 | 196 |
189 if __name__ == '__main__': | 197 if __name__ == '__main__': |
190 sys.exit(main(sys.argv)) | 198 sys.exit(main(sys.argv)) |
OLD | NEW |