Closing application once the task is done

This commit is contained in:
Pavel Shevaev 2023-11-10 15:18:13 +03:00
parent 9249d49d54
commit 33230ba98e
2 changed files with 20 additions and 2 deletions

View File

@ -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);
});
}

View File

@ -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;