Repository navigation
fix(tool): parse ADB device lists by connection state - #189973
Merged
auto-submit[bot] merged 1 commit intoJul 29, 2026
Merged
auto-submit[bot] merged 1 commit into
auto-submit[bot] merged 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the ADB device parsing regular expression in android_device_discovery.dart to use greedy matching for the device serial, followed by trimming trailing whitespace from the parsed device ID. This change allows correct parsing of long serials and serials containing whitespace (such as mDNS conflict suffixes). Extensive unit tests are added to cover these scenarios and various ADB states. Feedback was provided to update the regex documentation comments to use triple-slash (///) documentation comments in accordance with the Flutter Style Guide.
bkonyi
self-requested a review
July 27, 2026 19:26
bkonyi
approved these changes
Jul 27, 2026
bkonyi
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the follow up fix, and sorry for not getting back to you sooner! LGTM!
mboetger
approved these changes
Jul 27, 2026
This was referenced Jul 30, 2026
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.
Fixes #189972
Related to #189430 and #189369. This supersedes the narrower parser approach from closed PR #189431.
Summary
ADB formats long device-list rows as
%-22s %s: 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 #189369 correctly protects serials containing whitespace by requiring two spaces or a tab before the state. PR #189431 proposed a narrower one-space fallback for serials without whitespace and was closed after #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:
(2)withdeviceandofflinestates;Ran:
The device-discovery test file passed with 16 tests, and analysis reported no issues.
Real-device validation
After deleting
bin/cache/flutter_tools.snapshot, unmodifiedupstream/masterat0ed149e63db1f68d2042063baf0a99d969ccd84bomitted the wireless Android device and reported an unexpected ADB parsing failure. With this patch,flutter devices -vlisted the device with the complete mDNS conflict serial and successfully used that serial foradb -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
///).