1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-10-29 22:24:51 +00:00

Check APK version and ABI when installing

- Check the APK's versionName property against the workload's
  expected version if specified
- If workload specifies check_abi param, try to get APK from
  ABI-specific path on the host
- Add variant_name param to APK resource-getter for backwards
  compatibility of dex2oat and peacekeeper
This commit is contained in:
muendelezaji
2016-06-22 19:34:04 +01:00
parent fab6a977aa
commit bb33123b17
6 changed files with 76 additions and 18 deletions

View File

@@ -362,9 +362,9 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
if ext == '.apk':
flags = []
if replace:
flags.append('-r') # Replace existing APK
flags.append('-r') # Replace existing APK
if self.get_sdk_version() >= 23:
flags.append('-g') # Grant all runtime permissions
flags.append('-g') # Grant all runtime permissions
self.logger.debug("Replace APK = {}, ADB flags = '{}'".format(replace, ' '.join(flags)))
return adb_command(self.adb_name, "install {} '{}'".format(' '.join(flags), filepath), timeout=timeout)
else:

View File

@@ -34,3 +34,10 @@ class JarFile(FileResource):
class ApkFile(FileResource):
name = 'apk'
def __init__(self, owner, platform=None):
super(ApkFile, self).__init__(owner)
self.platform = platform
def __str__(self):
return '<{}\'s {} APK>'.format(self.owner, self.platform)

View File

@@ -20,6 +20,7 @@ import time
from wlauto.core.extension import Parameter
from wlauto.core.workload import Workload
from wlauto.core.resource import NO_ONE
from wlauto.common.android.resources import ApkFile
from wlauto.common.resources import ExtensionAsset, Executable
from wlauto.exceptions import WorkloadError, ResourceError, ConfigError
from wlauto.utils.android import ApkInfo, ANDROID_NORMAL_PERMISSIONS
@@ -160,6 +161,11 @@ class ApkWorkload(Workload):
'''),
Parameter('uninstall_apk', kind=boolean, default=False,
description='If ``True``, will uninstall workload\'s APK as part of teardown.'),
Parameter('check_abi', kind=bool, default=False,
description='''
If ``True``, workload will check that the APK matches the target
device ABI, otherwise any APK found will be used.
'''),
]
def __init__(self, device, _call_super=True, **kwargs):
@@ -169,12 +175,14 @@ class ApkWorkload(Workload):
self.apk_version = None
self.logcat_log = None
def init_resources(self, context):
self.apk_file = context.resolver.get(wlauto.common.android.resources.ApkFile(self),
def initialize(self, context):
# Get APK for the correct version and device ABI
self.apk_file = context.resolver.get(ApkFile(self, self.device.abi),
version=getattr(self, 'version', None),
check_abi=getattr(self, 'check_abi', False),
variant_name=getattr(self, 'variant_name', None),
strict=self.check_apk)
def validate(self):
# Validate the APK
if self.check_apk:
if not self.apk_file:
raise WorkloadError('No APK file found for workload {}.'.format(self.name))
@@ -223,7 +231,7 @@ class ApkWorkload(Workload):
if installed_version:
self.device.uninstall(self.package)
# It's possible that the uninstall above fails, which might result in a warning
# and/or failure during installation. Hower execution should proceed, so need
# and/or failure during installation. However execution should proceed, so need
# to make sure that the right apk_vesion is reported in the end.
if self.install_apk(context):
self.apk_version = host_version