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
c584a5ea
Unverified
Commit
c584a5ea
authored
Dec 22, 2021
by
Jenn Magder
Committed by
GitHub
Dec 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate fuchsia_device to null safety (#95438)
parent
38cffc9c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
131 additions
and
137 deletions
+131
-137
fuchsia_build.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_build.dart
+16
-17
fuchsia_device.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
+90
-91
pkgctl.dart
packages/flutter_tools/lib/src/fuchsia/pkgctl.dart
+0
-2
session_control.dart
packages/flutter_tools/lib/src/fuchsia/session_control.dart
+0
-2
tiles_ctl.dart
packages/flutter_tools/lib/src/fuchsia/tiles_ctl.dart
+8
-8
fuchsia_device_test.dart
...tools/test/general.shard/fuchsia/fuchsia_device_test.dart
+17
-17
No files found.
packages/flutter_tools/lib/src/fuchsia/fuchsia_build.dart
View file @
c584a5ea
...
@@ -2,10 +2,6 @@
...
@@ -2,10 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:meta/meta.dart'
;
import
'../artifacts.dart'
;
import
'../artifacts.dart'
;
import
'../asset.dart'
;
import
'../asset.dart'
;
import
'../base/common.dart'
;
import
'../base/common.dart'
;
...
@@ -45,12 +41,13 @@ Future<void> _validateCmxFile(FuchsiaProject fuchsiaProject) async {
...
@@ -45,12 +41,13 @@ Future<void> _validateCmxFile(FuchsiaProject fuchsiaProject) async {
// 3. Using these manifests, use the Fuchsia SDK 'pm' tool to create the
// 3. Using these manifests, use the Fuchsia SDK 'pm' tool to create the
// Fuchsia package.
// Fuchsia package.
Future
<
void
>
buildFuchsia
({
Future
<
void
>
buildFuchsia
({
@
required
FuchsiaProject
fuchsiaProject
,
required
FuchsiaProject
fuchsiaProject
,
@
required
TargetPlatform
targetPlatform
,
required
TargetPlatform
targetPlatform
,
@required
String
target
,
// E.g., lib/main.dart
String
?
target
,
// E.g., lib/main.dart
BuildInfo
buildInfo
=
BuildInfo
.
debug
,
BuildInfo
buildInfo
=
BuildInfo
.
debug
,
String
runnerPackageSource
=
FuchsiaPackageServer
.
toolHost
,
String
runnerPackageSource
=
FuchsiaPackageServer
.
toolHost
,
})
async
{
})
async
{
final
String
targetPath
=
target
??=
'lib/main.dart'
;
await
_validateCmxFile
(
fuchsiaProject
);
await
_validateCmxFile
(
fuchsiaProject
);
final
Directory
outDir
=
globals
.
fs
.
directory
(
getFuchsiaBuildDirectory
());
final
Directory
outDir
=
globals
.
fs
.
directory
(
getFuchsiaBuildDirectory
());
if
(!
outDir
.
existsSync
())
{
if
(!
outDir
.
existsSync
())
{
...
@@ -58,18 +55,18 @@ Future<void> buildFuchsia({
...
@@ -58,18 +55,18 @@ Future<void> buildFuchsia({
}
}
await
_timedBuildStep
(
'fuchsia-kernel-compile'
,
await
_timedBuildStep
(
'fuchsia-kernel-compile'
,
()
=>
fuchsiaSdk
.
fuchsiaKernelCompiler
.
build
(
()
=>
fuchsiaSdk
!
.
fuchsiaKernelCompiler
.
build
(
fuchsiaProject:
fuchsiaProject
,
target:
target
,
buildInfo:
buildInfo
));
fuchsiaProject:
fuchsiaProject
,
target:
target
Path
,
buildInfo:
buildInfo
));
if
(
buildInfo
.
usesAot
)
{
if
(
buildInfo
.
usesAot
)
{
await
_timedBuildStep
(
'fuchsia-gen-snapshot'
,
await
_timedBuildStep
(
'fuchsia-gen-snapshot'
,
()
=>
_genSnapshot
(
fuchsiaProject
,
target
,
buildInfo
,
targetPlatform
));
()
=>
_genSnapshot
(
fuchsiaProject
,
target
Path
,
buildInfo
,
targetPlatform
));
}
}
await
_timedBuildStep
(
'fuchsia-build-assets'
,
await
_timedBuildStep
(
'fuchsia-build-assets'
,
()
=>
_buildAssets
(
fuchsiaProject
,
target
,
buildInfo
));
()
=>
_buildAssets
(
fuchsiaProject
,
target
Path
,
buildInfo
));
await
_timedBuildStep
(
'fuchsia-build-package'
,
await
_timedBuildStep
(
'fuchsia-build-package'
,
()
=>
_buildPackage
(
fuchsiaProject
,
target
,
buildInfo
,
runnerPackageSource
));
()
=>
_buildPackage
(
fuchsiaProject
,
target
Path
,
buildInfo
,
runnerPackageSource
));
}
}
Future
<
void
>
_genSnapshot
(
Future
<
void
>
_genSnapshot
(
...
@@ -84,7 +81,7 @@ Future<void> _genSnapshot(
...
@@ -84,7 +81,7 @@ Future<void> _genSnapshot(
final
String
elf
=
globals
.
fs
.
path
.
join
(
outDir
,
'elf.aotsnapshot'
);
final
String
elf
=
globals
.
fs
.
path
.
join
(
outDir
,
'elf.aotsnapshot'
);
final
String
genSnapshot
=
globals
.
artifacts
.
getArtifactPath
(
final
String
genSnapshot
=
globals
.
artifacts
!
.
getArtifactPath
(
Artifact
.
genSnapshot
,
Artifact
.
genSnapshot
,
platform:
targetPlatform
,
platform:
targetPlatform
,
mode:
buildInfo
.
mode
,
mode:
buildInfo
.
mode
,
...
@@ -118,7 +115,7 @@ Future<void> _buildAssets(
...
@@ -118,7 +115,7 @@ Future<void> _buildAssets(
BuildInfo
buildInfo
,
BuildInfo
buildInfo
,
)
async
{
)
async
{
final
String
assetDir
=
getAssetBuildDirectory
();
final
String
assetDir
=
getAssetBuildDirectory
();
final
AssetBundle
assets
=
await
buildAssets
(
final
AssetBundle
?
assets
=
await
buildAssets
(
manifestPath:
fuchsiaProject
.
project
.
pubspecFile
.
path
,
manifestPath:
fuchsiaProject
.
project
.
pubspecFile
.
path
,
packagesPath:
fuchsiaProject
.
project
.
packagesFile
.
path
,
packagesPath:
fuchsiaProject
.
project
.
packagesFile
.
path
,
assetDirPath:
assetDir
,
assetDirPath:
assetDir
,
...
@@ -148,7 +145,7 @@ Future<void> _buildAssets(
...
@@ -148,7 +145,7 @@ Future<void> _buildAssets(
}
}
void
_rewriteCmx
(
BuildMode
mode
,
String
runnerPackageSource
,
File
src
,
File
dst
)
{
void
_rewriteCmx
(
BuildMode
mode
,
String
runnerPackageSource
,
File
src
,
File
dst
)
{
final
Map
<
String
,
dynamic
>
cmx
=
castStringKeyedMap
(
json
.
decode
(
src
.
readAsStringSync
()))
;
final
Map
<
String
,
Object
?>
cmx
=
castStringKeyedMap
(
json
.
decode
(
src
.
readAsStringSync
()))
??
<
String
,
Object
?>{}
;
// If the app author has already specified the runner in the cmx file, then
// If the app author has already specified the runner in the cmx file, then
// do not override it with something else.
// do not override it with something else.
if
(
cmx
.
containsKey
(
'runner'
))
{
if
(
cmx
.
containsKey
(
'runner'
))
{
...
@@ -171,7 +168,6 @@ void _rewriteCmx(BuildMode mode, String runnerPackageSource, File src, File dst)
...
@@ -171,7 +168,6 @@ void _rewriteCmx(BuildMode mode, String runnerPackageSource, File src, File dst)
break
;
break
;
default
:
default
:
throwToolExit
(
'Fuchsia does not support build mode "
$mode
"'
);
throwToolExit
(
'Fuchsia does not support build mode "
$mode
"'
);
break
;
}
}
cmx
[
'runner'
]
=
'fuchsia-pkg://
$runnerPackageSource
/
$runner
#meta/
$runner
.cmx'
;
cmx
[
'runner'
]
=
'fuchsia-pkg://
$runnerPackageSource
/
$runner
#meta/
$runner
.cmx'
;
dst
.
writeAsStringSync
(
json
.
encode
(
cmx
));
dst
.
writeAsStringSync
(
json
.
encode
(
cmx
));
...
@@ -218,7 +214,10 @@ Future<void> _buildPackage(
...
@@ -218,7 +214,10 @@ Future<void> _buildPackage(
manifestFile
.
writeAsStringSync
(
'meta/package=
$pkgDir
/meta/package
\n
'
,
manifestFile
.
writeAsStringSync
(
'meta/package=
$pkgDir
/meta/package
\n
'
,
mode:
FileMode
.
append
);
mode:
FileMode
.
append
);
final
FuchsiaPM
fuchsiaPM
=
fuchsiaSdk
.
fuchsiaPM
;
final
FuchsiaPM
?
fuchsiaPM
=
fuchsiaSdk
?.
fuchsiaPM
;
if
(
fuchsiaPM
==
null
)
{
return
;
}
if
(!
await
fuchsiaPM
.
init
(
pkgDir
,
appName
))
{
if
(!
await
fuchsiaPM
.
init
(
pkgDir
,
appName
))
{
return
;
return
;
}
}
...
...
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
View file @
c584a5ea
...
@@ -2,11 +2,10 @@
...
@@ -2,11 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
import
'package:vm_service/vm_service.dart'
as
vm_service
;
import
'../application_package.dart'
;
import
'../application_package.dart'
;
import
'../artifacts.dart'
;
import
'../artifacts.dart'
;
...
@@ -36,19 +35,13 @@ import 'session_control.dart';
...
@@ -36,19 +35,13 @@ import 'session_control.dart';
import
'tiles_ctl.dart'
;
import
'tiles_ctl.dart'
;
/// The [FuchsiaDeviceTools] instance.
/// The [FuchsiaDeviceTools] instance.
FuchsiaDeviceTools
get
fuchsiaDeviceTools
=>
context
.
get
<
FuchsiaDeviceTools
>();
FuchsiaDeviceTools
get
fuchsiaDeviceTools
=>
context
.
get
<
FuchsiaDeviceTools
>()
!
;
/// Fuchsia device-side tools.
/// Fuchsia device-side tools.
class
FuchsiaDeviceTools
{
class
FuchsiaDeviceTools
{
FuchsiaPkgctl
_pkgctl
;
late
final
FuchsiaPkgctl
pkgctl
=
FuchsiaPkgctl
();
FuchsiaPkgctl
get
pkgctl
=>
_pkgctl
??=
FuchsiaPkgctl
();
late
final
FuchsiaTilesCtl
tilesCtl
=
FuchsiaTilesCtl
();
late
final
FuchsiaSessionControl
sessionControl
=
FuchsiaSessionControl
();
FuchsiaTilesCtl
_tilesCtl
;
FuchsiaTilesCtl
get
tilesCtl
=>
_tilesCtl
??=
FuchsiaTilesCtl
();
FuchsiaSessionControl
_sessionControl
;
FuchsiaSessionControl
get
sessionControl
=>
_sessionControl
??=
FuchsiaSessionControl
();
}
}
final
String
_ipv4Loopback
=
InternetAddress
.
loopbackIPv4
.
address
;
final
String
_ipv4Loopback
=
InternetAddress
.
loopbackIPv4
.
address
;
...
@@ -81,21 +74,21 @@ class _FuchsiaLogReader extends DeviceLogReader {
...
@@ -81,21 +74,21 @@ class _FuchsiaLogReader extends DeviceLogReader {
static
final
RegExp
_flutterLogOutput
=
RegExp
(
r'INFO: \S+\(flutter\): '
);
static
final
RegExp
_flutterLogOutput
=
RegExp
(
r'INFO: \S+\(flutter\): '
);
final
FuchsiaDevice
_device
;
final
FuchsiaDevice
_device
;
final
ApplicationPackage
_app
;
final
ApplicationPackage
?
_app
;
final
SystemClock
_systemClock
;
final
SystemClock
_systemClock
;
@override
@override
String
get
name
=>
_device
.
name
;
String
get
name
=>
_device
.
name
;
Stream
<
String
>
_logLines
;
Stream
<
String
>
?
_logLines
;
@override
@override
Stream
<
String
>
get
logLines
{
Stream
<
String
>
get
logLines
{
final
Stream
<
String
>
logStream
=
fuchsiaSdk
.
syslogs
(
_device
.
id
);
final
Stream
<
String
>
?
logStream
=
fuchsiaSdk
?
.
syslogs
(
_device
.
id
);
_logLines
??=
_processLogs
(
logStream
);
_logLines
??=
_processLogs
(
logStream
);
return
_logLines
;
return
_logLines
??
const
Stream
<
String
>.
empty
()
;
}
}
Stream
<
String
>
_processLogs
(
Stream
<
String
>
lines
)
{
Stream
<
String
>
?
_processLogs
(
Stream
<
String
>?
lines
)
{
if
(
lines
==
null
)
{
if
(
lines
==
null
)
{
return
null
;
return
null
;
}
}
...
@@ -104,9 +97,10 @@ class _FuchsiaLogReader extends DeviceLogReader {
...
@@ -104,9 +97,10 @@ class _FuchsiaLogReader extends DeviceLogReader {
final
DateTime
startTime
=
_systemClock
.
now
();
final
DateTime
startTime
=
_systemClock
.
now
();
// Determine if line comes from flutter, and optionally whether it matches
// Determine if line comes from flutter, and optionally whether it matches
// the correct fuchsia module.
// the correct fuchsia module.
final
RegExp
matchRegExp
=
_app
==
null
final
ApplicationPackage
?
app
=
_app
;
final
RegExp
matchRegExp
=
app
==
null
?
_flutterLogOutput
?
_flutterLogOutput
:
RegExp
(
'INFO:
${
_
app.name}
(
\\
.cmx)?
\\
(flutter
\\
): '
);
:
RegExp
(
'INFO:
${app.name}
(
\\
.cmx)?
\\
(flutter
\\
): '
);
return
Stream
<
String
>.
eventTransformed
(
return
Stream
<
String
>.
eventTransformed
(
lines
,
lines
,
(
EventSink
<
String
>
output
)
=>
_FuchsiaLogSink
(
output
,
matchRegExp
,
startTime
),
(
EventSink
<
String
>
output
)
=>
_FuchsiaLogSink
(
output
,
matchRegExp
,
startTime
),
...
@@ -136,7 +130,7 @@ class _FuchsiaLogSink implements EventSink<String> {
...
@@ -136,7 +130,7 @@ class _FuchsiaLogSink implements EventSink<String> {
if
(!
_matchRegExp
.
hasMatch
(
line
))
{
if
(!
_matchRegExp
.
hasMatch
(
line
))
{
return
;
return
;
}
}
final
String
rawDate
=
_utcDateOutput
.
firstMatch
(
line
)?.
group
(
0
);
final
String
?
rawDate
=
_utcDateOutput
.
firstMatch
(
line
)?.
group
(
0
);
if
(
rawDate
==
null
)
{
if
(
rawDate
==
null
)
{
return
;
return
;
}
}
...
@@ -149,7 +143,7 @@ class _FuchsiaLogSink implements EventSink<String> {
...
@@ -149,7 +143,7 @@ class _FuchsiaLogSink implements EventSink<String> {
}
}
@override
@override
void
addError
(
Object
error
,
[
StackTrace
stackTrace
])
{
void
addError
(
Object
error
,
[
StackTrace
?
stackTrace
])
{
_outputSink
.
addError
(
error
,
stackTrace
);
_outputSink
.
addError
(
error
,
stackTrace
);
}
}
...
@@ -162,10 +156,10 @@ class _FuchsiaLogSink implements EventSink<String> {
...
@@ -162,10 +156,10 @@ class _FuchsiaLogSink implements EventSink<String> {
/// Device discovery for Fuchsia devices.
/// Device discovery for Fuchsia devices.
class
FuchsiaDevices
extends
PollingDeviceDiscovery
{
class
FuchsiaDevices
extends
PollingDeviceDiscovery
{
FuchsiaDevices
({
FuchsiaDevices
({
@
required
Platform
platform
,
required
Platform
platform
,
@
required
FuchsiaWorkflow
fuchsiaWorkflow
,
required
FuchsiaWorkflow
fuchsiaWorkflow
,
@
required
FuchsiaSdk
fuchsiaSdk
,
required
FuchsiaSdk
fuchsiaSdk
,
@
required
Logger
logger
,
required
Logger
logger
,
})
:
_platform
=
platform
,
})
:
_platform
=
platform
,
_fuchsiaWorkflow
=
fuchsiaWorkflow
,
_fuchsiaWorkflow
=
fuchsiaWorkflow
,
_fuchsiaSdk
=
fuchsiaSdk
,
_fuchsiaSdk
=
fuchsiaSdk
,
...
@@ -184,12 +178,12 @@ class FuchsiaDevices extends PollingDeviceDiscovery {
...
@@ -184,12 +178,12 @@ class FuchsiaDevices extends PollingDeviceDiscovery {
bool
get
canListAnything
=>
_fuchsiaWorkflow
.
canListDevices
;
bool
get
canListAnything
=>
_fuchsiaWorkflow
.
canListDevices
;
@override
@override
Future
<
List
<
Device
>>
pollingGetDevices
({
Duration
timeout
})
async
{
Future
<
List
<
Device
>>
pollingGetDevices
({
Duration
?
timeout
})
async
{
if
(!
_fuchsiaWorkflow
.
canListDevices
)
{
if
(!
_fuchsiaWorkflow
.
canListDevices
)
{
return
<
Device
>[];
return
<
Device
>[];
}
}
// TODO(omerlevran): Remove once soft transition is complete fxb/67602.
// TODO(omerlevran): Remove once soft transition is complete fxb/67602.
final
List
<
String
>
text
=
(
await
_fuchsiaSdk
.
listDevices
(
final
List
<
String
>
?
text
=
(
await
_fuchsiaSdk
.
listDevices
(
timeout:
timeout
,
timeout:
timeout
,
))?.
split
(
'
\n
'
);
))?.
split
(
'
\n
'
);
if
(
text
==
null
||
text
.
isEmpty
)
{
if
(
text
==
null
||
text
.
isEmpty
)
{
...
@@ -197,7 +191,7 @@ class FuchsiaDevices extends PollingDeviceDiscovery {
...
@@ -197,7 +191,7 @@ class FuchsiaDevices extends PollingDeviceDiscovery {
}
}
final
List
<
FuchsiaDevice
>
devices
=
<
FuchsiaDevice
>[];
final
List
<
FuchsiaDevice
>
devices
=
<
FuchsiaDevice
>[];
for
(
final
String
line
in
text
)
{
for
(
final
String
line
in
text
)
{
final
FuchsiaDevice
device
=
await
_parseDevice
(
line
);
final
FuchsiaDevice
?
device
=
await
_parseDevice
(
line
);
if
(
device
==
null
)
{
if
(
device
==
null
)
{
continue
;
continue
;
}
}
...
@@ -209,7 +203,7 @@ class FuchsiaDevices extends PollingDeviceDiscovery {
...
@@ -209,7 +203,7 @@ class FuchsiaDevices extends PollingDeviceDiscovery {
@override
@override
Future
<
List
<
String
>>
getDiagnostics
()
async
=>
const
<
String
>[];
Future
<
List
<
String
>>
getDiagnostics
()
async
=>
const
<
String
>[];
Future
<
FuchsiaDevice
>
_parseDevice
(
String
text
)
async
{
Future
<
FuchsiaDevice
?
>
_parseDevice
(
String
text
)
async
{
final
String
line
=
text
.
trim
();
final
String
line
=
text
.
trim
();
// ['ip', 'device name']
// ['ip', 'device name']
final
List
<
String
>
words
=
line
.
split
(
' '
);
final
List
<
String
>
words
=
line
.
split
(
' '
);
...
@@ -219,7 +213,7 @@ class FuchsiaDevices extends PollingDeviceDiscovery {
...
@@ -219,7 +213,7 @@ class FuchsiaDevices extends PollingDeviceDiscovery {
final
String
name
=
words
[
1
];
final
String
name
=
words
[
1
];
// TODO(omerlevran): Add support for resolve on the FuchsiaSdk Object.
// TODO(omerlevran): Add support for resolve on the FuchsiaSdk Object.
final
String
resolvedHost
=
await
_fuchsiaSdk
.
fuchsiaFfx
.
resolve
(
name
);
final
String
?
resolvedHost
=
await
_fuchsiaSdk
.
fuchsiaFfx
.
resolve
(
name
);
if
(
resolvedHost
==
null
)
{
if
(
resolvedHost
==
null
)
{
_logger
.
printError
(
'Failed to resolve host for Fuchsia device `
$name
`'
);
_logger
.
printError
(
'Failed to resolve host for Fuchsia device `
$name
`'
);
return
null
;
return
null
;
...
@@ -233,7 +227,7 @@ class FuchsiaDevices extends PollingDeviceDiscovery {
...
@@ -233,7 +227,7 @@ class FuchsiaDevices extends PollingDeviceDiscovery {
class
FuchsiaDevice
extends
Device
{
class
FuchsiaDevice
extends
Device
{
FuchsiaDevice
(
String
id
,
{
this
.
name
})
:
super
(
FuchsiaDevice
(
String
id
,
{
required
this
.
name
})
:
super
(
id
,
id
,
platformType:
PlatformType
.
fuchsia
,
platformType:
PlatformType
.
fuchsia
,
category:
null
,
category:
null
,
...
@@ -256,14 +250,12 @@ class FuchsiaDevice extends Device {
...
@@ -256,14 +250,12 @@ class FuchsiaDevice extends Device {
Future
<
bool
>
get
isLocalEmulator
async
=>
false
;
Future
<
bool
>
get
isLocalEmulator
async
=>
false
;
@override
@override
Future
<
String
>
get
emulatorId
async
=>
null
;
Future
<
String
?
>
get
emulatorId
async
=>
null
;
@override
@override
bool
get
supportsStartPaused
=>
false
;
bool
get
supportsStartPaused
=>
false
;
bool
_isSession
;
late
final
Future
<
bool
>
isSession
=
_initIsSession
();
Future
<
bool
>
get
isSession
async
=>
_isSession
??=
await
_initIsSession
();
/// Determine if the Fuchsia device is running a session based build.
/// Determine if the Fuchsia device is running a session based build.
///
///
...
@@ -280,7 +272,7 @@ class FuchsiaDevice extends Device {
...
@@ -280,7 +272,7 @@ class FuchsiaDevice extends Device {
@override
@override
Future
<
bool
>
isAppInstalled
(
Future
<
bool
>
isAppInstalled
(
ApplicationPackage
app
,
{
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
})
async
=>
false
;
})
async
=>
false
;
@override
@override
...
@@ -289,13 +281,13 @@ class FuchsiaDevice extends Device {
...
@@ -289,13 +281,13 @@ class FuchsiaDevice extends Device {
@override
@override
Future
<
bool
>
installApp
(
Future
<
bool
>
installApp
(
ApplicationPackage
app
,
{
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
})
=>
Future
<
bool
>.
value
(
false
);
})
=>
Future
<
bool
>.
value
(
false
);
@override
@override
Future
<
bool
>
uninstallApp
(
Future
<
bool
>
uninstallApp
(
ApplicationPackage
app
,
{
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
})
async
=>
false
;
})
async
=>
false
;
@override
@override
...
@@ -307,13 +299,13 @@ class FuchsiaDevice extends Device {
...
@@ -307,13 +299,13 @@ class FuchsiaDevice extends Device {
@override
@override
Future
<
LaunchResult
>
startApp
(
Future
<
LaunchResult
>
startApp
(
covariant
FuchsiaApp
package
,
{
covariant
FuchsiaApp
package
,
{
String
mainPath
,
String
?
mainPath
,
String
route
,
String
?
route
,
DebuggingOptions
debuggingOptions
,
required
DebuggingOptions
debuggingOptions
,
Map
<
String
,
dynamic
>
platformArgs
,
Map
<
String
,
Object
?>
platformArgs
=
const
<
String
,
Object
?>{}
,
bool
prebuiltApplication
=
false
,
bool
prebuiltApplication
=
false
,
bool
ipv6
=
false
,
bool
ipv6
=
false
,
String
userIdentifier
,
String
?
userIdentifier
,
})
async
{
})
async
{
if
(
await
isSession
)
{
if
(
await
isSession
)
{
globals
.
printTrace
(
'Running on a session framework based build.'
);
globals
.
printTrace
(
'Running on a session framework based build.'
);
...
@@ -356,7 +348,7 @@ class FuchsiaDevice extends Device {
...
@@ -356,7 +348,7 @@ class FuchsiaDevice extends Device {
final
Status
status
=
globals
.
logger
.
startProgress
(
final
Status
status
=
globals
.
logger
.
startProgress
(
'Starting Fuchsia application
$appName
...'
,
'Starting Fuchsia application
$appName
...'
,
);
);
FuchsiaPackageServer
fuchsiaPackageServer
;
FuchsiaPackageServer
?
fuchsiaPackageServer
;
bool
serverRegistered
=
false
;
bool
serverRegistered
=
false
;
String
fuchsiaUrl
;
String
fuchsiaUrl
;
try
{
try
{
...
@@ -379,7 +371,7 @@ class FuchsiaDevice extends Device {
...
@@ -379,7 +371,7 @@ class FuchsiaDevice extends Device {
// Serve the flutter_runner.
// Serve the flutter_runner.
final
File
flutterRunnerArchive
=
final
File
flutterRunnerArchive
=
globals
.
fs
.
file
(
globals
.
artifacts
.
getArtifactPath
(
globals
.
fs
.
file
(
globals
.
artifacts
!
.
getArtifactPath
(
Artifact
.
fuchsiaFlutterRunner
,
Artifact
.
fuchsiaFlutterRunner
,
platform:
await
targetPlatform
,
platform:
await
targetPlatform
,
mode:
debuggingOptions
.
buildInfo
.
mode
,
mode:
debuggingOptions
.
buildInfo
.
mode
,
...
@@ -455,7 +447,7 @@ class FuchsiaDevice extends Device {
...
@@ -455,7 +447,7 @@ class FuchsiaDevice extends Device {
}
finally
{
}
finally
{
// Try to un-teach the package controller about the package server if
// Try to un-teach the package controller about the package server if
// needed.
// needed.
if
(
serverRegistered
)
{
if
(
serverRegistered
&&
fuchsiaPackageServer
!=
null
)
{
await
fuchsiaDeviceTools
.
pkgctl
.
rmRepo
(
this
,
fuchsiaPackageServer
);
await
fuchsiaDeviceTools
.
pkgctl
.
rmRepo
(
this
,
fuchsiaPackageServer
);
}
}
// Shutdown the package server and delete the package repo;
// Shutdown the package server and delete the package repo;
...
@@ -493,7 +485,7 @@ class FuchsiaDevice extends Device {
...
@@ -493,7 +485,7 @@ class FuchsiaDevice extends Device {
@override
@override
Future
<
bool
>
stopApp
(
Future
<
bool
>
stopApp
(
covariant
FuchsiaApp
app
,
{
covariant
FuchsiaApp
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
})
async
{
})
async
{
if
(
await
isSession
)
{
if
(
await
isSession
)
{
// Currently there are no way to close a running app programmatically
// Currently there are no way to close a running app programmatically
...
@@ -510,11 +502,9 @@ class FuchsiaDevice extends Device {
...
@@ -510,11 +502,9 @@ class FuchsiaDevice extends Device {
return
true
;
return
true
;
}
}
TargetPlatform
_targetPlatform
;
Future
<
TargetPlatform
>
_queryTargetPlatform
()
async
{
Future
<
TargetPlatform
>
_queryTargetPlatform
()
async
{
const
TargetPlatform
defaultTargetPlatform
=
TargetPlatform
.
fuchsia_arm64
;
const
TargetPlatform
defaultTargetPlatform
=
TargetPlatform
.
fuchsia_arm64
;
if
(!
globals
.
fuchsiaArtifacts
.
hasSshConfig
)
{
if
(!
globals
.
fuchsiaArtifacts
!
.
hasSshConfig
)
{
globals
.
printTrace
(
'Could not determine Fuchsia target platform because '
globals
.
printTrace
(
'Could not determine Fuchsia target platform because '
'Fuchsia ssh configuration is missing.
\n
'
'Fuchsia ssh configuration is missing.
\n
'
'Defaulting to arm64.'
);
'Defaulting to arm64.'
);
...
@@ -574,12 +564,12 @@ class FuchsiaDevice extends Device {
...
@@ -574,12 +564,12 @@ class FuchsiaDevice extends Device {
}
}
@override
@override
Future
<
TargetPlatform
>
get
targetPlatform
async
=>
_targetPlatform
??=
await
_queryTargetPlatform
();
late
final
Future
<
TargetPlatform
>
targetPlatform
=
_queryTargetPlatform
();
@override
@override
Future
<
String
>
get
sdkNameAndVersion
async
{
Future
<
String
>
get
sdkNameAndVersion
async
{
const
String
defaultName
=
'Fuchsia'
;
const
String
defaultName
=
'Fuchsia'
;
if
(!
globals
.
fuchsiaArtifacts
.
hasSshConfig
)
{
if
(!
globals
.
fuchsiaArtifacts
!
.
hasSshConfig
)
{
globals
.
printTrace
(
'Could not determine Fuchsia sdk name or version '
globals
.
printTrace
(
'Could not determine Fuchsia sdk name or version '
'because Fuchsia ssh configuration is missing.'
);
'because Fuchsia ssh configuration is missing.'
);
return
defaultName
;
return
defaultName
;
...
@@ -600,18 +590,18 @@ class FuchsiaDevice extends Device {
...
@@ -600,18 +590,18 @@ class FuchsiaDevice extends Device {
@override
@override
DeviceLogReader
getLogReader
({
DeviceLogReader
getLogReader
({
ApplicationPackage
app
,
ApplicationPackage
?
app
,
bool
includePastLogs
=
false
,
bool
includePastLogs
=
false
,
})
{
})
{
assert
(!
includePastLogs
,
'Past log reading not supported on Fuchsia.'
);
assert
(!
includePastLogs
,
'Past log reading not supported on Fuchsia.'
);
return
_logReader
??=
_FuchsiaLogReader
(
this
,
globals
.
systemClock
,
app
);
return
_logReader
??=
_FuchsiaLogReader
(
this
,
globals
.
systemClock
,
app
);
}
}
_FuchsiaLogReader
_logReader
;
_FuchsiaLogReader
?
_logReader
;
@override
@override
DevicePortForwarder
get
portForwarder
=>
DevicePortForwarder
get
portForwarder
=>
_portForwarder
??=
_FuchsiaPortForwarder
(
this
);
_portForwarder
??=
_FuchsiaPortForwarder
(
this
);
DevicePortForwarder
_portForwarder
;
DevicePortForwarder
?
_portForwarder
;
@visibleForTesting
@visibleForTesting
set
portForwarder
(
DevicePortForwarder
forwarder
)
{
set
portForwarder
(
DevicePortForwarder
forwarder
)
{
...
@@ -621,17 +611,12 @@ class FuchsiaDevice extends Device {
...
@@ -621,17 +611,12 @@ class FuchsiaDevice extends Device {
@override
@override
void
clearLogs
()
{}
void
clearLogs
()
{}
bool
_ipv6
;
/// [true] if the current host address is IPv6.
/// [true] if the current host address is IPv6.
bool
get
ipv6
=>
_ipv6
??
=
isIPv6Address
(
id
);
late
final
bool
ipv6
=
isIPv6Address
(
id
);
/// Return the address that the device should use to communicate with the
/// Return the address that the device should use to communicate with the
/// host.
/// host.
Future
<
String
>
get
hostAddress
async
{
late
final
Future
<
String
>
hostAddress
=
()
async
{
if
(
_cachedHostAddress
!=
null
)
{
return
_cachedHostAddress
;
}
final
RunResult
result
=
await
shell
(
r'echo $SSH_CONNECTION'
);
final
RunResult
result
=
await
shell
(
r'echo $SSH_CONNECTION'
);
void
fail
()
{
void
fail
()
{
throwToolExit
(
'Failed to get local address, aborting.
\n
$result
'
);
throwToolExit
(
'Failed to get local address, aborting.
\n
$result
'
);
...
@@ -647,10 +632,8 @@ class FuchsiaDevice extends Device {
...
@@ -647,10 +632,8 @@ class FuchsiaDevice extends Device {
if
(
addr
.
isEmpty
)
{
if
(
addr
.
isEmpty
)
{
fail
();
fail
();
}
}
return
_cachedHostAddress
=
addr
;
return
addr
;
}
}();
String
_cachedHostAddress
;
/// List the ports currently running a dart observatory.
/// List the ports currently running a dart observatory.
Future
<
List
<
int
>>
servicePorts
()
async
{
Future
<
List
<
int
>>
servicePorts
()
async
{
...
@@ -679,7 +662,7 @@ class FuchsiaDevice extends Device {
...
@@ -679,7 +662,7 @@ class FuchsiaDevice extends Device {
if
(
line
==
''
)
{
if
(
line
==
''
)
{
continue
;
continue
;
}
}
final
int
port
=
int
.
tryParse
(
line
);
final
int
?
port
=
int
.
tryParse
(
line
);
if
(
port
!=
null
)
{
if
(
port
!=
null
)
{
ports
.
add
(
port
);
ports
.
add
(
port
);
}
}
...
@@ -690,14 +673,15 @@ class FuchsiaDevice extends Device {
...
@@ -690,14 +673,15 @@ class FuchsiaDevice extends Device {
/// Run `command` on the Fuchsia device shell.
/// Run `command` on the Fuchsia device shell.
Future
<
RunResult
>
shell
(
String
command
)
async
{
Future
<
RunResult
>
shell
(
String
command
)
async
{
if
(
globals
.
fuchsiaArtifacts
.
sshConfig
==
null
)
{
final
File
?
sshConfig
=
globals
.
fuchsiaArtifacts
?.
sshConfig
;
if
(
sshConfig
==
null
)
{
throwToolExit
(
'Cannot interact with device. No ssh config.
\n
'
throwToolExit
(
'Cannot interact with device. No ssh config.
\n
'
'Try setting FUCHSIA_SSH_CONFIG or FUCHSIA_BUILD_DIR.'
);
'Try setting FUCHSIA_SSH_CONFIG or FUCHSIA_BUILD_DIR.'
);
}
}
return
globals
.
processUtils
.
run
(<
String
>[
return
globals
.
processUtils
.
run
(<
String
>[
'ssh'
,
'ssh'
,
'-F'
,
'-F'
,
globals
.
fuchsiaArtifacts
.
sshConfig
.
absolute
.
path
,
sshConfig
.
absolute
.
path
,
id
,
// Device's IP address.
id
,
// Device's IP address.
command
,
command
,
]);
]);
...
@@ -705,14 +689,15 @@ class FuchsiaDevice extends Device {
...
@@ -705,14 +689,15 @@ class FuchsiaDevice extends Device {
/// Transfer the file [origin] from the device to [destination].
/// Transfer the file [origin] from the device to [destination].
Future
<
RunResult
>
scp
(
String
origin
,
String
destination
)
async
{
Future
<
RunResult
>
scp
(
String
origin
,
String
destination
)
async
{
if
(
globals
.
fuchsiaArtifacts
.
sshConfig
==
null
)
{
final
File
?
sshConfig
=
globals
.
fuchsiaArtifacts
!.
sshConfig
;
if
(
sshConfig
==
null
)
{
throwToolExit
(
'Cannot interact with device. No ssh config.
\n
'
throwToolExit
(
'Cannot interact with device. No ssh config.
\n
'
'Try setting FUCHSIA_SSH_CONFIG or FUCHSIA_BUILD_DIR.'
);
'Try setting FUCHSIA_SSH_CONFIG or FUCHSIA_BUILD_DIR.'
);
}
}
return
globals
.
processUtils
.
run
(<
String
>[
return
globals
.
processUtils
.
run
(<
String
>[
'scp'
,
'scp'
,
'-F'
,
'-F'
,
globals
.
fuchsiaArtifacts
.
sshConfig
.
absolute
.
path
,
sshConfig
.
absolute
.
path
,
'
$id
:
$origin
'
,
'
$id
:
$origin
'
,
destination
,
destination
,
]);
]);
...
@@ -733,11 +718,13 @@ class FuchsiaDevice extends Device {
...
@@ -733,11 +718,13 @@ class FuchsiaDevice extends Device {
final
FlutterVmService
vmService
=
await
connectToVmService
(
uri
,
logger:
globals
.
logger
);
final
FlutterVmService
vmService
=
await
connectToVmService
(
uri
,
logger:
globals
.
logger
);
final
List
<
FlutterView
>
flutterViews
=
await
vmService
.
getFlutterViews
();
final
List
<
FlutterView
>
flutterViews
=
await
vmService
.
getFlutterViews
();
for
(
final
FlutterView
flutterView
in
flutterViews
)
{
for
(
final
FlutterView
flutterView
in
flutterViews
)
{
if
(
flutterView
.
uiIsolate
==
null
)
{
final
vm_service
.
IsolateRef
?
uiIsolate
=
flutterView
.
uiIsolate
;
if
(
uiIsolate
==
null
)
{
continue
;
continue
;
}
}
if
(
flutterView
.
uiIsolate
.
name
.
contains
(
isolateName
))
{
final
int
?
port
=
vmService
.
httpAddress
?.
port
;
return
vmService
.
httpAddress
.
port
;
if
(
port
!=
null
&&
uiIsolate
.
name
?.
contains
(
isolateName
)
==
true
)
{
return
port
;
}
}
}
}
}
on
SocketException
catch
(
err
)
{
}
on
SocketException
catch
(
err
)
{
...
@@ -780,12 +767,12 @@ class FuchsiaIsolateDiscoveryProtocol {
...
@@ -780,12 +767,12 @@ class FuchsiaIsolateDiscoveryProtocol {
final
Future
<
void
>
Function
(
Device
,
Uri
,
bool
)
_ddsStarter
;
final
Future
<
void
>
Function
(
Device
,
Uri
,
bool
)
_ddsStarter
;
// whether to only poll once.
// whether to only poll once.
final
bool
_pollOnce
;
final
bool
_pollOnce
;
Timer
_pollingTimer
;
Timer
?
_pollingTimer
;
Status
_status
;
Status
?
_status
;
FutureOr
<
Uri
>
get
uri
{
FutureOr
<
Uri
>
get
uri
{
if
(
_uri
!=
null
)
{
if
(
_uri
!=
null
)
{
return
_uri
;
return
_uri
!
;
}
}
_status
??=
globals
.
logger
.
startProgress
(
_status
??=
globals
.
logger
.
startProgress
(
'Waiting for a connection from
$_isolateName
on
${_device.name}
...'
,
'Waiting for a connection from
$_isolateName
on
${_device.name}
...'
,
...
@@ -797,7 +784,7 @@ class FuchsiaIsolateDiscoveryProtocol {
...
@@ -797,7 +784,7 @@ class FuchsiaIsolateDiscoveryProtocol {
});
});
}
}
Uri
_uri
;
Uri
?
_uri
;
void
dispose
()
{
void
dispose
()
{
if
(!
_foundUri
.
isCompleted
)
{
if
(!
_foundUri
.
isCompleted
)
{
...
@@ -812,7 +799,7 @@ class FuchsiaIsolateDiscoveryProtocol {
...
@@ -812,7 +799,7 @@ class FuchsiaIsolateDiscoveryProtocol {
Future
<
void
>
_findIsolate
()
async
{
Future
<
void
>
_findIsolate
()
async
{
final
List
<
int
>
ports
=
await
_device
.
servicePorts
();
final
List
<
int
>
ports
=
await
_device
.
servicePorts
();
for
(
final
int
port
in
ports
)
{
for
(
final
int
port
in
ports
)
{
FlutterVmService
service
;
FlutterVmService
?
service
;
if
(
_ports
.
containsKey
(
port
))
{
if
(
_ports
.
containsKey
(
port
))
{
service
=
_ports
[
port
];
service
=
_ports
[
port
];
}
else
{
}
else
{
...
@@ -820,30 +807,32 @@ class FuchsiaIsolateDiscoveryProtocol {
...
@@ -820,30 +807,32 @@ class FuchsiaIsolateDiscoveryProtocol {
try
{
try
{
final
Uri
uri
=
Uri
.
parse
(
'http://[
$_ipv6Loopback
]:
$localPort
'
);
final
Uri
uri
=
Uri
.
parse
(
'http://[
$_ipv6Loopback
]:
$localPort
'
);
await
_ddsStarter
(
_device
,
uri
,
true
);
await
_ddsStarter
(
_device
,
uri
,
true
);
service
=
await
_vmServiceConnector
(
_device
.
dds
.
uri
);
service
=
await
_vmServiceConnector
(
_device
.
dds
.
uri
!
);
_ports
[
port
]
=
service
;
_ports
[
port
]
=
service
;
}
on
SocketException
catch
(
err
)
{
}
on
SocketException
catch
(
err
)
{
globals
.
printTrace
(
'Failed to connect to
$localPort
:
$err
'
);
globals
.
printTrace
(
'Failed to connect to
$localPort
:
$err
'
);
continue
;
continue
;
}
}
}
}
final
List
<
FlutterView
>
flutterViews
=
await
service
.
getFlutterViews
()
;
final
List
<
FlutterView
>
flutterViews
=
await
service
?.
getFlutterViews
()
??
<
FlutterView
>[]
;
for
(
final
FlutterView
flutterView
in
flutterViews
)
{
for
(
final
FlutterView
flutterView
in
flutterViews
)
{
if
(
flutterView
.
uiIsolate
==
null
)
{
final
vm_service
.
IsolateRef
?
uiIsolate
=
flutterView
.
uiIsolate
;
if
(
uiIsolate
==
null
)
{
continue
;
continue
;
}
}
if
(
flutterView
.
uiIsolate
.
name
.
contains
(
_isolateName
))
{
final
int
?
port
=
service
?.
httpAddress
?.
port
;
if
(
port
!=
null
&&
uiIsolate
.
name
?.
contains
(
_isolateName
)
==
true
)
{
_foundUri
.
complete
(
_device
.
ipv6
_foundUri
.
complete
(
_device
.
ipv6
?
Uri
.
parse
(
'http://[
$_ipv6Loopback
]:
$
{service.httpAddress.port}
/'
)
?
Uri
.
parse
(
'http://[
$_ipv6Loopback
]:
$
port
/'
)
:
Uri
.
parse
(
'http://
$_ipv4Loopback
:
$
{service.httpAddress.port}
/'
));
:
Uri
.
parse
(
'http://
$_ipv4Loopback
:
$
port
/'
));
_status
.
stop
();
_status
?
.
stop
();
return
;
return
;
}
}
}
}
}
}
if
(
_pollOnce
)
{
if
(
_pollOnce
)
{
_foundUri
.
completeError
(
Exception
(
'Max iterations exceeded'
));
_foundUri
.
completeError
(
Exception
(
'Max iterations exceeded'
));
_status
.
stop
();
_status
?
.
stop
();
return
;
return
;
}
}
_pollingTimer
=
Timer
(
_pollDuration
,
_findIsolate
);
_pollingTimer
=
Timer
(
_pollDuration
,
_findIsolate
);
...
@@ -857,18 +846,23 @@ class _FuchsiaPortForwarder extends DevicePortForwarder {
...
@@ -857,18 +846,23 @@ class _FuchsiaPortForwarder extends DevicePortForwarder {
final
Map
<
int
,
Process
>
_processes
=
<
int
,
Process
>{};
final
Map
<
int
,
Process
>
_processes
=
<
int
,
Process
>{};
@override
@override
Future
<
int
>
forward
(
int
devicePort
,
{
int
hostPort
})
async
{
Future
<
int
>
forward
(
int
devicePort
,
{
int
?
hostPort
})
async
{
hostPort
??=
await
globals
.
os
.
findFreePort
();
hostPort
??=
await
globals
.
os
.
findFreePort
();
if
(
hostPort
==
0
)
{
if
(
hostPort
==
0
)
{
throwToolExit
(
'Failed to forward port
$devicePort
. No free host-side ports'
);
throwToolExit
(
'Failed to forward port
$devicePort
. No free host-side ports'
);
}
}
final
File
?
sshConfig
=
globals
.
fuchsiaArtifacts
?.
sshConfig
;
if
(
sshConfig
==
null
)
{
throwToolExit
(
'Cannot interact with device. No ssh config.
\n
'
'Try setting FUCHSIA_SSH_CONFIG or FUCHSIA_BUILD_DIR.'
);
}
// Note: the provided command works around a bug in -N, see US-515
// Note: the provided command works around a bug in -N, see US-515
// for more explanation.
// for more explanation.
final
List
<
String
>
command
=
<
String
>[
final
List
<
String
>
command
=
<
String
>[
'ssh'
,
'ssh'
,
'-6'
,
'-6'
,
'-F'
,
'-F'
,
globals
.
fuchsiaArtifacts
.
sshConfig
.
absolute
.
path
,
sshConfig
.
absolute
.
path
,
'-nNT'
,
'-nNT'
,
'-vvv'
,
'-vvv'
,
'-f'
,
'-f'
,
...
@@ -895,12 +889,17 @@ class _FuchsiaPortForwarder extends DevicePortForwarder {
...
@@ -895,12 +889,17 @@ class _FuchsiaPortForwarder extends DevicePortForwarder {
@override
@override
Future
<
void
>
unforward
(
ForwardedPort
forwardedPort
)
async
{
Future
<
void
>
unforward
(
ForwardedPort
forwardedPort
)
async
{
_forwardedPorts
.
remove
(
forwardedPort
);
_forwardedPorts
.
remove
(
forwardedPort
);
final
Process
process
=
_processes
.
remove
(
forwardedPort
.
hostPort
);
final
Process
?
process
=
_processes
.
remove
(
forwardedPort
.
hostPort
);
process
?.
kill
();
process
?.
kill
();
final
File
?
sshConfig
=
globals
.
fuchsiaArtifacts
?.
sshConfig
;
if
(
sshConfig
==
null
)
{
// Nothing to cancel.
return
;
}
final
List
<
String
>
command
=
<
String
>[
final
List
<
String
>
command
=
<
String
>[
'ssh'
,
'ssh'
,
'-F'
,
'-F'
,
globals
.
fuchsiaArtifacts
.
sshConfig
.
absolute
.
path
,
sshConfig
.
absolute
.
path
,
'-O'
,
'-O'
,
'cancel'
,
'cancel'
,
'-vvv'
,
'-vvv'
,
...
...
packages/flutter_tools/lib/src/fuchsia/pkgctl.dart
View file @
c584a5ea
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'../base/process.dart'
;
import
'../base/process.dart'
;
import
'fuchsia_device.dart'
;
import
'fuchsia_device.dart'
;
...
...
packages/flutter_tools/lib/src/fuchsia/session_control.dart
View file @
c584a5ea
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'../base/process.dart'
;
import
'../base/process.dart'
;
import
'fuchsia_device.dart'
;
import
'fuchsia_device.dart'
;
...
...
packages/flutter_tools/lib/src/fuchsia/tiles_ctl.dart
View file @
c584a5ea
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'../base/process.dart'
;
import
'../base/process.dart'
;
import
'../globals.dart'
as
globals
;
import
'../globals.dart'
as
globals
;
...
@@ -23,7 +21,7 @@ class FuchsiaTilesCtl {
...
@@ -23,7 +21,7 @@ class FuchsiaTilesCtl {
/// found.
/// found.
static
Future
<
int
>
findAppKey
(
FuchsiaDevice
device
,
String
appName
)
async
{
static
Future
<
int
>
findAppKey
(
FuchsiaDevice
device
,
String
appName
)
async
{
final
FuchsiaTilesCtl
tilesCtl
=
fuchsiaDeviceTools
.
tilesCtl
;
final
FuchsiaTilesCtl
tilesCtl
=
fuchsiaDeviceTools
.
tilesCtl
;
final
Map
<
int
,
String
>
runningApps
=
await
tilesCtl
.
list
(
device
);
final
Map
<
int
,
String
>
?
runningApps
=
await
tilesCtl
.
list
(
device
);
if
(
runningApps
==
null
)
{
if
(
runningApps
==
null
)
{
globals
.
printTrace
(
'tiles_ctl is not running'
);
globals
.
printTrace
(
'tiles_ctl is not running'
);
return
-
1
;
return
-
1
;
...
@@ -39,7 +37,7 @@ class FuchsiaTilesCtl {
...
@@ -39,7 +37,7 @@ class FuchsiaTilesCtl {
/// Ensures that tiles is running on the device.
/// Ensures that tiles is running on the device.
static
Future
<
bool
>
ensureStarted
(
FuchsiaDevice
device
)
async
{
static
Future
<
bool
>
ensureStarted
(
FuchsiaDevice
device
)
async
{
final
FuchsiaTilesCtl
tilesCtl
=
fuchsiaDeviceTools
.
tilesCtl
;
final
FuchsiaTilesCtl
tilesCtl
=
fuchsiaDeviceTools
.
tilesCtl
;
final
Map
<
int
,
String
>
runningApps
=
await
tilesCtl
.
list
(
device
);
final
Map
<
int
,
String
>
?
runningApps
=
await
tilesCtl
.
list
(
device
);
if
(
runningApps
==
null
)
{
if
(
runningApps
==
null
)
{
return
tilesCtl
.
start
(
device
);
return
tilesCtl
.
start
(
device
);
}
}
...
@@ -58,7 +56,7 @@ class FuchsiaTilesCtl {
...
@@ -58,7 +56,7 @@ class FuchsiaTilesCtl {
///
///
/// Returns an empty mapping if tiles_ctl is running but no apps are running.
/// Returns an empty mapping if tiles_ctl is running but no apps are running.
/// Returns null if tiles_ctl is not running.
/// Returns null if tiles_ctl is not running.
Future
<
Map
<
int
,
String
>>
list
(
FuchsiaDevice
device
)
async
{
Future
<
Map
<
int
,
String
>
?
>
list
(
FuchsiaDevice
device
)
async
{
// Output of tiles_ctl list has the format:
// Output of tiles_ctl list has the format:
// Found 1 tiles:
// Found 1 tiles:
// Tile key 1 url fuchsia-pkg://fuchsia.com/stocks#meta/stocks.cmx ...
// Tile key 1 url fuchsia-pkg://fuchsia.com/stocks#meta/stocks.cmx ...
...
@@ -75,9 +73,11 @@ class FuchsiaTilesCtl {
...
@@ -75,9 +73,11 @@ class FuchsiaTilesCtl {
for
(
final
String
line
in
result
.
stdout
.
split
(
'
\n
'
))
{
for
(
final
String
line
in
result
.
stdout
.
split
(
'
\n
'
))
{
final
List
<
String
>
words
=
line
.
split
(
' '
);
final
List
<
String
>
words
=
line
.
split
(
' '
);
if
(
words
.
isNotEmpty
&&
words
[
0
]
==
'Tile'
)
{
if
(
words
.
isNotEmpty
&&
words
[
0
]
==
'Tile'
)
{
final
int
key
=
int
.
tryParse
(
words
[
2
]);
final
int
?
key
=
int
.
tryParse
(
words
[
2
]);
final
String
url
=
words
[
4
];
if
(
key
!=
null
)
{
tiles
[
key
]
=
url
;
final
String
url
=
words
[
4
];
tiles
[
key
]
=
url
;
}
}
}
}
}
return
tiles
;
return
tiles
;
...
...
packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart
View file @
c584a5ea
...
@@ -91,7 +91,7 @@ void main() {
...
@@ -91,7 +91,7 @@ void main() {
final
FakeFuchsiaWorkflow
fuchsiaWorkflow
=
FakeFuchsiaWorkflow
(
canListDevices:
false
);
final
FakeFuchsiaWorkflow
fuchsiaWorkflow
=
FakeFuchsiaWorkflow
(
canListDevices:
false
);
final
FuchsiaDevices
fuchsiaDevices
=
FuchsiaDevices
(
final
FuchsiaDevices
fuchsiaDevices
=
FuchsiaDevices
(
platform:
FakePlatform
(),
platform:
FakePlatform
(),
fuchsiaSdk:
null
,
fuchsiaSdk:
FakeFuchsiaSdk
(
devices:
'ignored'
)
,
fuchsiaWorkflow:
fuchsiaWorkflow
,
fuchsiaWorkflow:
fuchsiaWorkflow
,
logger:
BufferLogger
.
test
(),
logger:
BufferLogger
.
test
(),
);
);
...
@@ -154,7 +154,7 @@ void main() {
...
@@ -154,7 +154,7 @@ void main() {
testUsingContext
(
'disposing device disposes the portForwarder'
,
()
async
{
testUsingContext
(
'disposing device disposes the portForwarder'
,
()
async
{
final
FakePortForwarder
portForwarder
=
FakePortForwarder
();
final
FakePortForwarder
portForwarder
=
FakePortForwarder
();
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
device
.
portForwarder
=
portForwarder
;
device
.
portForwarder
=
portForwarder
;
await
device
.
dispose
();
await
device
.
dispose
();
...
@@ -162,7 +162,7 @@ void main() {
...
@@ -162,7 +162,7 @@ void main() {
});
});
testWithoutContext
(
'default capabilities'
,
()
async
{
testWithoutContext
(
'default capabilities'
,
()
async
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
final
FlutterProject
project
=
FlutterProject
.
fromDirectoryTest
(
memoryFileSystem
.
currentDirectory
);
final
FlutterProject
project
=
FlutterProject
.
fromDirectoryTest
(
memoryFileSystem
.
currentDirectory
);
memoryFileSystem
.
directory
(
'fuchsia'
).
createSync
(
recursive:
true
);
memoryFileSystem
.
directory
(
'fuchsia'
).
createSync
(
recursive:
true
);
memoryFileSystem
.
file
(
'pubspec.yaml'
).
createSync
();
memoryFileSystem
.
file
(
'pubspec.yaml'
).
createSync
();
...
@@ -174,13 +174,13 @@ void main() {
...
@@ -174,13 +174,13 @@ void main() {
});
});
test
(
'is ephemeral'
,
()
{
test
(
'is ephemeral'
,
()
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
expect
(
device
.
ephemeral
,
true
);
expect
(
device
.
ephemeral
,
true
);
});
});
testWithoutContext
(
'supported for project'
,
()
async
{
testWithoutContext
(
'supported for project'
,
()
async
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
final
FlutterProject
project
=
FlutterProject
.
fromDirectoryTest
(
memoryFileSystem
.
currentDirectory
);
final
FlutterProject
project
=
FlutterProject
.
fromDirectoryTest
(
memoryFileSystem
.
currentDirectory
);
memoryFileSystem
.
directory
(
'fuchsia'
).
createSync
(
recursive:
true
);
memoryFileSystem
.
directory
(
'fuchsia'
).
createSync
(
recursive:
true
);
memoryFileSystem
.
file
(
'pubspec.yaml'
).
createSync
();
memoryFileSystem
.
file
(
'pubspec.yaml'
).
createSync
();
...
@@ -189,7 +189,7 @@ void main() {
...
@@ -189,7 +189,7 @@ void main() {
});
});
testWithoutContext
(
'not supported for project'
,
()
async
{
testWithoutContext
(
'not supported for project'
,
()
async
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
final
FlutterProject
project
=
FlutterProject
.
fromDirectoryTest
(
memoryFileSystem
.
currentDirectory
);
final
FlutterProject
project
=
FlutterProject
.
fromDirectoryTest
(
memoryFileSystem
.
currentDirectory
);
memoryFileSystem
.
file
(
'pubspec.yaml'
).
createSync
();
memoryFileSystem
.
file
(
'pubspec.yaml'
).
createSync
();
...
@@ -197,7 +197,7 @@ void main() {
...
@@ -197,7 +197,7 @@ void main() {
});
});
testUsingContext
(
'targetPlatform does not throw when sshConfig is missing'
,
()
async
{
testUsingContext
(
'targetPlatform does not throw when sshConfig is missing'
,
()
async
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
expect
(
await
device
.
targetPlatform
,
TargetPlatform
.
fuchsia_arm64
);
expect
(
await
device
.
targetPlatform
,
TargetPlatform
.
fuchsia_arm64
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
...
@@ -212,7 +212,7 @@ void main() {
...
@@ -212,7 +212,7 @@ void main() {
stdout:
'aarch64'
,
stdout:
'aarch64'
,
));
));
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
expect
(
await
device
.
targetPlatform
,
TargetPlatform
.
fuchsia_arm64
);
expect
(
await
device
.
targetPlatform
,
TargetPlatform
.
fuchsia_arm64
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
...
@@ -226,7 +226,7 @@ void main() {
...
@@ -226,7 +226,7 @@ void main() {
stdout:
'x86_64'
,
stdout:
'x86_64'
,
));
));
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
expect
(
await
device
.
targetPlatform
,
TargetPlatform
.
fuchsia_x64
);
expect
(
await
device
.
targetPlatform
,
TargetPlatform
.
fuchsia_x64
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
...
@@ -240,7 +240,7 @@ void main() {
...
@@ -240,7 +240,7 @@ void main() {
stdout:
'fe80::8c6c:2fff:fe3d:c5e1%ethp0003 50666 fe80::5054:ff:fe63:5e7a%ethp0003 22'
,
stdout:
'fe80::8c6c:2fff:fe3d:c5e1%ethp0003 50666 fe80::5054:ff:fe63:5e7a%ethp0003 22'
,
));
));
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'id'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'id'
,
name:
'device'
);
expect
(
await
device
.
hostAddress
,
'fe80::8c6c:2fff:fe3d:c5e1%25ethp0003'
);
expect
(
await
device
.
hostAddress
,
'fe80::8c6c:2fff:fe3d:c5e1%25ethp0003'
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
...
@@ -254,7 +254,7 @@ void main() {
...
@@ -254,7 +254,7 @@ void main() {
exitCode:
1
,
exitCode:
1
,
));
));
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'id'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'id'
,
name:
'device'
);
await
expectLater
(()
=>
device
.
hostAddress
,
throwsToolExit
());
await
expectLater
(()
=>
device
.
hostAddress
,
throwsToolExit
());
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
...
@@ -267,7 +267,7 @@ void main() {
...
@@ -267,7 +267,7 @@ void main() {
command:
<
String
>[
'ssh'
,
'-F'
,
'/ssh_config'
,
'id'
,
r'echo $SSH_CONNECTION'
],
command:
<
String
>[
'ssh'
,
'-F'
,
'/ssh_config'
,
'id'
,
r'echo $SSH_CONNECTION'
],
));
));
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'id'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'id'
,
name:
'device'
);
expect
(()
async
=>
device
.
hostAddress
,
throwsToolExit
());
expect
(()
async
=>
device
.
hostAddress
,
throwsToolExit
());
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
...
@@ -289,7 +289,7 @@ void main() {
...
@@ -289,7 +289,7 @@ void main() {
processManager
.
addCommand
(
const
FakeCommand
(
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'ssh'
,
'-F'
,
'/artifact'
,
'id'
,
'find /hub -name vmservice-port'
],
command:
<
String
>[
'ssh'
,
'-F'
,
'/artifact'
,
'id'
,
'find /hub -name vmservice-port'
],
));
));
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'id'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'id'
,
name:
'device'
);
await
expectLater
(
device
.
servicePorts
,
throwsToolExit
(
message:
'No Dart Observatories found. Are you running a debug build?'
));
await
expectLater
(
device
.
servicePorts
,
throwsToolExit
(
message:
'No Dart Observatories found. Are you running a debug build?'
));
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
...
@@ -766,7 +766,7 @@ void main() {
...
@@ -766,7 +766,7 @@ void main() {
});
});
testUsingContext
(
'does not throw on non-existent ssh config'
,
()
async
{
testUsingContext
(
'does not throw on non-existent ssh config'
,
()
async
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
expect
(
await
device
.
sdkNameAndVersion
,
equals
(
'Fuchsia'
));
expect
(
await
device
.
sdkNameAndVersion
,
equals
(
'Fuchsia'
));
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
...
@@ -780,7 +780,7 @@ void main() {
...
@@ -780,7 +780,7 @@ void main() {
command:
<
String
>[
'ssh'
,
'-F'
,
'/ssh_config'
,
'123'
,
'cat /pkgfs/packages/build-info/0/data/version'
],
command:
<
String
>[
'ssh'
,
'-F'
,
'/ssh_config'
,
'123'
,
'cat /pkgfs/packages/build-info/0/data/version'
],
stdout:
'version'
stdout:
'version'
));
));
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
expect
(
await
device
.
sdkNameAndVersion
,
equals
(
'Fuchsia version'
));
expect
(
await
device
.
sdkNameAndVersion
,
equals
(
'Fuchsia version'
));
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
...
@@ -794,7 +794,7 @@ void main() {
...
@@ -794,7 +794,7 @@ void main() {
command:
<
String
>[
'ssh'
,
'-F'
,
'/ssh_config'
,
'123'
,
'cat /pkgfs/packages/build-info/0/data/version'
],
command:
<
String
>[
'ssh'
,
'-F'
,
'/ssh_config'
,
'123'
,
'cat /pkgfs/packages/build-info/0/data/version'
],
exitCode:
1
,
exitCode:
1
,
));
));
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
expect
(
await
device
.
sdkNameAndVersion
,
equals
(
'Fuchsia'
));
expect
(
await
device
.
sdkNameAndVersion
,
equals
(
'Fuchsia'
));
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
...
@@ -807,7 +807,7 @@ void main() {
...
@@ -807,7 +807,7 @@ void main() {
processManager
.
addCommand
(
const
FakeCommand
(
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'ssh'
,
'-F'
,
'/ssh_config'
,
'123'
,
'cat /pkgfs/packages/build-info/0/data/version'
],
command:
<
String
>[
'ssh'
,
'-F'
,
'/ssh_config'
,
'123'
,
'cat /pkgfs/packages/build-info/0/data/version'
],
));
));
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
expect
(
await
device
.
sdkNameAndVersion
,
equals
(
'Fuchsia'
));
expect
(
await
device
.
sdkNameAndVersion
,
equals
(
'Fuchsia'
));
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
...
...
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