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

Side by Side 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 unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """ 5 """
6 Provides a variety of device interactions based on adb. 6 Provides a variety of device interactions based on adb.
7 7
8 Eventually, this will be based on adb_wrapper. 8 Eventually, this will be based on adb_wrapper.
9 """ 9 """
10 # pylint: disable=W0613 10 # pylint: disable=W0613
11 11
12 import multiprocessing 12 import multiprocessing
13 import os 13 import os
14 import sys 14 import sys
15 import time
15 16
16 import pylib.android_commands 17 import pylib.android_commands
17 from pylib.device import adb_wrapper 18 from pylib.device import adb_wrapper
18 from pylib.device import decorators 19 from pylib.device import decorators
19 from pylib.device import device_errors 20 from pylib.device import device_errors
20 21
21 CHROME_SRC_DIR = os.path.abspath( 22 CHROME_SRC_DIR = os.path.abspath(
22 os.path.join(os.path.dirname(__file__), '..', '..', '..', '..')) 23 os.path.join(os.path.dirname(__file__), '..', '..', '..', '..'))
23 sys.path.append(os.path.join( 24 sys.path.append(os.path.join(
24 CHROME_SRC_DIR, 'third_party', 'android_testrunner')) 25 CHROME_SRC_DIR, 'third_party', 'android_testrunner'))
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 Args: 144 Args:
144 timeout: Same as for |IsOnline|. 145 timeout: Same as for |IsOnline|.
145 retries: Same as for |IsOnline|. 146 retries: Same as for |IsOnline|.
146 Raises: 147 Raises:
147 CommandFailedError if root could not be enabled. 148 CommandFailedError if root could not be enabled.
148 """ 149 """
149 if not self.old_interface.EnableAdbRoot(): 150 if not self.old_interface.EnableAdbRoot():
150 raise device_errors.CommandFailedError( 151 raise device_errors.CommandFailedError(
151 'adb root', 'Could not enable root.') 152 'adb root', 'Could not enable root.')
152 153
154 @decorators.WithTimeoutAndRetriesFromInstance(
155 '_default_timeout', '_default_retries')
156 def GetExternalStoragePath(self, timeout=None, retries=None):
157 """ Get the device's path to its SD card.
158
159 Args:
160 timeout: Same as for |IsOnline|.
161 retries: Same as for |IsOnline|.
162 Returns:
163 The device's path to its SD card.
164 """
165 try:
166 return self.old_interface.GetExternalStorage()
167 except AssertionError as e:
168 raise device_errors.CommandFailedError(str(e))
169
170 @decorators.WithTimeoutAndRetriesFromInstance(
171 '_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 -
172 def WaitUntilFullyBooted(self, wifi=False, timeout=None, retries=None):
173 """ Wait for the device to fully boot.
174
175 This means waiting for the device to boot, the package manager to be
176 available, and the SD card to be ready. It can optionally mean waiting
177 for wifi to come up, too.
178
179 Args:
180 wifi: A boolean indicating if we should wait for wifi to come up or not.
181 timeout: Same as for |IsOnline|.
182 retries: Same as for |IsOnline|.
183 Raises:
184 CommandTimeoutError if one of the component waits times out.
185 DeviceUnreachableError if the device becomes unresponsive.
186 """
187 try:
188 self.old_interface.WaitForSystemBootCompleted(timeout)
189 self.old_interface.WaitForDevicePm()
190 self.old_interface.WaitForSdCardReady(timeout)
191 if wifi:
192 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
193 while not wifi_enabled:
194 wifi_results = self.old_interface.RunShellCommand('dumpsys wifi')
195 wifi_enabled = 'Wi-Fi is enabled' in wifi_results
196 time.sleep(0.1)
197 except errors.DeviceUnresponsiveError as e:
198 raise device_errors.DeviceUnreachableError(str(e))
199 except errors.WaitForResponseTimedOutError as e:
200 raise device_errors.CommandTimeoutError(str(e))
201
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698