custom-device: add customizable stopApp command (#202)

This change adds `stopApp` command to custom-devices json file to quit flutter app from host PC remotely.

Fixed #157

Signed-off-by: Hidenori Matsubayashi <[email protected]>
This commit is contained in:
Hidenori Matsubayashi
2023-08-16 01:24:35 +00:00
committed by GitHub
parent 2f83e0844e
commit a957327203
2 changed files with 23 additions and 0 deletions
+15
View File
@@ -255,6 +255,21 @@ class ELinuxDevice extends Device {
{String? userIdentifier}) async {
_maybeUnforwardPort();
// Stop app for remote devices.
if (!_desktop && _config!.stopAppCommand.isNotEmpty) {
final List<String> interpolated = interpolateCommand(
_config!.stopAppCommand, <String, String>{'appName': app!.name!});
try {
_logger.printStatus('Stop ${app.name!} for custom device.');
await _processUtils.run(interpolated,
throwOnError: true, timeout: const Duration(seconds: 10));
_logger.printStatus('Stop Success.');
} on ProcessException catch (e) {
_logger.printError(
'Error executing Stop app command for custom device $id: $e');
}
}
bool succeeded = true;
// Walk a copy of _runningProcesses, since the exit handler removes from the
// set.