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

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

Issue 294113003: [Android] Convert to DeviceUtils versions of WaitUntilFullyBooted and GetExternalStoragePath. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 ea1019d3de996f44b6bcb95785541b7570ee4344..d9159afc450d4be0af2bfdf0e5912b42b0c0063c 100644
--- a/build/android/pylib/device/device_utils.py
+++ b/build/android/pylib/device/device_utils.py
@@ -12,6 +12,7 @@ Eventually, this will be based on adb_wrapper.
import multiprocessing
import os
import sys
+import time
import pylib.android_commands
from pylib.device import adb_wrapper
@@ -150,3 +151,51 @@ class DeviceUtils(object):
raise device_errors.CommandFailedError(
'adb root', 'Could not enable root.')
+ @decorators.WithTimeoutAndRetriesFromInstance(
+ '_default_timeout', '_default_retries')
+ def GetExternalStoragePath(self, timeout=None, retries=None):
+ """ Get the device's path to its SD card.
+
+ Args:
+ timeout: Same as for |IsOnline|.
+ retries: Same as for |IsOnline|.
+ Returns:
+ The device's path to its SD card.
+ """
+ try:
+ return self.old_interface.GetExternalStorage()
+ except AssertionError as e:
+ raise device_errors.CommandFailedError(str(e))
+
+ @decorators.WithTimeoutAndRetriesFromInstance(
+ '_default_timeout', '_default_retries')
craigdh 2014/05/21 22:25:00 duplicated strings should be module level constant
jbudorick 2014/05/22 04:49:58 Wound up doing what you suggested on the last CL -
+ def WaitUntilFullyBooted(self, wifi=False, timeout=None, retries=None):
+ """ Wait for the device to fully boot.
+
+ This means waiting for the device to boot, the package manager to be
+ available, and the SD card to be ready. It can optionally mean waiting
+ for wifi to come up, too.
+
+ Args:
+ wifi: A boolean indicating if we should wait for wifi to come up or not.
+ timeout: Same as for |IsOnline|.
+ retries: Same as for |IsOnline|.
+ Raises:
+ CommandTimeoutError if one of the component waits times out.
+ DeviceUnreachableError if the device becomes unresponsive.
+ """
+ try:
+ self.old_interface.WaitForSystemBootCompleted(timeout)
+ self.old_interface.WaitForDevicePm()
+ self.old_interface.WaitForSdCardReady(timeout)
+ if wifi:
+ wifi_enabled = False
craigdh 2014/05/21 22:25:00 these five lines can be just two: while 'Wi-Fi is
jbudorick 2014/05/22 04:49:58 Done, though sadly it doesn't fit in 80 characters
+ while not wifi_enabled:
+ wifi_results = self.old_interface.RunShellCommand('dumpsys wifi')
+ wifi_enabled = 'Wi-Fi is enabled' in wifi_results
+ time.sleep(0.1)
+ except errors.DeviceUnresponsiveError as e:
+ raise device_errors.DeviceUnreachableError(str(e))
+ except errors.WaitForResponseTimedOutError as e:
+ raise device_errors.CommandTimeoutError(str(e))
+

Powered by Google App Engine
This is Rietveld 408576698