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

Unified Diff: build/android/pylib/device/device_utils.py

Issue 255783008: Add option to wipe device. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits. Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/provision_devices.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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):
« no previous file with comments | « build/android/provision_devices.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698