Repository navigation
Commit 9c98b26
authored
fix(tool): parse ADB device lists by connection state (flutter#189973)
Fixes flutter#189972
Related to flutter#189430 and flutter#189369. This supersedes the narrower parser
approach from closed PR flutter#189431.
## Summary
ADB formats long device-list rows as [`%-22s
%s`](https://android.googlesource.com/platform/packages/modules/adb/+/1cf2f017d312f73b3dc53bda85ef2610e35a80e9/transport.cpp#1410):
the serial field has a minimum width, so a long wireless serial can be
separated from its connection state by a single space. mDNS conflict
suffixes can also introduce whitespace inside the serial.
[PR flutter#189369](flutter#189369) correctly
protects serials containing whitespace by requiring two spaces or a tab
before the state. [PR
flutter#189431](flutter#189431) proposed a
narrower one-space fallback for serials without whitespace and was
closed after flutter#189369 landed. The combined case has both an mDNS conflict
suffix and a valid single-space state delimiter, so neither earlier rule
accepts it.
This change parses the explicit known ADB connection-state field instead
of inferring a boundary from whitespace width. The serial capture is
greedy so state-like words and mDNS conflict suffixes remain part of the
serial, and right-side padding from ADB's minimum-width field is
removed.
## Tests
Added regression coverage for:
- ordinary single-space wireless mDNS serials;
- mDNS conflict serials containing ` (2)` with `device` and `offline`
states;
- every state currently recognized by Flutter Tools;
- serials that contain state-like words; and
- existing padded and tab-separated output forms.
Ran:
```text
flutter test packages/flutter_tools/test/general.shard/android/android_device_discovery_test.dart
flutter analyze packages/flutter_tools
```
The device-discovery test file passed with 16 tests, and analysis
reported no issues.
## Real-device validation
After deleting `bin/cache/flutter_tools.snapshot`, unmodified
`upstream/master` at `0ed149e63db1f68d2042063baf0a99d969ccd84b` omitted
the wireless Android device and reported an unexpected ADB parsing
failure. With this patch, `flutter devices -v` listed the device with
the complete mDNS conflict serial and successfully used that serial for
`adb -s ... shell getprop`.
## Scope
This PR changes only Flutter Tools parsing and its Android
device-discovery tests. It does not change ADB, mDNS pairing, wireless
transport behavior, or device-state handling after a row has been
parsed.
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.1 parent ec66198 commit 9c98b26
2 files changed
Lines changed: 87 additions & 8 deletions
File tree
- packages/flutter_tools
- lib/src/android
- test/general.shard/android
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
123 | | - | |
| 122 | + | |
124 | 123 | | |
125 | 124 | | |
126 | 125 | | |
127 | | - | |
| 126 | + | |
128 | 127 | | |
129 | 128 | | |
130 | 129 | | |
| |||
163 | 162 | | |
164 | 163 | | |
165 | 164 | | |
166 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
167 | 168 | | |
168 | 169 | | |
169 | 170 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
241 | 319 | | |
242 | 320 | | |
243 | 321 | | |
| |||
0 commit comments