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:
parent
a8d97a6dc9
commit
7e4038fe27
@ -188,10 +188,22 @@ Return a list of all available emulators. The `params` field will be a List; eac
|
|||||||
|
|
||||||
#### emulator.launch
|
#### emulator.launch
|
||||||
|
|
||||||
The `launch()` command takes allows launching an emulator/simulator by its `id`.
|
The `launch()` command allows launching an emulator/simulator by its `id`.
|
||||||
|
|
||||||
- `emulatorId`: the id of an emulator as returned by `getEmulators`.
|
- `emulatorId`: the id of an emulator as returned by `getEmulators`.
|
||||||
|
|
||||||
|
#### emulator.create
|
||||||
|
|
||||||
|
The `create()` command creates a new Android emulator with an optional `name`.
|
||||||
|
|
||||||
|
- `name`: an optional name for this emulator
|
||||||
|
|
||||||
|
The returned `params` will contain:
|
||||||
|
|
||||||
|
- `success` - whether the emulator was successfully created
|
||||||
|
- `emulatorName` - the name of the emulator created; this will have been auto-generated if you did not supply one
|
||||||
|
- `error` - when `success`=`false`, a message explaining why the creation of the emulator failed
|
||||||
|
|
||||||
## Flutter Run --machine
|
## Flutter Run --machine
|
||||||
|
|
||||||
When running `flutter run --machine` the following subset of the daemon is available:
|
When running `flutter run --machine` the following subset of the daemon is available:
|
||||||
@ -229,4 +241,5 @@ See the [source](https://github.com/flutter/flutter/blob/master/packages/flutter
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
- 0.4.0: Added `emulator.create` command
|
||||||
- 0.3.0: Added `daemon.connected` event at startup
|
- 0.3.0: Added `daemon.connected` event at startup
|
||||||
|
@ -28,7 +28,7 @@ import '../runner/flutter_command.dart';
|
|||||||
import '../tester/flutter_tester.dart';
|
import '../tester/flutter_tester.dart';
|
||||||
import '../vmservice.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.
|
/// 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
|
/// 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') {
|
EmulatorDomain(Daemon daemon) : super(daemon, 'emulator') {
|
||||||
registerHandler('getEmulators', getEmulators);
|
registerHandler('getEmulators', getEmulators);
|
||||||
registerHandler('launch', launch);
|
registerHandler('launch', launch);
|
||||||
|
registerHandler('create', create);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Map<String, dynamic>>> getEmulators([Map<String, dynamic> args]) async {
|
Future<List<Map<String, dynamic>>> getEmulators([Map<String, dynamic> args]) async {
|
||||||
@ -868,6 +869,16 @@ class EmulatorDomain extends Domain {
|
|||||||
await matches.first.launch();
|
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.
|
/// A [Logger] which sends log messages to a listening daemon client.
|
||||||
|
@ -98,12 +98,15 @@ class EmulatorManager {
|
|||||||
// - Removes lines that say "null" (!)
|
// - Removes lines that say "null" (!)
|
||||||
// - Removes lines that tell the user to use '--force' to overwrite emulators
|
// - Removes lines that tell the user to use '--force' to overwrite emulators
|
||||||
String cleanError(String error) {
|
String cleanError(String error) {
|
||||||
return (error ?? '')
|
if (error == null || error.trim() == '')
|
||||||
|
return null;
|
||||||
|
return error
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.where((String l) => l.trim() != 'null')
|
.where((String l) => l.trim() != 'null')
|
||||||
.where((String l) =>
|
.where((String l) =>
|
||||||
l.trim() != 'Use --force if you want to replace it.')
|
l.trim() != 'Use --force if you want to replace it.')
|
||||||
.join('\n');
|
.join('\n')
|
||||||
|
.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<String> args = <String>[
|
final List<String> args = <String>[
|
||||||
|
Loading…
x
Reference in New Issue
Block a user