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 <Hidenori.Matsubayashi@gmail.com>
This commit is contained in:
committed by
GitHub
parent
2f83e0844e
commit
a957327203
@@ -255,6 +255,21 @@ class ELinuxDevice extends Device {
|
|||||||
{String? userIdentifier}) async {
|
{String? userIdentifier}) async {
|
||||||
_maybeUnforwardPort();
|
_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;
|
bool succeeded = true;
|
||||||
// Walk a copy of _runningProcesses, since the exit handler removes from the
|
// Walk a copy of _runningProcesses, since the exit handler removes from the
|
||||||
// set.
|
// set.
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ class ELinuxRemoteDeviceConfig {
|
|||||||
required this.installCommand,
|
required this.installCommand,
|
||||||
required this.uninstallCommand,
|
required this.uninstallCommand,
|
||||||
required this.runDebugCommand,
|
required this.runDebugCommand,
|
||||||
|
this.stopAppCommand = const <String>[],
|
||||||
this.forwardPortCommand,
|
this.forwardPortCommand,
|
||||||
this.forwardPortSuccessRegex,
|
this.forwardPortSuccessRegex,
|
||||||
this.screenshotCommand})
|
this.screenshotCommand})
|
||||||
@@ -133,6 +134,7 @@ class ELinuxRemoteDeviceConfig {
|
|||||||
runDebugCommand: _castStringList(
|
runDebugCommand: _castStringList(
|
||||||
typedMap[_kRunDebugCommand], _kRunDebugCommand, 'array of strings with at least one element',
|
typedMap[_kRunDebugCommand], _kRunDebugCommand, 'array of strings with at least one element',
|
||||||
minLength: 1),
|
minLength: 1),
|
||||||
|
stopAppCommand: _castStringList(typedMap[_kStopAppCommand], _kStopAppCommand, 'array of strings with at least one element', minLength: 1),
|
||||||
forwardPortCommand: forwardPortCommand,
|
forwardPortCommand: forwardPortCommand,
|
||||||
forwardPortSuccessRegex: forwardPortSuccessRegex,
|
forwardPortSuccessRegex: forwardPortSuccessRegex,
|
||||||
screenshotCommand: _castStringListOrNull(typedMap[_kScreenshotCommand], _kScreenshotCommand, 'array of strings with at least one element', minLength: 1));
|
screenshotCommand: _castStringListOrNull(typedMap[_kScreenshotCommand], _kScreenshotCommand, 'array of strings with at least one element', minLength: 1));
|
||||||
@@ -150,6 +152,7 @@ class ELinuxRemoteDeviceConfig {
|
|||||||
static const String _kInstallCommand = 'install';
|
static const String _kInstallCommand = 'install';
|
||||||
static const String _kUninstallCommand = 'uninstall';
|
static const String _kUninstallCommand = 'uninstall';
|
||||||
static const String _kRunDebugCommand = 'runDebug';
|
static const String _kRunDebugCommand = 'runDebug';
|
||||||
|
static const String _kStopAppCommand = 'stopApp';
|
||||||
static const String _kForwardPortCommand = 'forwardPort';
|
static const String _kForwardPortCommand = 'forwardPort';
|
||||||
static const String _kForwardPortSuccessRegex = 'forwardPortSuccessRegex';
|
static const String _kForwardPortSuccessRegex = 'forwardPortSuccessRegex';
|
||||||
static const String _kScreenshotCommand = 'screenshot';
|
static const String _kScreenshotCommand = 'screenshot';
|
||||||
@@ -166,6 +169,7 @@ class ELinuxRemoteDeviceConfig {
|
|||||||
final List<String> installCommand;
|
final List<String> installCommand;
|
||||||
final List<String> uninstallCommand;
|
final List<String> uninstallCommand;
|
||||||
final List<String> runDebugCommand;
|
final List<String> runDebugCommand;
|
||||||
|
final List<String> stopAppCommand;
|
||||||
final List<String>? forwardPortCommand;
|
final List<String>? forwardPortCommand;
|
||||||
final RegExp? forwardPortSuccessRegex;
|
final RegExp? forwardPortSuccessRegex;
|
||||||
final List<String>? screenshotCommand;
|
final List<String>? screenshotCommand;
|
||||||
@@ -292,6 +296,7 @@ class ELinuxRemoteDeviceConfig {
|
|||||||
_kInstallCommand: installCommand,
|
_kInstallCommand: installCommand,
|
||||||
_kUninstallCommand: uninstallCommand,
|
_kUninstallCommand: uninstallCommand,
|
||||||
_kRunDebugCommand: runDebugCommand,
|
_kRunDebugCommand: runDebugCommand,
|
||||||
|
_kStopAppCommand: stopAppCommand,
|
||||||
_kForwardPortCommand: forwardPortCommand,
|
_kForwardPortCommand: forwardPortCommand,
|
||||||
_kForwardPortSuccessRegex: forwardPortSuccessRegex?.pattern,
|
_kForwardPortSuccessRegex: forwardPortSuccessRegex?.pattern,
|
||||||
_kScreenshotCommand: screenshotCommand,
|
_kScreenshotCommand: screenshotCommand,
|
||||||
@@ -313,6 +318,7 @@ class ELinuxRemoteDeviceConfig {
|
|||||||
_listsEqual(other.installCommand, installCommand) &&
|
_listsEqual(other.installCommand, installCommand) &&
|
||||||
_listsEqual(other.uninstallCommand, uninstallCommand) &&
|
_listsEqual(other.uninstallCommand, uninstallCommand) &&
|
||||||
_listsEqual(other.runDebugCommand, runDebugCommand) &&
|
_listsEqual(other.runDebugCommand, runDebugCommand) &&
|
||||||
|
_listsEqual(other.stopAppCommand, stopAppCommand) &&
|
||||||
_listsEqual(other.forwardPortCommand, forwardPortCommand) &&
|
_listsEqual(other.forwardPortCommand, forwardPortCommand) &&
|
||||||
_regexesEqual(other.forwardPortSuccessRegex, forwardPortSuccessRegex) &&
|
_regexesEqual(other.forwardPortSuccessRegex, forwardPortSuccessRegex) &&
|
||||||
_listsEqual(other.screenshotCommand, screenshotCommand);
|
_listsEqual(other.screenshotCommand, screenshotCommand);
|
||||||
@@ -332,6 +338,7 @@ class ELinuxRemoteDeviceConfig {
|
|||||||
installCommand.hashCode ^
|
installCommand.hashCode ^
|
||||||
uninstallCommand.hashCode ^
|
uninstallCommand.hashCode ^
|
||||||
runDebugCommand.hashCode ^
|
runDebugCommand.hashCode ^
|
||||||
|
stopAppCommand.hashCode ^
|
||||||
forwardPortCommand.hashCode ^
|
forwardPortCommand.hashCode ^
|
||||||
(forwardPortSuccessRegex?.pattern).hashCode ^
|
(forwardPortSuccessRegex?.pattern).hashCode ^
|
||||||
screenshotCommand.hashCode;
|
screenshotCommand.hashCode;
|
||||||
@@ -352,6 +359,7 @@ class ELinuxRemoteDeviceConfig {
|
|||||||
'installCommand: $installCommand, '
|
'installCommand: $installCommand, '
|
||||||
'uninstallCommand: $uninstallCommand, '
|
'uninstallCommand: $uninstallCommand, '
|
||||||
'runDebugCommand: $runDebugCommand, '
|
'runDebugCommand: $runDebugCommand, '
|
||||||
|
'stopAppCommand: $stopAppCommand, '
|
||||||
'forwardPortCommand: $forwardPortCommand, '
|
'forwardPortCommand: $forwardPortCommand, '
|
||||||
'forwardPortSuccessRegex: $forwardPortSuccessRegex, '
|
'forwardPortSuccessRegex: $forwardPortSuccessRegex, '
|
||||||
'screenshotCommand: $screenshotCommand)';
|
'screenshotCommand: $screenshotCommand)';
|
||||||
|
|||||||
Reference in New Issue
Block a user