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

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

Issue 181043008: Revert of Update android device provisioning script to set some reliability settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | build/android/pylib/content_settings.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 logging
14 import optparse 13 import optparse
15 import os 14 import os
16 import re 15 import re
17 import subprocess 16 import subprocess
18 import sys 17 import sys
19 import time 18 import time
20 19
21 from pylib import android_commands 20 from pylib import android_commands
22 from pylib import constants 21 from pylib import constants
23 from pylib import device_settings
24
25 22
26 def KillHostHeartbeat(): 23 def KillHostHeartbeat():
27 ps = subprocess.Popen(['ps', 'aux'], stdout = subprocess.PIPE) 24 ps = subprocess.Popen(['ps', 'aux'], stdout = subprocess.PIPE)
28 stdout, _ = ps.communicate() 25 stdout, _ = ps.communicate()
29 matches = re.findall('\\n.*host_heartbeat.*', stdout) 26 matches = re.findall('\\n.*host_heartbeat.*', stdout)
30 for match in matches: 27 for match in matches:
31 print 'An instance of host heart beart running... will kill' 28 print 'An instance of host heart beart running... will kill'
32 pid = re.findall('(\d+)', match)[1] 29 pid = re.findall('(\d+)', match)[1]
33 subprocess.call(['kill', str(pid)]) 30 subprocess.call(['kill', str(pid)])
34 31
(...skipping 26 matching lines...) Expand all
61 adb_reboot = os.path.join(constants.DIR_SOURCE_ROOT, 58 adb_reboot = os.path.join(constants.DIR_SOURCE_ROOT,
62 'out/%s/adb_reboot' % target) 59 'out/%s/adb_reboot' % target)
63 android_cmd.PushIfNeeded(adb_reboot, '/data/local/tmp/') 60 android_cmd.PushIfNeeded(adb_reboot, '/data/local/tmp/')
64 # Launch adb_reboot 61 # Launch adb_reboot
65 print ' Launching adb_reboot ...' 62 print ' Launching adb_reboot ...'
66 p = subprocess.Popen(['adb', '-s', device, 'shell'], stdin=subprocess.PIPE) 63 p = subprocess.Popen(['adb', '-s', device, 'shell'], stdin=subprocess.PIPE)
67 p.communicate('/data/local/tmp/adb_reboot; exit\n') 64 p.communicate('/data/local/tmp/adb_reboot; exit\n')
68 LaunchHostHeartbeat() 65 LaunchHostHeartbeat()
69 66
70 67
71 def _ConfigureLocalProperties(adb):
72 """Set standard readonly testing device properties prior to reboot."""
73 local_props = [
74 'ro.monkey=1',
75 'ro.test_harness=1',
76 'ro.audio.silent=1',
77 'ro.setupwizard.mode=DISABLED',
78 ]
79 adb.SetProtectedFileContents(android_commands.LOCAL_PROPERTIES_PATH,
80 '\n'.join(local_props))
81 # Android will not respect the local props file if it is world writable.
82 adb.RunShellCommandWithSU('chmod 644 %s' %
83 android_commands.LOCAL_PROPERTIES_PATH)
84
85
86 def ProvisionDevices(options): 68 def ProvisionDevices(options):
87 if options.device is not None: 69 if options.device is not None:
88 devices = [options.device] 70 devices = [options.device]
89 else: 71 else:
90 devices = android_commands.GetAttachedDevices() 72 devices = android_commands.GetAttachedDevices()
91 for device in devices: 73 for device in devices:
92 android_cmd = android_commands.AndroidCommands(device) 74 android_cmd = android_commands.AndroidCommands(device)
93 _ConfigureLocalProperties(android_cmd)
94 device_settings.ConfigureContentSettingsDict(
95 android_cmd, device_settings.DETERMINISTIC_DEVICE_SETTINGS)
96 # TODO(tonyg): We eventually want network on. However, currently radios
97 # can cause perfbots to drain faster than they charge.
98 if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower():
99 device_settings.ConfigureContentSettingsDict(
100 android_cmd, device_settings.NETWORK_DISABLED_SETTINGS)
101 android_cmd.RunShellCommandWithSU('date -u %f' % time.time()) 75 android_cmd.RunShellCommandWithSU('date -u %f' % time.time())
102 if options.auto_reconnect: 76 if options.auto_reconnect:
103 PushAndLaunchAdbReboot(devices, options.target) 77 PushAndLaunchAdbReboot(devices, options.target)
104 78
105 79
106 def main(argv): 80 def main(argv):
107 logging.basicConfig(level=logging.INFO)
108
109 parser = optparse.OptionParser() 81 parser = optparse.OptionParser()
110 parser.add_option('-d', '--device', 82 parser.add_option('-d', '--device',
111 help='The serial number of the device to be provisioned') 83 help='The serial number of the device to be provisioned')
112 parser.add_option('-t', '--target', default='Debug', help='The build target') 84 parser.add_option('-t', '--target', default='Debug', help='The build target')
113 parser.add_option( 85 parser.add_option(
114 '-r', '--auto-reconnect', action='store_true', 86 '-r', '--auto-reconnect', action='store_true',
115 help='Push binary which will reboot the device on adb disconnections.') 87 help='Push binary which will reboot the device on adb disconnections.')
116 options, args = parser.parse_args(argv[1:]) 88 options, args = parser.parse_args(argv[1:])
117 constants.SetBuildType(options.target) 89 constants.SetBuildType(options.target)
118 90
119 if args: 91 if args:
120 print >> sys.stderr, 'Unused args %s' % args 92 print >> sys.stderr, 'Unused args %s' % args
121 return 1 93 return 1
122 94
123 ProvisionDevices(options) 95 ProvisionDevices(options)
124 96
125 97
126 if __name__ == '__main__': 98 if __name__ == '__main__':
127 sys.exit(main(sys.argv)) 99 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/content_settings.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698