| Index: build/android/pylib/device/device_utils.py
|
| diff --git a/build/android/pylib/device/device_utils.py b/build/android/pylib/device/device_utils.py
|
| index c8a5c3a48124107fe9142489c6cf999e4d143eb4..93e364eb426599cdcd32abc69fc1ce9122f3f96d 100644
|
| --- a/build/android/pylib/device/device_utils.py
|
| +++ b/build/android/pylib/device/device_utils.py
|
| @@ -8,14 +8,49 @@ Provides a variety of device interactions based on adb.
|
| Eventually, this will be based on adb_wrapper.
|
| """
|
|
|
| +import multiprocessing
|
| +import os
|
| +import sys
|
| import pylib.android_commands
|
| from pylib.device import adb_wrapper
|
|
|
| +CHROME_SRC_DIR = os.path.abspath(
|
| + os.path.join(os.path.dirname(__file__), '..', '..', '..', '..'))
|
| +sys.path.append(os.path.join(
|
| + CHROME_SRC_DIR, 'third_party', 'android_testrunner'))
|
| +import errors
|
|
|
| def GetAVDs():
|
| return pylib.android_commands.GetAVDs()
|
|
|
|
|
| +# multiprocessing map_async requires a top-level function for pickle library.
|
| +def RebootDeviceSafe(device):
|
| + """Reboot a device, wait for it to start, and squelch timeout exceptions."""
|
| + try:
|
| + DeviceUtils(device).old_interface.Reboot(True)
|
| + except errors.DeviceUnresponsiveError as e:
|
| + return e
|
| +
|
| +
|
| +def RebootDevices():
|
| + """Reboot all attached and online devices."""
|
| + devices = pylib.android_commands.GetAttachedDevices()
|
| + print 'Rebooting: %s' % devices
|
| + if devices:
|
| + pool = multiprocessing.Pool(len(devices))
|
| + results = pool.map_async(RebootDeviceSafe, devices).get(99999)
|
| +
|
| + for device, result in zip(devices, results):
|
| + if result:
|
| + print '%s failed to startup.' % device
|
| +
|
| + if any(results):
|
| + print 'RebootDevices() Warning: %s' % results
|
| + else:
|
| + print 'Reboots complete.'
|
| +
|
| +
|
| class DeviceUtils(object):
|
|
|
| def __init__(self, device):
|
|
|