Skip to content

[stable] fix(tool): parse ADB device lists by connection state - #191296

Merged
auto-submit[bot] merged 1 commit into
flutter:flutter-3.47-candidate.0from
flutteractionsbot:cp-stable-9c98b2622b4dcc656c1d822a6c2497cfd6c316f4
Aug 18, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:flutter-3.47-candidate.0from
flutteractionsbot:cp-stable-9c98b2622b4dcc656c1d822a6c2497cfd6c316f4

Conversation

@flutteractionsbot

@flutteractionsbot flutteractionsbot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is created by automatic cherry pick workflow
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.

Issue Link:

#189972

Impact Description:

ADB formats long device list rows using %-22s %s (minimum width 22 characters). For long wireless device serials ($\ge 22$ chars) or wireless serials with mDNS conflict suffixes (such as (2)), ADB outputs only a single space before the connection state. The previous parser required two or more spaces before the state, causing flutter_tools to fail parsing these rows, report unexpected ADB parsing errors, and omit connected wireless Android devices from flutter devices and IDEs.

Changelog Description:

[flutter/189972] Fix ADB device list parsing for long wireless mDNS serials separated from state by a single space.

Workaround:

Use wired USB debugging or reconnect wireless debugging.

Risk:

  • Low
  • Medium
  • High

Test Coverage:

  • Yes
  • No

Validation Steps:

  1. Connect a wireless Android device whose serial contains $\ge 22$ characters or an mDNS conflict suffix (2).
  2. Run flutter devices -v.
  3. Confirm that the wireless Android device is listed and its full serial is recognized without parser errors.
  4. Run packages/flutter_tools/test/general.shard/android/android_device_discovery_test.dart.

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.
@flutteractionsbot
flutteractionsbot requested a review from a team as a code owner August 18, 2026 18:21
@flutteractionsbot
flutteractionsbot requested review from mboetger and removed request for a team August 18, 2026 18:21
@flutteractionsbot flutteractionsbot added the cp: review Cherry-picks in the review queue label Aug 18, 2026
@flutteractionsbot

Copy link
Copy Markdown
Contributor Author

@bkonyi please fill out the PR description above, afterwards the release team will review this request.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 18, 2026
@github-actions github-actions Bot added tool Affects the "flutter" command-line tool. See also t: labels. team-android Owned by Android platform team labels Aug 18, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter.

Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed.

@bkonyi bkonyi changed the title [CP-stable]fix(tool): parse ADB device lists by connection state [stable] fix(tool): parse ADB device lists by connection state Aug 18, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the regular expression used to parse the output of adb devices -l in android_device_discovery.dart to greedily match the device serial number. This allows the parser to handle serials that are 22 characters or longer followed by a single space, as well as serials containing whitespace. The parsed device ID is trimmed of trailing whitespace, and several unit tests are added to verify the changes across various ADB states and serial formats. There are no review comments, so no feedback is provided.

@eyebrowsoffire eyebrowsoffire added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 18, 2026
@auto-submit
auto-submit Bot merged commit 1926f75 into flutter:flutter-3.47-candidate.0 Aug 18, 2026
10 checks passed
@flutteractionsbot
flutteractionsbot deleted the cp-stable-9c98b2622b4dcc656c1d822a6c2497cfd6c316f4 branch August 18, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD cp: review Cherry-picks in the review queue team-android Owned by Android platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants