OLD | NEW |
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 """Provides a variety of device interactions based on adb. | 5 """Provides a variety of device interactions based on adb. |
6 | 6 |
7 Eventually, this will be based on adb_wrapper. | 7 Eventually, this will be based on adb_wrapper. |
8 """ | 8 """ |
9 # pylint: disable=W0613 | 9 # pylint: disable=W0613 |
10 | 10 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 @decorators.WithTimeoutAndRetriesFromInstance() | 249 @decorators.WithTimeoutAndRetriesFromInstance() |
250 def GetApplicationPath(self, package, timeout=None, retries=None): | 250 def GetApplicationPath(self, package, timeout=None, retries=None): |
251 """Get the path of the installed apk on the device for the given package. | 251 """Get the path of the installed apk on the device for the given package. |
252 | 252 |
253 Args: | 253 Args: |
254 package: Name of the package. | 254 package: Name of the package. |
255 | 255 |
256 Returns: | 256 Returns: |
257 Path to the apk on the device if it exists, None otherwise. | 257 Path to the apk on the device if it exists, None otherwise. |
258 """ | 258 """ |
| 259 # 'pm path' is liable to incorrectly exit with a nonzero number starting |
| 260 # in Lollipop. |
| 261 # TODO(jbudorick): Check if this is fixed as new Android versions are |
| 262 # released to put an upper bound on this. |
| 263 should_check_return = (self.build_version_sdk < |
| 264 constants.ANDROID_SDK_VERSION_CODES.LOLLIPOP) |
259 output = self.RunShellCommand(['pm', 'path', package], single_line=True, | 265 output = self.RunShellCommand(['pm', 'path', package], single_line=True, |
260 check_return=True) | 266 check_return=should_check_return) |
261 if not output: | 267 if not output: |
262 return None | 268 return None |
263 if not output.startswith('package:'): | 269 if not output.startswith('package:'): |
264 raise device_errors.CommandFailedError('pm path returned: %r' % output, | 270 raise device_errors.CommandFailedError('pm path returned: %r' % output, |
265 str(self)) | 271 str(self)) |
266 return output[len('package:'):] | 272 return output[len('package:'):] |
267 | 273 |
268 @decorators.WithTimeoutAndRetriesFromInstance() | 274 @decorators.WithTimeoutAndRetriesFromInstance() |
269 def WaitUntilFullyBooted(self, wifi=False, timeout=None, retries=None): | 275 def WaitUntilFullyBooted(self, wifi=False, timeout=None, retries=None): |
270 """Wait for the device to fully boot. | 276 """Wait for the device to fully boot. |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1263 Returns: | 1269 Returns: |
1264 A Parallelizer operating over |devices|. | 1270 A Parallelizer operating over |devices|. |
1265 """ | 1271 """ |
1266 if not devices: | 1272 if not devices: |
1267 devices = adb_wrapper.AdbWrapper.GetDevices() | 1273 devices = adb_wrapper.AdbWrapper.GetDevices() |
1268 devices = [d if isinstance(d, cls) else cls(d) for d in devices] | 1274 devices = [d if isinstance(d, cls) else cls(d) for d in devices] |
1269 if async: | 1275 if async: |
1270 return parallelizer.Parallelizer(devices) | 1276 return parallelizer.Parallelizer(devices) |
1271 else: | 1277 else: |
1272 return parallelizer.SyncParallelizer(devices) | 1278 return parallelizer.SyncParallelizer(devices) |
OLD | NEW |