Skip to content

Commit d9983e1

Browse files
authored
Add category/platformType to emulators (flutter#34721)
1 parent b798b27 commit d9983e1

File tree

7 files changed

+33
-3
lines changed

7 files changed

+33
-3
lines changed

packages/flutter_tools/doc/daemon.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ This is sent when a device is disconnected (and polling has been enabled via `en
199199

200200
#### emulator.getEmulators
201201

202-
Return a list of all available emulators. The `params` field will be a List; each item is a map with the fields `id` and `name`.
202+
Return a list of all available emulators. The `params` field will be a List; each item is a map with the fields `id`, `name`, `category` and `platformType`. `category` and `platformType` values match the values described in `device.getDevices`.
203203

204204
#### emulator.launch
205205

@@ -258,7 +258,8 @@ See the [source](https://github.com/flutter/flutter/blob/master/packages/flutter
258258

259259
## Changelog
260260

261-
- 0.5.1: Added `platformType`, `ephemeral`, and `category` field to device.
261+
- 0.5.2: Added `platformType` and `category` fields to emulator.
262+
- 0.5.1: Added `platformType`, `ephemeral`, and `category` fields to device.
262263
- 0.5.0: Added `daemon.getSupportedPlatforms` command
263264
- 0.4.2: Added `app.detach` command
264265
- 0.4.1: Added `flutter attach --machine`

packages/flutter_tools/lib/src/android/android_emulator.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import '../android/android_workflow.dart';
1111
import '../base/file_system.dart';
1212
import '../base/io.dart';
1313
import '../base/process_manager.dart';
14+
import '../device.dart';
1415
import '../emulator.dart';
1516
import 'android_sdk.dart';
1617

@@ -40,6 +41,12 @@ class AndroidEmulator extends Emulator {
4041
@override
4142
String get label => _prop('avd.ini.displayname');
4243

44+
@override
45+
Category get category => Category.mobile;
46+
47+
@override
48+
PlatformType get platformType => PlatformType.android;
49+
4350
String _prop(String name) => _properties != null ? _properties[name] : null;
4451

4552
@override

packages/flutter_tools/lib/src/commands/daemon.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import '../run_hot.dart';
2626
import '../runner/flutter_command.dart';
2727
import '../vmservice.dart';
2828

29-
const String protocolVersion = '0.5.1';
29+
const String protocolVersion = '0.5.2';
3030

3131
/// A server process command. This command will start up a long-lived server.
3232
/// It reads JSON-RPC based commands from stdin, executes them, and returns
@@ -783,6 +783,8 @@ Map<String, dynamic> _emulatorToMap(Emulator emulator) {
783783
return <String, dynamic>{
784784
'id': emulator.id,
785785
'name': emulator.name,
786+
'category': emulator.category?.toString(),
787+
'platformType': emulator.platformType?.toString(),
786788
};
787789
}
788790

packages/flutter_tools/lib/src/emulator.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import 'android/android_sdk.dart';
1010
import 'base/context.dart';
1111
import 'base/io.dart' show ProcessResult;
1212
import 'base/process_manager.dart';
13+
import 'device.dart';
1314
import 'globals.dart';
1415
import 'ios/ios_emulators.dart';
1516

@@ -218,6 +219,8 @@ abstract class Emulator {
218219
String get name;
219220
String get manufacturer;
220221
String get label;
222+
Category get category;
223+
PlatformType get platformType;
221224

222225
@override
223226
int get hashCode => id.hashCode;

packages/flutter_tools/lib/src/ios/ios_emulators.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'dart:async';
66

77
import '../base/platform.dart';
88
import '../base/process.dart';
9+
import '../device.dart';
910
import '../emulator.dart';
1011
import '../globals.dart';
1112
import '../macos/xcode.dart';
@@ -34,6 +35,12 @@ class IOSEmulator extends Emulator {
3435
@override
3536
String get label => null;
3637

38+
@override
39+
Category get category => Category.mobile;
40+
41+
@override
42+
PlatformType get platformType => PlatformType.ios;
43+
3744
@override
3845
Future<void> launch() async {
3946
Future<bool> launchSimulator(List<String> additionalArgs) async {

packages/flutter_tools/test/android/android_emulator_test.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// found in the LICENSE file.
44

55
import 'package:flutter_tools/src/android/android_emulator.dart';
6+
import 'package:flutter_tools/src/device.dart';
67

78
import '../src/common.dart';
89
import '../src/context.dart';
@@ -38,6 +39,8 @@ void main() {
3839
expect(emulator.name, name);
3940
expect(emulator.manufacturer, manufacturer);
4041
expect(emulator.label, label);
42+
expect(emulator.category, Category.mobile);
43+
expect(emulator.platformType, PlatformType.android);
4144
});
4245
testUsingContext('parses ini files', () {
4346
const String iniFile = '''

packages/flutter_tools/test/emulator_test.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:collection/collection.dart' show ListEquality;
99
import 'package:flutter_tools/src/android/android_sdk.dart';
1010
import 'package:flutter_tools/src/base/config.dart';
1111
import 'package:flutter_tools/src/base/io.dart';
12+
import 'package:flutter_tools/src/device.dart';
1213
import 'package:flutter_tools/src/emulator.dart';
1314
import 'package:flutter_tools/src/ios/ios_emulators.dart';
1415
import 'package:flutter_tools/src/macos/xcode.dart';
@@ -171,6 +172,12 @@ class _MockEmulator extends Emulator {
171172
@override
172173
final String label;
173174

175+
@override
176+
Category get category => Category.mobile;
177+
178+
@override
179+
PlatformType get platformType => PlatformType.android;
180+
174181
@override
175182
Future<void> launch() {
176183
throw UnimplementedError('Not implemented in Mock');

0 commit comments

Comments
 (0)