Add get_props to adb.py's AndroidDevice.
Saves adb shell roundtrips if multiple properties are needed. Change-Id: I3a9fc0354b6eb0ee5389984e3f345c380404658c
This commit is contained in:
@@ -411,6 +411,22 @@ class AndroidDevice(object):
|
||||
def wait(self):
|
||||
return self._simple_call(['wait-for-device'])
|
||||
|
||||
def get_props(self):
|
||||
result = {}
|
||||
output, _ = self.shell(['getprop'])
|
||||
output = output.splitlines()
|
||||
pattern = re.compile(r'^\[([^]]+)\]: \[(.*)\]')
|
||||
for line in output:
|
||||
match = pattern.match(line)
|
||||
if match is None:
|
||||
raise RuntimeError('invalid getprop line: "{}"'.format(line))
|
||||
key = match.group(1)
|
||||
value = match.group(2)
|
||||
if key in result:
|
||||
raise RuntimeError('duplicate getprop key: "{}"'.format(key))
|
||||
result[key] = value
|
||||
return result
|
||||
|
||||
def get_prop(self, prop_name):
|
||||
output = self.shell(['getprop', prop_name])[0].splitlines()
|
||||
if len(output) != 1:
|
||||
|
||||
Reference in New Issue
Block a user