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
7acc9965
Commit
7acc9965
authored
Oct 27, 2016
by
Dan Rubel
Committed by
GitHub
Oct 27, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update Android device detection to handle adb error messages (#6521)
parent
ca90656f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
4 deletions
+25
-4
android_device.dart
packages/flutter_tools/lib/src/android/android_device.dart
+10
-4
android_device_test.dart
packages/flutter_tools/test/android_device_test.dart
+15
-0
No files found.
packages/flutter_tools/lib/src/android/android_device.dart
View file @
7acc9965
...
...
@@ -629,18 +629,24 @@ final RegExp _kDeviceRegex = new RegExp(r'^(\S+)\s+(\S+)(.*)');
/// [mockAdbOutput] is public for testing.
List
<
AndroidDevice
>
getAdbDevices
({
String
mockAdbOutput
})
{
List
<
AndroidDevice
>
devices
=
<
AndroidDevice
>[];
List
<
String
>
outpu
t
;
String
tex
t
;
if
(
mockAdbOutput
==
null
)
{
String
adbPath
=
getAdbPath
(
androidSdk
);
if
(
adbPath
==
null
)
return
<
AndroidDevice
>[];
output
=
runSync
(<
String
>[
adbPath
,
'devices'
,
'-l'
]).
trim
().
split
(
'
\n
'
);
text
=
runSync
(<
String
>[
adbPath
,
'devices'
,
'-l'
]
);
}
else
{
output
=
mockAdbOutput
.
trim
().
split
(
'
\n
'
)
;
text
=
mockAdbOutput
;
}
for
(
String
line
in
output
)
{
// Check for error messages from adb
if
(!
text
.
contains
(
'List of devices'
))
{
printError
(
text
);
return
<
AndroidDevice
>[];
}
for
(
String
line
in
text
.
trim
().
split
(
'
\n
'
))
{
// Skip lines like: * daemon started successfully *
if
(
line
.
startsWith
(
'* daemon '
))
continue
;
...
...
packages/flutter_tools/test/android_device_test.dart
View file @
7acc9965
...
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import
'package:flutter_tools/src/android/android_device.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:test/test.dart'
;
import
'src/context.dart'
;
...
...
@@ -41,11 +42,25 @@ emulator-5612 host features:shell_2
testUsingContext
(
'android n'
,
()
{
List
<
AndroidDevice
>
devices
=
getAdbDevices
(
mockAdbOutput:
'''
List of devices attached
ZX1G22JJWR device usb:3-3 product:shamu model:Nexus_6 device:shamu features:cmd,shell_v2
'''
);
expect
(
devices
,
hasLength
(
1
));
expect
(
devices
.
first
.
name
,
'Nexus 6'
);
});
BufferLogger
logger
=
new
BufferLogger
();
testUsingContext
(
'adb error message'
,
()
{
List
<
AndroidDevice
>
devices
=
getAdbDevices
(
mockAdbOutput:
'''
It appears you do not have '
Android
SDK
Platform
-
tools
' installed.
Use the '
android
' tool to install them:
android update sdk --no-ui --filter '
platform
-
tools
'
'''
);
expect
(
devices
,
hasLength
(
0
));
expect
(
logger
.
errorText
,
contains
(
'you do not have'
));
},
overrides:
<
Type
,
dynamic
>{
Logger
:
logger
,
});
});
group
(
'parseAdbDeviceProperties'
,
()
{
...
...
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