Chromium Code Reviews| 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 bc1f2ab27339c25b18d03ccac517649c15017c55..0dffa1d55bb52e9f24bf00dd58df0f25970f048b 100644 |
| --- a/build/android/pylib/device/device_utils.py |
| +++ b/build/android/pylib/device/device_utils.py |
| @@ -386,6 +386,28 @@ class DeviceUtils(object): |
| return apks |
| @decorators.WithTimeoutAndRetriesFromInstance() |
| + def GetApplicationVersion(self, package, timeout=None, retries=None): |
| + """Get the version name of a package installed on the device. |
| + |
| + Args: |
| + package: Name of the package. |
| + |
| + Returns: |
| + A string with the version name or None if the package is not found |
| + on the device. |
| + """ |
| + output = self.RunShellCommand( |
| + ['dumpsys', 'package', package], check_return=True) |
| + if not output: |
| + return None |
|
jbudorick
2015/08/26 13:01:18
Should this be an exception, too?
perezju
2015/08/26 13:21:12
This usually means that the app is not installed o
jbudorick
2015/08/26 13:22:51
Seems reasonable.
|
| + for line in output: |
| + line = line.strip() |
| + if line.startswith('versionName='): |
| + return line[len('versionName='):] |
| + raise device_errors.CommandFailedError( |
| + 'Version name for %s not found on dumpsys output' % package, str(self)) |
| + |
| + @decorators.WithTimeoutAndRetriesFromInstance() |
| def GetApplicationDataDirectory(self, package, timeout=None, retries=None): |
| """Get the data directory on the device for the given package. |