Repository navigation
[flutter_tools] Parse single-space wireless ADB device output - #189431
Closed
Ram-Dawson wants to merge 2 commits into
Closed
Ram-Dawson wants to merge 2 commits into
Ram-Dawson wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds a fallback regular expression to correctly parse ADB devices with long mDNS serials separated by a single space, along with a corresponding test case. The review feedback suggests updating the comment for the new regex to use triple-slash documentation format (///) to align with the Flutter Style Guide.
…y.dart Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
mboetger
approved these changes
Jul 14, 2026
Contributor
|
Thanks for the contribution @Ram-Dawson! However, a fix for this issue has already been landed: #189369. |
This was referenced Jul 24, 2026
Closed
navaronbracke
pushed a commit
to navaronbracke/flutter
that referenced
this pull request
Jul 29, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes Android device discovery when
adb devices -lseparates a long wirelessmDNS serial and its device state with a single space.
The existing parser accepts two spaces or a tab as the delimiter. Some ADB
output uses a single space instead, causing Flutter to report an unexpected
parsing failure and omit the wireless device.
This change adds a fallback parser for single-space delimiters when the serial
contains no spaces. The existing parser remains the preferred path so mDNS
conflict names containing spaces continue to be handled correctly.
Fixes #189430
Testing
flutter test packages/flutter_tools/test/general.shard/android/android_device_discovery_test.dartflutter analyze packages/flutter_toolsManual verification
Using the same wireless ADB device output:
master(3.47.0-1.0.pre-58, framework11faf0ac6ec69abcc7267e372a703f6d63d5b86f) reports an ADB parsingfailure and omits the device.
22127RK46C (wireless).Pre-launch Checklist
///).