Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: build/android/provision_devices.py

Issue 413523006: Don't wipe data when provisioning non-rooted devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 device.RunShellCommand('restorecon %s' % dir_path, as_root=True) 129 device.RunShellCommand('restorecon %s' % dir_path, as_root=True)
130 device.RunShellCommand('echo %s > %s' % 130 device.RunShellCommand('echo %s > %s' %
131 (adb_keys[0], constants.ADB_KEYS_FILE), as_root=True) 131 (adb_keys[0], constants.ADB_KEYS_FILE), as_root=True)
132 for adb_key in adb_keys[1:]: 132 for adb_key in adb_keys[1:]:
133 device.RunShellCommand( 133 device.RunShellCommand(
134 'echo %s >> %s' % (adb_key, constants.ADB_KEYS_FILE), as_root=True) 134 'echo %s >> %s' % (adb_key, constants.ADB_KEYS_FILE), as_root=True)
135 device.RunShellCommand('restorecon %s' % constants.ADB_KEYS_FILE, 135 device.RunShellCommand('restorecon %s' % constants.ADB_KEYS_FILE,
136 as_root=True) 136 as_root=True)
137 137
138 138
139 def WipeDevicesIfPossible(devices):
140 devices_to_reboot = []
141 for device_serial in devices:
142 device = device_utils.DeviceUtils(device_serial)
143 if not device.old_interface.EnableAdbRoot():
144 continue
145 WipeDeviceData(device)
146 devices_to_reboot.append(device)
147
148 if devices_to_reboot:
149 try:
150 device_utils.DeviceUtils.parallel(devices_to_reboot).Reboot(True)
151 except errors.DeviceUnresponsiveError:
152 pass
153 for device_serial in devices_to_reboot:
154 device.WaitUntilFullyBooted(timeout=90)
155
156
139 def ProvisionDevices(options): 157 def ProvisionDevices(options):
140 is_perf = 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower() 158 is_perf = 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower()
141 # TODO(jbudorick): Parallelize provisioning of all attached devices after 159 # TODO(jbudorick): Parallelize provisioning of all attached devices after
142 # switching from AndroidCommands. 160 # switching from AndroidCommands.
143 if options.device is not None: 161 if options.device is not None:
144 devices = [options.device] 162 devices = [options.device]
145 else: 163 else:
146 devices = android_commands.GetAttachedDevices() 164 devices = android_commands.GetAttachedDevices()
147 165
148 # Wipe devices (unless --skip-wipe was specified) 166 # Wipe devices (unless --skip-wipe was specified)
149 if not options.skip_wipe: 167 if not options.skip_wipe:
150 for device_serial in devices: 168 WipeDevicesIfPossible(devices)
151 device = device_utils.DeviceUtils(device_serial)
152 device.old_interface.EnableAdbRoot()
153 WipeDeviceData(device)
154 try:
155 device_utils.DeviceUtils.parallel(devices).Reboot(True)
156 except errors.DeviceUnresponsiveError:
157 pass
158 for device_serial in devices:
159 device.WaitUntilFullyBooted(timeout=90)
160 169
161 # Provision devices 170 # Provision devices
162 for device_serial in devices: 171 for device_serial in devices:
163 device = device_utils.DeviceUtils(device_serial) 172 device = device_utils.DeviceUtils(device_serial)
164 device.old_interface.EnableAdbRoot() 173 device.old_interface.EnableAdbRoot()
165 _ConfigureLocalProperties(device, is_perf) 174 _ConfigureLocalProperties(device, is_perf)
166 device_settings_map = device_settings.DETERMINISTIC_DEVICE_SETTINGS 175 device_settings_map = device_settings.DETERMINISTIC_DEVICE_SETTINGS
167 if options.disable_location: 176 if options.disable_location:
168 device_settings_map.update(device_settings.DISABLE_LOCATION_SETTING) 177 device_settings_map.update(device_settings.DISABLE_LOCATION_SETTING)
169 else: 178 else:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 239
231 if args: 240 if args:
232 print >> sys.stderr, 'Unused args %s' % args 241 print >> sys.stderr, 'Unused args %s' % args
233 return 1 242 return 1
234 243
235 ProvisionDevices(options) 244 ProvisionDevices(options)
236 245
237 246
238 if __name__ == '__main__': 247 if __name__ == '__main__':
239 sys.exit(main(sys.argv)) 248 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698