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
e365453e
Commit
e365453e
authored
May 04, 2016
by
Devon Carew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better parsing of adb devices output (#3726)
* better parsing of adb devices output * re-order lines
parent
b0467069
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
30 deletions
+37
-30
adb.dart
packages/flutter_tools/lib/src/android/adb.dart
+2
-2
android_device.dart
packages/flutter_tools/lib/src/android/android_device.dart
+27
-28
android_device_test.dart
packages/flutter_tools/test/android_device_test.dart
+8
-0
No files found.
packages/flutter_tools/lib/src/android/adb.dart
View file @
e365453e
...
...
@@ -166,7 +166,7 @@ class AdbDevice {
// 'TA95000FQA device usb:340787200X product:peregrine_retus model:XT1045 device:peregrine'
// '015d172c98400a03 device usb:340787200X product:nakasi model:Nexus_7 device:grouper'
Match
match
=
d
eviceRegex
.
firstMatch
(
deviceInfo
);
Match
match
=
kD
eviceRegex
.
firstMatch
(
deviceInfo
);
id
=
match
[
1
];
status
=
match
[
2
];
...
...
@@ -185,7 +185,7 @@ class AdbDevice {
modelID
=
cleanAdbDeviceName
(
modelID
);
}
static
final
RegExp
d
eviceRegex
=
new
RegExp
(
r'^(\S+)\s+(\S+)(.*)'
);
static
final
RegExp
kD
eviceRegex
=
new
RegExp
(
r'^(\S+)\s+(\S+)(.*)'
);
/// Always non-null; something like `TA95000FQA`.
String
id
;
...
...
packages/flutter_tools/lib/src/android/android_device.dart
View file @
e365453e
...
...
@@ -403,6 +403,9 @@ class AndroidDevice extends Device {
}
}
// 015d172c98400a03 device usb:340787200X product:nakasi model:Nexus_7 device:grouper
final
RegExp
_kDeviceRegex
=
new
RegExp
(
r'^(\S+)\s+(\S+)(.*)'
);
/// Return the list of connected ADB devices.
///
/// [mockAdbOutput] is public for testing.
...
...
@@ -419,15 +422,6 @@ List<AndroidDevice> getAdbDevices({ String mockAdbOutput }) {
output
=
mockAdbOutput
.
trim
().
split
(
'
\n
'
);
}
// 015d172c98400a03 device usb:340787200X product:nakasi model:Nexus_7 device:grouper
RegExp
deviceRegExLong
=
new
RegExp
(
r'^(\S+)\s+device\s+.*product:(\S+)\s+model:(\S+)\s+device:(\S+)$'
);
// 0149947A0D01500C device usb:340787200X
// emulator-5612 host features:shell_2
// emulator-5554 offline
RegExp
deviceRegExShort
=
new
RegExp
(
r'^(\S+)\s+(\S+)(\s+\S+)?$'
);
for
(
String
line
in
output
)
{
// Skip lines like: * daemon started successfully *
if
(
line
.
startsWith
(
'* daemon '
))
...
...
@@ -436,26 +430,26 @@ List<AndroidDevice> getAdbDevices({ String mockAdbOutput }) {
if
(
line
.
startsWith
(
'List of devices'
))
continue
;
if
(
deviceRegExLong
.
hasMatch
(
line
))
{
Match
match
=
deviceRegExLong
.
firstMatch
(
line
);
String
deviceID
=
match
[
1
];
String
productID
=
match
[
2
];
String
modelID
=
match
[
3
];
String
deviceCodeName
=
match
[
4
];
if
(
modelID
!=
null
)
modelID
=
cleanAdbDeviceName
(
modelID
);
devices
.
add
(
new
AndroidDevice
(
deviceID
,
productID:
productID
,
modelID:
modelID
,
deviceCodeName:
deviceCodeName
));
}
else
if
(
deviceRegExShort
.
hasMatch
(
line
))
{
Match
match
=
deviceRegExShort
.
firstMatch
(
line
);
if
(
_kDeviceRegex
.
hasMatch
(
line
))
{
Match
match
=
_kDeviceRegex
.
firstMatch
(
line
);
String
deviceID
=
match
[
1
];
String
deviceState
=
match
[
2
];
String
rest
=
match
[
3
];
Map
<
String
,
String
>
info
=
<
String
,
String
>{};
if
(
rest
!=
null
&&
rest
.
isNotEmpty
)
{
rest
=
rest
.
trim
();
for
(
String
data
in
rest
.
split
(
' '
))
{
if
(
data
.
contains
(
':'
))
{
List
<
String
>
fields
=
data
.
split
(
':'
);
info
[
fields
[
0
]]
=
fields
[
1
];
}
}
}
if
(
info
[
'model'
]
!=
null
)
info
[
'model'
]
=
cleanAdbDeviceName
(
info
[
'model'
]);
if
(
deviceState
==
'unauthorized'
)
{
printError
(
...
...
@@ -465,7 +459,12 @@ List<AndroidDevice> getAdbDevices({ String mockAdbOutput }) {
}
else
if
(
deviceState
==
'offline'
)
{
printError
(
'Device
$deviceID
is offline.'
);
}
else
{
devices
.
add
(
new
AndroidDevice
(
deviceID
,
modelID:
deviceID
));
devices
.
add
(
new
AndroidDevice
(
deviceID
,
productID:
info
[
'product'
],
modelID:
info
[
'model'
]
??
deviceID
,
deviceCodeName:
info
[
'device'
]
));
}
}
else
{
printError
(
...
...
packages/flutter_tools/test/android_device_test.dart
View file @
e365453e
...
...
@@ -38,5 +38,13 @@ emulator-5612 host features:shell_2
expect
(
devices
,
hasLength
(
3
));
expect
(
devices
.
first
.
name
,
'localhost:36790'
);
});
testUsingContext
(
'android n'
,
()
{
List
<
AndroidDevice
>
devices
=
getAdbDevices
(
mockAdbOutput:
'''
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'
);
});
});
}
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