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

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

Issue 787393003: Add access to read-only properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: migrate clients to use properties Created 6 years 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
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 553e9602ffc0a9ebfba319bea746fc460e86b605..ea899abb8e6f549db1edea1d4c62fff3706dcdd5 100644
--- a/build/android/pylib/device/device_utils.py
+++ b/build/android/pylib/device/device_utils.py
@@ -994,11 +994,75 @@ class DeviceUtils(object):
"""
return self.old_interface.SetJavaAssertsEnabled(enabled)
+
+ @property
+ def build_description(self):
+ """Returns the build description of the system.
+
+ For example:
+ hammerhead-userdebug KeyLimePie KFS78N 850839 dev-keys
+ """
+ return self.GetProp('ro.build.description', cache=True)
+
+ @property
+ def build_fingerprint(self):
+ """Returns the build fingerprint of the system.
+
+ For example:
+ google/hammerhead/hammerhead:KeyLimePie/KFS78N/850839:userdebug/dev-keys
+ """
+ return self.GetProp('ro.build.fingerprint', cache=True)
+
+ @property
+ def build_id(self):
+ """Returns the build ID of the system (e.g. 'KFS78N')."""
+ return self.GetProp('ro.build.id', cache=True)
+
+ @property
+ def build_product(self):
+ """Returns the build product of the system (e.g. 'hammerhead')."""
+ return self.GetProp('ro.build.product', cache=True)
+
@property
def build_type(self):
- """Returns the build type of the system (e.g. userdebug)."""
+ """Returns the build type of the system (e.g. 'userdebug')."""
return self.GetProp('ro.build.type', cache=True)
+ @property
+ def build_version_sdk(self):
+ """Returns the build version sdk of the system as a number (e.g. 18).
+
+ For version code numbers see:
+ http://developer.android.com/reference/android/os/Build.VERSION_CODES.html
+
+ For named constants see:
+ pylib.constants.ANDROID_SDK_VERSION_CODES
+
+ Raises:
+ CommandFailedError if the build version sdk is not a number.
+ """
+ value = self.GetProp('ro.build.version.sdk', cache=True)
+ try:
+ return int(value)
+ except ValueError:
+ raise device_errors.CommandFailedError(
+ 'Invalid build version sdk: %r' % value)
perezju 2014/12/10 13:37:34 We attempt to cast to an integer here. This is wha
+
+ @property
+ def product_cpu_abi(self):
+ """Returns the product cpu abi of the device (e.g. 'armeabi-v7a')."""
+ return self.GetProp('ro.product.cpu.abi', cache=True)
+
+ @property
+ def product_model(self):
+ """Returns the name of the product model (e.g. 'Nexus 5')."""
+ return self.GetProp('ro.product.model', cache=True)
+
+ @property
+ def product_name(self):
+ """Returns the product name of the device (e.g. 'hammerhead')."""
+ return self.GetProp('ro.product.name', cache=True)
+
def GetProp(self, property_name, cache=False, timeout=None, retries=None):
"""Gets a property from the device.

Powered by Google App Engine
This is Rietveld 408576698