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=unused-argument | 9 # pylint: disable=unused-argument |
10 | 10 |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 output = self.RunShellCommand(['pm', 'path', package], single_line=True, | 357 output = self.RunShellCommand(['pm', 'path', package], single_line=True, |
358 check_return=should_check_return) | 358 check_return=should_check_return) |
359 if not output: | 359 if not output: |
360 return None | 360 return None |
361 if not output.startswith('package:'): | 361 if not output.startswith('package:'): |
362 raise device_errors.CommandFailedError('pm path returned: %r' % output, | 362 raise device_errors.CommandFailedError('pm path returned: %r' % output, |
363 str(self)) | 363 str(self)) |
364 return output[len('package:'):] | 364 return output[len('package:'):] |
365 | 365 |
366 @decorators.WithTimeoutAndRetriesFromInstance() | 366 @decorators.WithTimeoutAndRetriesFromInstance() |
| 367 def GetApplicationDataDirectory(self, package, timeout=None, retries=None): |
| 368 """Get the data directory on the device for the given package. |
| 369 |
| 370 Args: |
| 371 package: Name of the package. |
| 372 |
| 373 Returns: |
| 374 The package's data directory, or None if the package doesn't exist on the |
| 375 device. |
| 376 """ |
| 377 try: |
| 378 output = self._RunPipedShellCommand( |
| 379 'pm dump %s | grep dataDir=' % cmd_helper.SingleQuote(package)) |
| 380 for line in output: |
| 381 _, _, dataDir = line.partition('dataDir=') |
| 382 if dataDir: |
| 383 return dataDir |
| 384 except device_errors.CommandFailedError: |
| 385 logging.exception('Could not find data directory for %s', package) |
| 386 return None |
| 387 |
| 388 @decorators.WithTimeoutAndRetriesFromInstance() |
367 def WaitUntilFullyBooted(self, wifi=False, timeout=None, retries=None): | 389 def WaitUntilFullyBooted(self, wifi=False, timeout=None, retries=None): |
368 """Wait for the device to fully boot. | 390 """Wait for the device to fully boot. |
369 | 391 |
370 This means waiting for the device to boot, the package manager to be | 392 This means waiting for the device to boot, the package manager to be |
371 available, and the SD card to be ready. It can optionally mean waiting | 393 available, and the SD card to be ready. It can optionally mean waiting |
372 for wifi to come up, too. | 394 for wifi to come up, too. |
373 | 395 |
374 Args: | 396 Args: |
375 wifi: A boolean indicating if we should wait for wifi to come up or not. | 397 wifi: A boolean indicating if we should wait for wifi to come up or not. |
376 timeout: timeout in seconds | 398 timeout: timeout in seconds |
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1579 blacklist = device_blacklist.ReadBlacklist() | 1601 blacklist = device_blacklist.ReadBlacklist() |
1580 def blacklisted(adb): | 1602 def blacklisted(adb): |
1581 if adb.GetDeviceSerial() in blacklist: | 1603 if adb.GetDeviceSerial() in blacklist: |
1582 logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial()) | 1604 logging.warning('Device %s is blacklisted.', adb.GetDeviceSerial()) |
1583 return True | 1605 return True |
1584 return False | 1606 return False |
1585 | 1607 |
1586 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() | 1608 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() |
1587 if not blacklisted(adb)] | 1609 if not blacklisted(adb)] |
1588 | 1610 |
OLD | NEW |