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
e1f476b6
Commit
e1f476b6
authored
Mar 03, 2016
by
Devon Carew
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2378 from devoncarew/refactor_stop
refactor the stop command to not use DeviceStore
parents
0a0f3e7a
d911aaa6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
44 deletions
+65
-44
analyze.dart
packages/flutter_tools/lib/src/commands/analyze.dart
+1
-0
apk.dart
packages/flutter_tools/lib/src/commands/apk.dart
+1
-2
daemon.dart
packages/flutter_tools/lib/src/commands/daemon.dart
+50
-14
drive.dart
packages/flutter_tools/lib/src/commands/drive.dart
+2
-7
stop.dart
packages/flutter_tools/lib/src/commands/stop.dart
+9
-19
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+2
-2
No files found.
packages/flutter_tools/lib/src/commands/analyze.dart
View file @
e1f476b6
...
...
@@ -340,6 +340,7 @@ linter:
printTrace
(
file
);
}
printTrace
(
cmd
.
join
(
' '
));
Process
process
=
await
Process
.
start
(
cmd
[
0
],
cmd
.
sublist
(
1
),
...
...
packages/flutter_tools/lib/src/commands/apk.dart
View file @
e1f476b6
...
...
@@ -449,8 +449,7 @@ Future<int> buildAll(
"consider renaming your 'apk/' directory to 'android/'."
);
}
int
result
=
await
build
(
toolchain
,
configs
,
enginePath:
enginePath
,
target:
target
);
int
result
=
await
build
(
toolchain
,
configs
,
enginePath:
enginePath
,
target:
target
);
if
(
result
!=
0
)
return
result
;
}
...
...
packages/flutter_tools/lib/src/commands/daemon.dart
View file @
e1f476b6
...
...
@@ -7,6 +7,7 @@ import 'dart:convert';
import
'dart:io'
;
import
'../android/android_device.dart'
;
import
'../application_package.dart'
;
import
'../base/context.dart'
;
import
'../base/logger.dart'
;
import
'../device.dart'
;
...
...
@@ -15,7 +16,6 @@ import '../ios/devices.dart';
import
'../ios/simulators.dart'
;
import
'../runner/flutter_command.dart'
;
import
'run.dart'
;
import
'stop.dart'
as
stop
;
const
String
protocolVersion
=
'0.1.0'
;
...
...
@@ -78,9 +78,9 @@ class Daemon {
this
.
notifyingLogger
})
{
// Set up domains.
_registerDomain
(
new
DaemonDomain
(
this
));
_registerDomain
(
new
AppDomain
(
this
));
_registerDomain
(
new
DeviceDomain
(
this
));
_registerDomain
(
daemonDomain
=
new
DaemonDomain
(
this
));
_registerDomain
(
appDomain
=
new
AppDomain
(
this
));
_registerDomain
(
deviceDomain
=
new
DeviceDomain
(
this
));
// Start listening.
commandStream
.
listen
(
...
...
@@ -89,6 +89,10 @@ class Daemon {
);
}
DaemonDomain
daemonDomain
;
AppDomain
appDomain
;
DeviceDomain
deviceDomain
;
final
DispatchComand
sendCommand
;
final
DaemonCommand
daemonCommand
;
final
NotifyingLogger
notifyingLogger
;
...
...
@@ -221,29 +225,30 @@ class DaemonDomain extends Domain {
}
}
/// This domain responds to methods like [start] and [stop
All
].
/// This domain responds to methods like [start] and [stop].
///
/// It'll be extended to fire events for when applications start, stop, and
/// log data.
class
AppDomain
extends
Domain
{
AppDomain
(
Daemon
daemon
)
:
super
(
daemon
,
'app'
)
{
registerHandler
(
'start'
,
start
);
registerHandler
(
'stop
All'
,
stopAll
);
registerHandler
(
'stop
'
,
stop
);
}
Future
<
dynamic
>
start
(
Map
<
String
,
dynamic
>
args
)
async
{
// TODO(devoncarew): We need to be able to specify the target device.
if
(
args
[
'deviceId'
]
is
!
String
)
throw
"A 'deviceId' is required"
;
Device
device
=
await
_getDevice
(
args
[
'deviceId'
]);
if
(
device
==
null
)
throw
"A 'projectDirectory' is required"
;
if
(
args
[
'projectDirectory'
]
is
!
String
)
throw
"A 'projectDirectory' is required"
;
String
projectDirectory
=
args
[
'projectDirectory'
];
if
(!
FileSystemEntity
.
isDirectorySync
(
projectDirectory
))
throw
"The '
$projectDirectory
' does not exist"
;
// We change the current working directory for the duration of the `start`
// command. This would have race conditions with other commands happening in
// parallel and doesn't play well with the caching built into `FlutterCommand`.
// We change the current working directory for the duration of the `start` command.
// TODO(devoncarew): Make flutter_tools work better with commands run from any directory.
Directory
cwd
=
Directory
.
current
;
Directory
.
current
=
new
Directory
(
projectDirectory
);
...
...
@@ -259,6 +264,7 @@ class AppDomain extends Domain {
command
.
applicationPackages
,
command
.
toolchain
,
command
.
buildConfigurations
,
stop:
true
,
target:
args
[
'target'
],
route:
args
[
'route'
],
checked:
args
[
'checked'
]
??
true
...
...
@@ -273,8 +279,38 @@ class AppDomain extends Domain {
return
null
;
}
Future
<
bool
>
stopAll
(
dynamic
args
)
{
return
stop
.
stopAll
(
command
.
devices
,
command
.
applicationPackages
);
Future
<
bool
>
stop
(
dynamic
args
)
async
{
if
(
args
[
'deviceId'
]
is
!
String
)
throw
"A 'deviceId' is required"
;
Device
device
=
await
_getDevice
(
args
[
'deviceId'
]);
if
(
device
==
null
)
throw
"A 'projectDirectory' is required"
;
if
(
args
[
'projectDirectory'
]
is
!
String
)
throw
"A 'projectDirectory' is required"
;
String
projectDirectory
=
args
[
'projectDirectory'
];
if
(!
FileSystemEntity
.
isDirectorySync
(
projectDirectory
))
throw
"The '
$projectDirectory
' does not exist"
;
Directory
cwd
=
Directory
.
current
;
Directory
.
current
=
new
Directory
(
projectDirectory
);
try
{
await
Future
.
wait
([
command
.
downloadToolchain
(),
command
.
downloadApplicationPackages
(),
],
eagerError:
true
);
ApplicationPackage
app
=
command
.
applicationPackages
.
getPackageForPlatform
(
device
.
platform
);
return
device
.
stopApp
(
app
);
}
finally
{
Directory
.
current
=
cwd
;
}
}
Future
<
Device
>
_getDevice
(
String
deviceId
)
async
{
List
<
Device
>
devices
=
await
daemon
.
deviceDomain
.
getDevices
();
return
devices
.
firstWhere
((
Device
device
)
=>
device
.
id
==
deviceId
,
orElse:
()
=>
null
);
}
}
...
...
@@ -312,7 +348,7 @@ class DeviceDomain extends Domain {
List
<
PollingDeviceDiscovery
>
_discoverers
=
<
PollingDeviceDiscovery
>[];
Future
<
List
<
Device
>>
getDevices
(
dynamic
args
)
{
Future
<
List
<
Device
>>
getDevices
(
[
dynamic
args
]
)
{
List
<
Device
>
devices
=
_discoverers
.
expand
((
PollingDeviceDiscovery
discoverer
)
{
return
discoverer
.
devices
;
}).
toList
();
...
...
packages/flutter_tools/lib/src/commands/drive.dart
View file @
e1f476b6
...
...
@@ -7,17 +7,16 @@ import 'dart:async';
import
'package:path/path.dart'
as
path
;
import
'package:test/src/executable.dart'
as
executable
;
import
'../android/android_device.dart'
show
AndroidDevice
;
import
'../application_package.dart'
;
import
'../base/common.dart'
;
import
'../base/file_system.dart'
;
import
'../base/os.dart'
;
import
'../device.dart'
;
import
'../globals.dart'
;
import
'../ios/simulators.dart'
show
SimControl
,
IOSSimulatorUtils
;
import
'../android/android_device.dart'
show
AndroidDevice
;
import
'../application_package.dart'
;
import
'apk.dart'
as
apk
;
import
'run.dart'
;
import
'stop.dart'
;
/// Runs integration (a.k.a. end-to-end) tests.
///
...
...
@@ -126,10 +125,6 @@ class DriveCommand extends RunCommandBase {
}
}
Future
<
int
>
stop
()
async
{
return
await
stopAll
(
devices
,
applicationPackages
)
?
0
:
2
;
}
String
_getTestFile
()
{
String
appFile
=
path
.
normalize
(
target
);
...
...
packages/flutter_tools/lib/src/commands/stop.dart
View file @
e1f476b6
...
...
@@ -6,31 +6,21 @@ import 'dart:async';
import
'../application_package.dart'
;
import
'../device.dart'
;
import
'../globals.dart'
;
import
'../runner/flutter_command.dart'
;
class
StopCommand
extends
FlutterCommand
{
final
String
name
=
'stop'
;
final
String
description
=
'Stop your Flutter app on all attached devices.'
;
final
String
description
=
'Stop your Flutter app on an attached device.'
;
bool
get
requiresDevice
=>
true
;
@override
Future
<
int
>
runInProject
()
async
{
await
downloadApplicationPackagesAndConnectToDevices
();
return
await
stop
()
?
0
:
2
;
await
downloadApplicationPackages
();
Device
device
=
deviceForCommand
;
ApplicationPackage
app
=
applicationPackages
.
getPackageForPlatform
(
device
.
platform
);
printStatus
(
'Stopping apps on
${device.name}
.'
);
return
await
device
.
stopApp
(
app
)
?
0
:
1
;
}
Future
<
bool
>
stop
()
=>
stopAll
(
devices
,
applicationPackages
);
}
Future
<
bool
>
stopAll
(
DeviceStore
devices
,
ApplicationPackageStore
applicationPackages
)
async
{
bool
stoppedSomething
=
false
;
for
(
Device
device
in
devices
.
all
)
{
ApplicationPackage
package
=
applicationPackages
.
getPackageForPlatform
(
device
.
platform
);
if
(
package
==
null
)
continue
;
if
(
await
device
.
stopApp
(
package
))
stoppedSomething
=
true
;
}
return
stoppedSomething
;
}
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
e1f476b6
...
...
@@ -35,11 +35,11 @@ abstract class FlutterCommand extends Command {
}
Future
downloadApplicationPackagesAndConnectToDevices
()
async
{
await
_
downloadApplicationPackages
();
await
downloadApplicationPackages
();
_connectToDevices
();
}
Future
_
downloadApplicationPackages
()
async
{
Future
downloadApplicationPackages
()
async
{
applicationPackages
??=
await
ApplicationPackageStore
.
forConfigs
(
buildConfigurations
);
}
...
...
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