From 33230ba98e4d26bba6c9e724dd02c7f9c7f9f364 Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Fri, 10 Nov 2023 15:18:13 +0300 Subject: [PATCH] Closing application once the task is done --- atf.inc.php | 18 ++++++++++++++++-- plan.inc.php | 4 ++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/atf.inc.php b/atf.inc.php index bfd2677..2cdcff8 100644 --- a/atf.inc.php +++ b/atf.inc.php @@ -179,14 +179,28 @@ function get_ext_status_async(string $atf_host, string $device, int $timeout = 2 }); } +function stop_app_async(string $atf_host, string $device) : Amp\Promise +{ + return Amp\call(function() use($atf_host, $device) { + yield host_exec_async($atf_host, "%{adb}% -s $device shell am force-stop %{package_id}%", DEPLOY_OPT_ERR_OK, 30); + }); +} + +function start_app_async(string $atf_host, string $device) : Amp\Promise +{ + return Amp\call(function() use($atf_host, $device) { + yield host_exec_async($atf_host, "%{adb}% -s $device shell am start -n %{package_id}%/%{activity}%", 0, 30); + }); +} + function start_ext_cmd_on_device_async(string $atf_host, string $device, Cmd $cmd, array $cmd_args) : Amp\Promise { return Amp\call(function() use($atf_host, $device, $cmd, $cmd_args) { yield device_del_file_async($atf_host, $device, 'atf_status.js', DEPLOY_OPT_ERR_OK); - yield host_exec_async($atf_host, "%{adb}% -s $device shell am force-stop %{package_id}%", DEPLOY_OPT_ERR_OK, 30); + yield stop_app_async($atf_host, $device); yield update_ext_cmd_async($atf_host, $device, $cmd, $cmd_args); - yield host_exec_async($atf_host, "%{adb}% -s $device shell am start -n %{package_id}%/%{activity}%", 0, 30); + yield start_app_async($atf_host, $device); }); } diff --git a/plan.inc.php b/plan.inc.php index adf09c4..16a30c2 100644 --- a/plan.inc.php +++ b/plan.inc.php @@ -277,6 +277,10 @@ class Plan { //let's reset bogus stats for this device $this->session->resetBogusDeviceCount($task->device); + + //let's quit the application once the task is done + yield stop_app_async($this->session->conf->atf_host, $task->device); + //let's free the device $task->device = null; break;