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

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

Issue 380073003: Fix provision_devices on the L-release preview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
« 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 communicate with the device, but after reboot the device will need to be 112 communicate with the device, but after reboot the device will need to be
113 re-authorized because the adb keys file is stored in /data/misc/adb/. 113 re-authorized because the adb keys file is stored in /data/misc/adb/.
114 Thus, adb_keys file is rewritten so the device does not need to be 114 Thus, adb_keys file is rewritten so the device does not need to be
115 re-authorized. 115 re-authorized.
116 116
117 Arguments: 117 Arguments:
118 device: the device to wipe 118 device: the device to wipe
119 """ 119 """
120 device_authorized = device.FileExists(constants.ADB_KEYS_FILE) 120 device_authorized = device.FileExists(constants.ADB_KEYS_FILE)
121 if device_authorized: 121 if device_authorized:
122 adb_keys = device.RunShellCommand('cat %s' % constants.ADB_KEYS_FILE, 122 adb_keys = '\n'.join(set(
123 as_root=True) 123 device.ReadFile(constants.ADB_KEYS_FILE, as_root=True)))
124 device.RunShellCommand('wipe data', as_root=True) 124 device.RunShellCommand('wipe data', as_root=True)
125 if device_authorized: 125 if device_authorized:
126 path_list = constants.ADB_KEYS_FILE.split('/') 126 path_list = constants.ADB_KEYS_FILE.split('/')
127 dir_path = '/'.join(path_list[:len(path_list)-1]) 127 dir_path = '/'.join(path_list[:len(path_list)-1])
128 device.RunShellCommand('mkdir -p %s' % dir_path, as_root=True) 128 device.RunShellCommand('mkdir -p %s' % dir_path, as_root=True)
129 device.RunShellCommand('echo %s > %s' % 129 device.RunShellCommand('restorecon %s' % dir_path, as_root=True)
130 (adb_keys[0], constants.ADB_KEYS_FILE)) 130 device.RunShellCommand('echo %s > %s' % (adb_keys, constants.ADB_KEYS_FILE),
Sami 2014/07/10 11:26:37 Does this work if there are multiple keys in adb_k
131 for adb_key in adb_keys[1:]: 131 as_root=True)
132 device.RunShellCommand( 132 device.RunShellCommand('restorecon %s' % constants.ADB_KEYS_FILE,
133 'echo %s >> %s' % (adb_key, constants.ADB_KEYS_FILE)) 133 as_root=True)
134 134
135 135
136 def ProvisionDevices(options): 136 def ProvisionDevices(options):
137 is_perf = 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower() 137 is_perf = 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower()
138 # TODO(jbudorick): Parallelize provisioning of all attached devices after 138 # TODO(jbudorick): Parallelize provisioning of all attached devices after
139 # switching from AndroidCommands. 139 # switching from AndroidCommands.
140 if options.device is not None: 140 if options.device is not None:
141 devices = [options.device] 141 devices = [options.device]
142 else: 142 else:
143 devices = android_commands.GetAttachedDevices() 143 devices = android_commands.GetAttachedDevices()
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 if args: 228 if args:
229 print >> sys.stderr, 'Unused args %s' % args 229 print >> sys.stderr, 'Unused args %s' % args
230 return 1 230 return 1
231 231
232 ProvisionDevices(options) 232 ProvisionDevices(options)
233 233
234 234
235 if __name__ == '__main__': 235 if __name__ == '__main__':
236 sys.exit(main(sys.argv)) 236 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