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

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

Issue 12733012: Provision Android devices after the 'device_status_check' step. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
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
5 # found in the LICENSE file.
6
7 """Provisions Android devices with settings required for bots.
8
9 Usage:
10 ./provision_devices.py [-d <device serial number>]
11 """
12
13 import optparse
14 import os
15 import re
16 import sys
17 import thread
18 import time
19
20 from pylib import android_commands
21
22
23 def PushAndLaunchAdbReboot(device, adb_reboot):
24 android_cmd = android_commands.AndroidCommands(device)
25 # Check if adb_reboot is running. If yes, stop it.
26 output = android_cmd.RunShellCommand('ps | grep adb_reboot')
27 if output and 'adb_reboot' in output[0]:
28 pid = re.findall('(\d+)', output[0])[0]
29 android_cmd.RunShellCommand('kill %d' % pid)
30 # Check if the exe is on the device. If yes, delete it.
31 if android_cmd.FileExistsOnDevice('/data/local/adb_reboot'):
32 android_cmd.RunShellCommand('rm /data/local/adb_reboot')
33 # Push adb_reboot
34 android_cmd.PushIfNeeded('%s' % adb_reboot, '/data/local/')
35 # Launch adb_reboot
36 cmd = 'echo "cd /data/local; ./adb_reboot; exit" | adb -s %s shell' % device
37 thread.start_new_thread(os.system, (cmd,))
38 time.sleep(1)
39
40
41 def ProvisionDevices(options):
42 if options.device is not None:
43 devices = [options.device]
44 else:
45 devices = android_commands.GetAttachedDevices()
46 for device in devices:
47 android_cmd = android_commands.AndroidCommands(device)
48 android_cmd.EnableAdbRoot()
49 android_cmd.RunShellCommand('date -u %f' % time.time())
50 PushAndLaunchAdbReboot(device, options.adb_reboot)
51
52
53 def main(argv):
54 parser = optparse.OptionParser()
55 parser.add_option('-d', '--device', dest='device', default=None,
56 help='The serial number of the device to be provisioned')
57 parser.add_option('-a', '--adb_reboot', dest='adb_reboot', default=None,
58 help='Path to the adb_reboot binary')
59 options, _ = parser.parse_args(argv)
60
61 if not options.adb_reboot:
62 print >> sys.stderr, 'Path to adb_reboot not specified'
63 return -1
64
65 ProvisionDevices(options)
66
67
68 if __name__ == '__main__':
69 sys.exit(main(sys.argv))
OLDNEW
« build/android/buildbot/bb_device_steps.py ('K') | « build/android/buildbot/bb_device_steps.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698