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

Unified Diff: build/android/pylib/device/device_utils.py

Issue 1315603002: [Android] Add DeviceUtils.GetApplicationVersion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698