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

Side by Side 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 unified diff | Download patch
OLDNEW
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=W0613 9 # pylint: disable=W0613
10 10
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 987
988 Returns: 988 Returns:
989 True if the device-side property changed and a restart is required as a 989 True if the device-side property changed and a restart is required as a
990 result, False otherwise. 990 result, False otherwise.
991 991
992 Raises: 992 Raises:
993 CommandTimeoutError on timeout. 993 CommandTimeoutError on timeout.
994 """ 994 """
995 return self.old_interface.SetJavaAssertsEnabled(enabled) 995 return self.old_interface.SetJavaAssertsEnabled(enabled)
996 996
997
998 @property
999 def build_description(self):
1000 """Returns the build description of the system.
1001
1002 For example:
1003 hammerhead-userdebug KeyLimePie KFS78N 850839 dev-keys
1004 """
1005 return self.GetProp('ro.build.description', cache=True)
1006
1007 @property
1008 def build_fingerprint(self):
1009 """Returns the build fingerprint of the system.
1010
1011 For example:
1012 google/hammerhead/hammerhead:KeyLimePie/KFS78N/850839:userdebug/dev-keys
1013 """
1014 return self.GetProp('ro.build.fingerprint', cache=True)
1015
1016 @property
1017 def build_id(self):
1018 """Returns the build ID of the system (e.g. 'KFS78N')."""
1019 return self.GetProp('ro.build.id', cache=True)
1020
1021 @property
1022 def build_product(self):
1023 """Returns the build product of the system (e.g. 'hammerhead')."""
1024 return self.GetProp('ro.build.product', cache=True)
1025
997 @property 1026 @property
998 def build_type(self): 1027 def build_type(self):
999 """Returns the build type of the system (e.g. userdebug).""" 1028 """Returns the build type of the system (e.g. 'userdebug')."""
1000 return self.GetProp('ro.build.type', cache=True) 1029 return self.GetProp('ro.build.type', cache=True)
1001 1030
1031 @property
1032 def build_version_sdk(self):
1033 """Returns the build version sdk of the system as a number (e.g. 18).
1034
1035 For version code numbers see:
1036 http://developer.android.com/reference/android/os/Build.VERSION_CODES.html
1037
1038 For named constants see:
1039 pylib.constants.ANDROID_SDK_VERSION_CODES
1040
1041 Raises:
1042 CommandFailedError if the build version sdk is not a number.
1043 """
1044 value = self.GetProp('ro.build.version.sdk', cache=True)
1045 try:
1046 return int(value)
1047 except ValueError:
1048 raise device_errors.CommandFailedError(
1049 'Invalid build version sdk: %r' % value)
perezju 2014/12/10 13:37:34 We attempt to cast to an integer here. This is wha
1050
1051 @property
1052 def product_cpu_abi(self):
1053 """Returns the product cpu abi of the device (e.g. 'armeabi-v7a')."""
1054 return self.GetProp('ro.product.cpu.abi', cache=True)
1055
1056 @property
1057 def product_model(self):
1058 """Returns the name of the product model (e.g. 'Nexus 5')."""
1059 return self.GetProp('ro.product.model', cache=True)
1060
1061 @property
1062 def product_name(self):
1063 """Returns the product name of the device (e.g. 'hammerhead')."""
1064 return self.GetProp('ro.product.name', cache=True)
1065
1002 def GetProp(self, property_name, cache=False, timeout=None, retries=None): 1066 def GetProp(self, property_name, cache=False, timeout=None, retries=None):
1003 """Gets a property from the device. 1067 """Gets a property from the device.
1004 1068
1005 Args: 1069 Args:
1006 property_name: A string containing the name of the property to get from 1070 property_name: A string containing the name of the property to get from
1007 the device. 1071 the device.
1008 cache: A boolean indicating whether to cache the value of this property. 1072 cache: A boolean indicating whether to cache the value of this property.
1009 timeout: timeout in seconds 1073 timeout: timeout in seconds
1010 retries: number of retries 1074 retries: number of retries
1011 1075
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 Returns: 1254 Returns:
1191 A Parallelizer operating over |devices|. 1255 A Parallelizer operating over |devices|.
1192 """ 1256 """
1193 if not devices or len(devices) == 0: 1257 if not devices or len(devices) == 0:
1194 devices = pylib.android_commands.GetAttachedDevices() 1258 devices = pylib.android_commands.GetAttachedDevices()
1195 parallelizer_type = (parallelizer.Parallelizer if async 1259 parallelizer_type = (parallelizer.Parallelizer if async
1196 else parallelizer.SyncParallelizer) 1260 else parallelizer.SyncParallelizer)
1197 return parallelizer_type([ 1261 return parallelizer_type([
1198 d if isinstance(d, DeviceUtils) else DeviceUtils(d) 1262 d if isinstance(d, DeviceUtils) else DeviceUtils(d)
1199 for d in devices]) 1263 for d in devices])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698