Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
4c67885b
Commit
4c67885b
authored
Apr 18, 2018
by
Danny Tuppeny
Committed by
Danny Tuppeny
May 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for launching emulators
parent
4d7c3c77
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
18 deletions
+65
-18
android_emulator.dart
packages/flutter_tools/lib/src/android/android_emulator.dart
+15
-5
emulators.dart
packages/flutter_tools/lib/src/commands/emulators.dart
+42
-13
emulator.dart
packages/flutter_tools/lib/src/emulator.dart
+2
-0
emulator_test.dart
packages/flutter_tools/test/emulator_test.dart
+6
-0
No files found.
packages/flutter_tools/lib/src/android/android_emulator.dart
View file @
4c67885b
...
...
@@ -9,8 +9,10 @@ import 'package:meta/meta.dart';
import
'../android/android_sdk.dart'
;
import
'../android/android_workflow.dart'
;
import
'../base/file_system.dart'
;
import
'../base/logger.dart'
;
import
'../base/process.dart'
;
import
'../emulator.dart'
;
import
'../globals.dart'
;
import
'android_sdk.dart'
;
class
AndroidEmulators
extends
EmulatorDiscovery
{
...
...
@@ -39,11 +41,19 @@ class AndroidEmulator extends Emulator {
@override
String
get
label
=>
_properties
[
'avd.ini.displayname'
];
// @override
// Future<bool> launch() async {
// // TODO: ...
// return null;Í
// }
@override
Future
<
bool
>
launch
()
async
{
final
Status
status
=
logger
.
startProgress
(
'Launching
$id
...'
);
final
RunResult
launchResult
=
await
runAsync
(<
String
>[
getEmulatorPath
(),
'-avd'
,
id
]);
status
.
stop
();
if
(
launchResult
.
exitCode
!=
0
)
{
printError
(
'Error: emulator exited with exit code
${launchResult.exitCode}
'
);
printError
(
'
$launchResult
'
);
return
false
;
}
return
true
;
}
}
/// Return the list of available emulator AVDs.
...
...
packages/flutter_tools/lib/src/commands/emulators.dart
View file @
4c67885b
...
...
@@ -12,6 +12,11 @@ import '../globals.dart';
import
'../runner/flutter_command.dart'
;
class
EmulatorsCommand
extends
FlutterCommand
{
EmulatorsCommand
()
{
argParser
.
addOption
(
'start'
,
help:
'The full or partial ID of the emulator to start.'
);
}
@override
final
String
name
=
'emulators'
;
...
...
@@ -20,23 +25,46 @@ class EmulatorsCommand extends FlutterCommand {
@override
Future
<
Null
>
runCommand
()
async
{
if
(
!
doctor
.
canListAnything
)
{
if
(
doctor
.
workflows
.
every
((
Workflow
w
)
=>
!
w
.
canListEmulators
)
)
{
throwToolExit
(
"Unable to locate
emulators; please run 'flutter doctor' for "
'information about installing additional components.'
,
exitCode:
1
);
"Unable to query
emulators; please run 'flutter doctor' for "
'information about installing additional components.'
,
exitCode:
1
);
}
final
List
<
Emulator
>
emulators
=
await
emulatorManager
.
getAllAvailableEmulators
().
toList
();
if
(
argResults
.
wasParsed
(
'start'
))
{
await
_startEmulator
(
argResults
[
'start'
]);
}
else
{
await
_listEmulators
();
}
}
Future
<
Null
>
_startEmulator
(
String
id
)
async
{
final
List
<
Emulator
>
emulators
=
await
emulatorManager
.
getEmulatorsById
(
id
).
toList
();
if
(
emulators
.
isEmpty
)
{
printStatus
(
'No emulators available.
\n\n
'
// TODO: Change these when we support creation
// 'You may need to create images using "flutter emulators --create"\n'
'You may need to create one using Android Studio
\n
'
'or visit https://flutter.io/setup/ for troubleshooting tips.'
);
final
List
<
String
>
diagnostics
=
await
emulatorManager
.
getEmulatorDiagnostics
();
printStatus
(
"No emulator found that matches the ID '
$id
'."
);
}
else
if
(
emulators
.
length
>
1
)
{
printStatus
(
"More than one emulator matches the ID '
$id
':
\n
"
);
Emulator
.
printEmulators
(
emulators
);
}
else
{
emulators
.
first
.
launch
();
}
}
Future
<
Null
>
_listEmulators
()
async
{
final
List
<
Emulator
>
emulators
=
await
emulatorManager
.
getAllAvailableEmulators
().
toList
();
if
(
emulators
.
isEmpty
)
{
printStatus
(
'No emulators available.
\n\n
'
// TODO: Change these when we support creation
// 'You may need to create images using "flutter emulators --create"\n'
'You may need to create one using Android Studio
\n
'
'or visit https://flutter.io/setup/ for troubleshooting tips.'
);
final
List
<
String
>
diagnostics
=
await
emulatorManager
.
getEmulatorDiagnostics
();
if
(
diagnostics
.
isNotEmpty
)
{
printStatus
(
''
);
for
(
String
diagnostic
in
diagnostics
)
{
...
...
@@ -44,7 +72,8 @@ class EmulatorsCommand extends FlutterCommand {
}
}
}
else
{
printStatus
(
'
${emulators.length}
available
${pluralize('emulators', emulators.length)}
:
\n
'
);
printStatus
(
'
${emulators.length}
available
${pluralize('emulators', emulators.length)}
:
\n
'
);
await
Emulator
.
printEmulators
(
emulators
);
}
}
...
...
packages/flutter_tools/lib/src/emulator.dart
View file @
4c67885b
...
...
@@ -135,6 +135,8 @@ abstract class Emulator {
return
id
==
other
.
id
;
}
void
launch
();
@override
String
toString
()
=>
name
;
...
...
packages/flutter_tools/test/emulator_test.dart
View file @
4c67885b
...
...
@@ -61,4 +61,10 @@ class _MockEmulator extends Emulator {
@override
final
String
label
;
@override
void
launch
()
{
throw
new
UnimplementedError
(
'Not implemented in Mock'
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment