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

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

Issue 949323003: Write adb public key to devices during provision. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make --adb-key-files an argument Created 5 years, 10 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 def ProvisionDevice(device, options): 152 def ProvisionDevice(device, options):
153 if options.reboot_timeout: 153 if options.reboot_timeout:
154 reboot_timeout = options.reboot_timeout 154 reboot_timeout = options.reboot_timeout
155 elif (device.build_version_sdk >= 155 elif (device.build_version_sdk >=
156 constants.ANDROID_SDK_VERSION_CODES.LOLLIPOP): 156 constants.ANDROID_SDK_VERSION_CODES.LOLLIPOP):
157 reboot_timeout = _DEFAULT_TIMEOUTS.LOLLIPOP 157 reboot_timeout = _DEFAULT_TIMEOUTS.LOLLIPOP
158 else: 158 else:
159 reboot_timeout = _DEFAULT_TIMEOUTS.PRE_LOLLIPOP 159 reboot_timeout = _DEFAULT_TIMEOUTS.PRE_LOLLIPOP
160 160
161 if options.adb_key_files:
162 adb_keys = set()
163 for adb_key_file in options.adb_key_files:
164 file_path = os.path.join(os.environ['HOME'], '.android', adb_key_file)
jbudorick 2015/02/25 01:32:46 to be clear: I don't think this should be locked i
navabi 2015/02/25 01:37:21 Yep. This is a mistake. options.adb_key_files will
165 with open(file_path, 'r') as f:
166 adb_public_key = f.readlines()[0]
167 adb_keys.add(adb_public_key)
168 path_list = constants.ADB_KEYS_FILE.split('/')
jbudorick 2015/02/25 01:32:46 Why is this now just duplicating the logic from Wi
navabi 2015/02/25 01:37:21 The only part that is duplicated, is the part that
169 dir_path = '/'.join(path_list[:len(path_list)-1])
170 device.RunShellCommand('mkdir -p %s' % dir_path, as_root=True)
171 device.RunShellCommand('restorecon %s' % dir_path, as_root=True)
172 adb_key_contents = '\n'.join(adb_keys)
173 device.WriteFile(constants.ADB_KEYS_FILE, adb_key_contents, as_root=True)
174 device.RunShellCommand('restorecon %s' % constants.ADB_KEYS_FILE,
175 as_root=True)
176
161 try: 177 try:
162 if not options.skip_wipe: 178 if not options.skip_wipe:
163 WipeDeviceIfPossible(device, reboot_timeout) 179 WipeDeviceIfPossible(device, reboot_timeout)
164 try: 180 try:
165 device.EnableRoot() 181 device.EnableRoot()
166 except device_errors.CommandFailedError as e: 182 except device_errors.CommandFailedError as e:
167 logging.warning(str(e)) 183 logging.warning(str(e))
168 _ConfigureLocalProperties(device, options.enable_java_debug) 184 _ConfigureLocalProperties(device, options.enable_java_debug)
169 device_settings.ConfigureContentSettings( 185 device_settings.ConfigureContentSettings(
170 device, device_settings.DETERMINISTIC_DEVICE_SETTINGS) 186 device, device_settings.DETERMINISTIC_DEVICE_SETTINGS)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 parser.add_argument('--disable-network', action='store_true', 285 parser.add_argument('--disable-network', action='store_true',
270 help='disable network access on devices') 286 help='disable network access on devices')
271 parser.add_argument('--disable-java-debug', action='store_false', 287 parser.add_argument('--disable-java-debug', action='store_false',
272 dest='enable_java_debug', default=True, 288 dest='enable_java_debug', default=True,
273 help='disable Java property asserts and JNI checking') 289 help='disable Java property asserts and JNI checking')
274 parser.add_argument('-t', '--target', default='Debug', 290 parser.add_argument('-t', '--target', default='Debug',
275 help='the build target (default: %(default)s)') 291 help='the build target (default: %(default)s)')
276 parser.add_argument('-r', '--auto-reconnect', action='store_true', 292 parser.add_argument('-r', '--auto-reconnect', action='store_true',
277 help='push binary which will reboot the device on adb' 293 help='push binary which will reboot the device on adb'
278 ' disconnections') 294 ' disconnections')
295 parser.add_argument('--adb-key-files', type=str, nargs='+',
296 help='list of adb keys to push to device')
279 args = parser.parse_args() 297 args = parser.parse_args()
280 constants.SetBuildType(args.target) 298 constants.SetBuildType(args.target)
281 299
282 return ProvisionDevices(args) 300 return ProvisionDevices(args)
283 301
284 302
285 if __name__ == '__main__': 303 if __name__ == '__main__':
286 sys.exit(main()) 304 sys.exit(main())
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