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

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

Issue 1089273002: Revert of [Android] Remove android_commands uses from build/android/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 | « build/android/host_heartbeat.py ('k') | build/android/pylib/device/adb_wrapper.py » ('j') | 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>]
11 """ 11 """
12 12
13 import argparse 13 import argparse
14 import logging 14 import logging
15 import os 15 import os
16 import posixpath 16 import posixpath
17 import re 17 import re
18 import subprocess 18 import subprocess
19 import sys 19 import sys
20 import time 20 import time
21 21
22 from pylib import android_commands
22 from pylib import constants 23 from pylib import constants
23 from pylib import device_settings 24 from pylib import device_settings
24 from pylib.device import adb_wrapper
25 from pylib.device import battery_utils 25 from pylib.device import battery_utils
26 from pylib.device import device_blacklist 26 from pylib.device import device_blacklist
27 from pylib.device import device_errors 27 from pylib.device import device_errors
28 from pylib.device import device_filter
29 from pylib.device import device_utils 28 from pylib.device import device_utils
30 from pylib.utils import run_tests_helper 29 from pylib.utils import run_tests_helper
31 from pylib.utils import timeout_retry 30 from pylib.utils import timeout_retry
32 31
33 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, 32 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT,
34 'third_party', 'android_testrunner')) 33 'third_party', 'android_testrunner'))
35 import errors 34 import errors
36 35
37 36
38 class _DEFAULT_TIMEOUTS(object): 37 class _DEFAULT_TIMEOUTS(object):
39 # L can take a while to reboot after a wipe. 38 # L can take a while to reboot after a wipe.
40 LOLLIPOP = 600 39 LOLLIPOP = 600
41 PRE_LOLLIPOP = 180 40 PRE_LOLLIPOP = 180
42 41
43 HELP_TEXT = '{}s on L, {}s on pre-L'.format(LOLLIPOP, PRE_LOLLIPOP) 42 HELP_TEXT = '{}s on L, {}s on pre-L'.format(LOLLIPOP, PRE_LOLLIPOP)
44 43
45 44
46 class _PHASES(object): 45 class _PHASES(object):
47 WIPE = 'wipe' 46 WIPE = 'wipe'
48 PROPERTIES = 'properties' 47 PROPERTIES = 'properties'
49 FINISH = 'finish' 48 FINISH = 'finish'
50 49
51 ALL = [WIPE, PROPERTIES, FINISH] 50 ALL = [WIPE, PROPERTIES, FINISH]
52 51
53 52
54 def ProvisionDevices(options): 53 def ProvisionDevices(options):
55 if options.device is not None: 54 if options.device is not None:
56 devices = [options.device] 55 devices = [options.device]
57 else: 56 else:
58 devices = adb_wrapper.AdbWrapper.Devices( 57 devices = android_commands.GetAttachedDevices()
59 filters=device_filter.DefaultFilters())
60 58
61 parallel_devices = device_utils.DeviceUtils.parallel(devices) 59 parallel_devices = device_utils.DeviceUtils.parallel(devices)
62 parallel_devices.pMap(ProvisionDevice, options) 60 parallel_devices.pMap(ProvisionDevice, options)
63 if options.auto_reconnect: 61 if options.auto_reconnect:
64 _LaunchHostHeartbeat() 62 _LaunchHostHeartbeat()
65 blacklist = device_blacklist.ReadBlacklist() 63 blacklist = device_blacklist.ReadBlacklist()
66 if all(d in blacklist for d in devices): 64 if all(d in blacklist for d in devices):
67 raise device_errors.NoDevicesError 65 raise device_errors.NoDevicesError
68 return 0 66 return 0
69 67
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 def _ConfigureLocalProperties(device, java_debug=True): 189 def _ConfigureLocalProperties(device, java_debug=True):
192 """Set standard readonly testing device properties prior to reboot.""" 190 """Set standard readonly testing device properties prior to reboot."""
193 local_props = [ 191 local_props = [
194 'persist.sys.usb.config=adb', 192 'persist.sys.usb.config=adb',
195 'ro.monkey=1', 193 'ro.monkey=1',
196 'ro.test_harness=1', 194 'ro.test_harness=1',
197 'ro.audio.silent=1', 195 'ro.audio.silent=1',
198 'ro.setupwizard.mode=DISABLED', 196 'ro.setupwizard.mode=DISABLED',
199 ] 197 ]
200 if java_debug: 198 if java_debug:
201 local_props.append( 199 local_props.append('%s=all' % android_commands.JAVA_ASSERT_PROPERTY)
202 '%s=all' % device_utils.DeviceUtils.JAVA_ASSERT_PROPERTY)
203 local_props.append('debug.checkjni=1') 200 local_props.append('debug.checkjni=1')
204 try: 201 try:
205 device.WriteFile( 202 device.WriteFile(
206 constants.DEVICE_LOCAL_PROPERTIES_PATH, 203 constants.DEVICE_LOCAL_PROPERTIES_PATH,
207 '\n'.join(local_props), as_root=True) 204 '\n'.join(local_props), as_root=True)
208 # Android will not respect the local props file if it is world writable. 205 # Android will not respect the local props file if it is world writable.
209 device.RunShellCommand( 206 device.RunShellCommand(
210 ['chmod', '644', constants.DEVICE_LOCAL_PROPERTIES_PATH], 207 ['chmod', '644', constants.DEVICE_LOCAL_PROPERTIES_PATH],
211 as_root=True, check_return=True) 208 as_root=True, check_return=True)
212 except device_errors.CommandFailedError: 209 except device_errors.CommandFailedError:
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 args = parser.parse_args() 311 args = parser.parse_args()
315 constants.SetBuildType(args.target) 312 constants.SetBuildType(args.target)
316 313
317 run_tests_helper.SetLogLevel(args.verbose) 314 run_tests_helper.SetLogLevel(args.verbose)
318 315
319 return ProvisionDevices(args) 316 return ProvisionDevices(args)
320 317
321 318
322 if __name__ == '__main__': 319 if __name__ == '__main__':
323 sys.exit(main()) 320 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/host_heartbeat.py ('k') | build/android/pylib/device/adb_wrapper.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698