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
60755f6d
Commit
60755f6d
authored
Apr 29, 2016
by
Devon Carew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix an issue parsing adb output (#3629)
parent
99114cd4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
10 deletions
+45
-10
android_device.dart
packages/flutter_tools/lib/src/android/android_device.dart
+21
-10
android_device_test.dart
packages/flutter_tools/test/android_device_test.dart
+24
-0
No files found.
packages/flutter_tools/lib/src/android/android_device.dart
View file @
60755f6d
...
...
@@ -55,8 +55,12 @@ class AndroidDevice extends Device {
bool
get
isLocalEmulator
{
if
(
_isLocalEmulator
==
null
)
{
// http://developer.android.com/ndk/guides/abis.html (x86, armeabi-v7a, ...)
try
{
String
value
=
runCheckedSync
(
adbCommandForDevice
([
'shell'
,
'getprop'
,
'ro.product.cpu.abi'
]));
_isLocalEmulator
=
value
.
startsWith
(
'x86'
);
}
catch
(
error
)
{
_isLocalEmulator
=
false
;
}
}
return
_isLocalEmulator
;
...
...
@@ -390,14 +394,21 @@ class AndroidDevice extends Device {
}
}
List
<
AndroidDevice
>
getAdbDevices
()
{
/// Return the list of connected ADB devices.
///
/// [mockAdbOutput] is public for testing.
List
<
AndroidDevice
>
getAdbDevices
({
String
mockAdbOutput
})
{
List
<
AndroidDevice
>
devices
=
[];
List
<
String
>
output
;
if
(
mockAdbOutput
==
null
)
{
String
adbPath
=
getAdbPath
(
androidSdk
);
if
(
adbPath
==
null
)
return
<
AndroidDevice
>[];
List
<
AndroidDevice
>
devices
=
[];
List
<
String
>
output
=
runSync
(<
String
>[
adbPath
,
'devices'
,
'-l'
]).
trim
().
split
(
'
\n
'
);
output
=
runSync
(<
String
>[
adbPath
,
'devices'
,
'-l'
]).
trim
().
split
(
'
\n
'
);
}
else
{
output
=
mockAdbOutput
.
trim
().
split
(
'
\n
'
);
}
// 015d172c98400a03 device usb:340787200X product:nakasi model:Nexus_7 device:grouper
RegExp
deviceRegExLong
=
new
RegExp
(
...
...
@@ -445,7 +456,7 @@ List<AndroidDevice> getAdbDevices() {
}
else
if
(
deviceState
==
'offline'
)
{
printError
(
'Device
$deviceID
is offline.'
);
}
else
{
devices
.
add
(
new
AndroidDevice
(
deviceID
));
devices
.
add
(
new
AndroidDevice
(
deviceID
,
modelID:
deviceID
));
}
}
else
{
printError
(
...
...
packages/flutter_tools/test/android_device_test.dart
View file @
60755f6d
...
...
@@ -15,4 +15,28 @@ void main() {
expect
(
device
.
id
,
equals
(
deviceId
));
});
});
group
(
'getAdbDevices'
,
()
{
testUsingContext
(
'physical devices'
,
()
{
List
<
AndroidDevice
>
devices
=
getAdbDevices
(
mockAdbOutput:
'''
List of devices attached
05a02bac device usb:336592896X product:razor model:Nexus_7 device:flo
'''
);
expect
(
devices
,
hasLength
(
1
));
expect
(
devices
.
first
.
name
,
'Nexus 7'
);
});
testUsingContext
(
'emulators and short listings'
,
()
{
List
<
AndroidDevice
>
devices
=
getAdbDevices
(
mockAdbOutput:
'''
List of devices attached
localhost:36790 device
0149947A0D01500C device usb:340787200X
emulator-5612 host features:shell_2
'''
);
expect
(
devices
,
hasLength
(
3
));
expect
(
devices
.
first
.
name
,
'localhost:36790'
);
});
});
}
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