Expose emulator creation to daemon API (#18905)

* Fix typo

* Add emulator.create to Daemon API

* Swap order of daemon changelog entries
This commit is contained in:
Danny Tuppeny
2018-06-28 14:10:26 +01:00
committed by GitHub
parent a8d97a6dc9
commit 7e4038fe27
3 changed files with 31 additions and 4 deletions

View File

@@ -28,7 +28,7 @@ import '../runner/flutter_command.dart';
import '../tester/flutter_tester.dart';
import '../vmservice.dart';
const String protocolVersion = '0.3.0';
const String protocolVersion = '0.4.0';
/// A server process command. This command will start up a long-lived server.
/// It reads JSON-RPC based commands from stdin, executes them, and returns
@@ -849,6 +849,7 @@ class EmulatorDomain extends Domain {
EmulatorDomain(Daemon daemon) : super(daemon, 'emulator') {
registerHandler('getEmulators', getEmulators);
registerHandler('launch', launch);
registerHandler('create', create);
}
Future<List<Map<String, dynamic>>> getEmulators([Map<String, dynamic> args]) async {
@@ -868,6 +869,16 @@ class EmulatorDomain extends Domain {
await matches.first.launch();
}
}
Future<Map<String, dynamic>> create(Map<String, dynamic> args) async {
final String name = _getStringArg(args, 'name', required: false);
final CreateEmulatorResult res = await emulators.createEmulator(name: name);
return <String, dynamic>{
'success': res.success,
'emulatorName': res.emulatorName,
'error': res.error,
};
}
}
/// A [Logger] which sends log messages to a listening daemon client.

View File

@@ -98,12 +98,15 @@ class EmulatorManager {
// - Removes lines that say "null" (!)
// - Removes lines that tell the user to use '--force' to overwrite emulators
String cleanError(String error) {
return (error ?? '')
if (error == null || error.trim() == '')
return null;
return error
.split('\n')
.where((String l) => l.trim() != 'null')
.where((String l) =>
l.trim() != 'Use --force if you want to replace it.')
.join('\n');
.join('\n')
.trim();
}
final List<String> args = <String>[