1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-09-01 19:02:31 +01:00

AndroidDevice: Improved gathering of build props

These are now gathered via `getprop` rather than trying to parse the
build.prop file directly.

This fixes issues with build.prop files that have imports.
This commit is contained in:
Sebastian Goscik
2016-05-24 11:27:29 +01:00
parent eaf4d02aea
commit 17fe6c9a5b

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.')