1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2024-10-06 19:01:15 +01:00

ApkWorkload: report correct apk verison on failed install

It's possible that there is already a version of an app on target that
differs form the version of the apk on the host. In such cases, WA will
usually try to uninstall the target version and install the host
version.

It's possible that the uninstall may fail. If that happens, it will be
reported as a warning but workload exectuion will proceed with the
target version. In this case, apk_version would have already been set to
that of the host apk. This change ensures that the APK version is
correctly set to the target version (the one that actually ran).
This commit is contained in:
Sergei Trofimov 2016-04-19 16:04:54 +01:00
parent 91210f26e9
commit 8bc71bb810

View File

@ -222,10 +222,16 @@ class ApkWorkload(Workload):
if self.force_install:
if installed_version:
self.device.uninstall(self.package)
self.install_apk(context)
# It's possible that that the uninstall above fails, which will result in
# install failing and a warning, hower execution would the 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
else:
self.apk_version = installed_version
else:
self.apk_version = installed_version
self.reset(context)
self.apk_version = host_version
def launch_package(self):
if not self.activity:
@ -247,6 +253,7 @@ class ApkWorkload(Workload):
self._grant_requested_permissions()
def install_apk(self, context):
success = False
output = self.device.install(self.apk_file, self.install_timeout)
if 'Failure' in output:
if 'ALREADY_EXISTS' in output:
@ -255,7 +262,9 @@ class ApkWorkload(Workload):
raise WorkloadError(output)
else:
self.logger.debug(output)
success = True
self.do_post_install(context)
return success
def _grant_requested_permissions(self):
dumpsys_output = self.device.execute(command="dumpsys package {}".format(self.package))