1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-04-14 23:00:49 +01:00

Merge pull request #169 from ep1cman/buildprop

AndroidDevice: Improved gathering of build props
This commit is contained in:
setrofim 2016-05-24 12:56:22 +01:00
commit 881b7514e2

View File

@ -21,6 +21,7 @@ import time
import tempfile import tempfile
import shutil import shutil
import threading import threading
import json
from subprocess import CalledProcessError from subprocess import CalledProcessError
from wlauto.core.extension import Parameter from wlauto.core.extension import Parameter
@ -508,17 +509,18 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
def _get_android_properties(self, context): def _get_android_properties(self, context):
props = {} props = {}
props['android_id'] = self.get_android_id() props['android_id'] = self.get_android_id()
buildprop_file = os.path.join(context.host_working_directory, 'build.prop') self._update_build_properties(props)
if not os.path.isfile(buildprop_file):
self.pull_file('/system/build.prop', context.host_working_directory)
self._update_build_properties(buildprop_file, props)
context.add_run_artifact('build_properties', buildprop_file, 'export')
dumpsys_target_file = self.path.join(self.working_directory, 'window.dumpsys') dumpsys_target_file = self.path.join(self.working_directory, 'window.dumpsys')
dumpsys_host_file = os.path.join(context.host_working_directory, 'window.dumpsys') dumpsys_host_file = os.path.join(context.host_working_directory, 'window.dumpsys')
self.execute('{} > {}'.format('dumpsys window', dumpsys_target_file)) self.execute('{} > {}'.format('dumpsys window', dumpsys_target_file))
self.pull_file(dumpsys_target_file, dumpsys_host_file) self.pull_file(dumpsys_target_file, dumpsys_host_file)
context.add_run_artifact('dumpsys_window', dumpsys_host_file, 'meta') context.add_run_artifact('dumpsys_window', dumpsys_host_file, 'meta')
prop_file = os.path.join(context.host_working_directory, 'android-props.json')
with open(prop_file, 'w') as wfh:
json.dump(props, wfh)
context.add_run_artifact('android_properties', prop_file, 'export')
return props return props
def getprop(self, prop=None): def getprop(self, prop=None):
@ -667,15 +669,15 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
# Internal methods: do not use outside of the class. # Internal methods: do not use outside of the class.
def _update_build_properties(self, filepath, props): def _update_build_properties(self, props):
try: try:
with open(filepath) as fh: def strip(somestring):
for line in fh: return somestring.strip().replace('[', '').replace(']', '')
line = re.sub(r'#.*', '', line).strip() for line in self.execute("getprop").splitlines():
if not line: key, value = line.split(':', 1)
continue key = strip(key)
key, value = line.split('=', 1) value = strip(value)
props[key] = value props[key] = value
except ValueError: except ValueError:
self.logger.warning('Could not parse build.prop.') self.logger.warning('Could not parse build.prop.')