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 c8b471831e62aec343c705afb12bd3095bd8ea24..f5f74890540df17d2630ef0c8f3b813bddcb881f 100644 |
--- a/build/android/pylib/device/device_utils.py |
+++ b/build/android/pylib/device/device_utils.py |
@@ -364,6 +364,28 @@ class DeviceUtils(object): |
return output[len('package:'):] |
@decorators.WithTimeoutAndRetriesFromInstance() |
+ def GetApplicationDataDirectory(self, package, timeout=None, retries=None): |
+ """Get the data directory on the device for the given package. |
+ |
+ Args: |
+ package: Name of the package. |
+ |
+ Returns: |
+ The package's data directory, or None if the package doesn't exist on the |
+ device. |
+ """ |
+ try: |
+ output = self._RunPipedShellCommand( |
+ 'pm dump %s | grep dataDir=' % cmd_helper.SingleQuote(package)) |
+ for line in output: |
+ _, _, dataDir = line.partition('dataDir=') |
+ if dataDir: |
+ return dataDir |
+ except device_errors.CommandFailedError: |
+ logging.exception('Could not find data directory for %s', package) |
+ return None |
+ |
+ @decorators.WithTimeoutAndRetriesFromInstance() |
def WaitUntilFullyBooted(self, wifi=False, timeout=None, retries=None): |
"""Wait for the device to fully boot. |