Skip to content

[beta] [flutter_tools] Fix ADB device listing output parsing regression - #189446

Merged
auto-submit[bot] merged 1 commit into
flutter:flutter-3.47-candidate.0from
bkonyi:cherry-pick-189369-to-beta
Jul 15, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:flutter-3.47-candidate.0from
bkonyi:cherry-pick-189369-to-beta

Conversation

@bkonyi

@bkonyi bkonyi commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is created by automatic cherry pick workflow

Issue Link:

#189274

Impact Description:

Fixes a regression in flutter_tools where adb devices -l output containing non-key-value attributes (e.g. ABCDEFG device 20-30 product:mokey ...) causes regex backtracking, incorrectly capturing ABCDEFG device into the device ID. This breaks device discovery and prevents running apps on affected Android devices/bots in devicelab.

Changelog Description:

[flutter_tools] When parsing ADB device output containing non-key-value attributes on Android, flutter tool misparses the device ID.

Workaround:

None.

Risk:

  • Low
  • Medium
  • High

Test Coverage:

  • Yes
  • No

Validation Steps:

Run flutter test test/general.shard/android/android_device_discovery_test.dart to verify device regex output parsing.

…tter#189369)

Fixes a regression introduced in
629df07 where `adb devices -l` output
containing non-key-value attributes (e.g. `ABCDEFG device 20-30
product:mokey model:mokey device:mokey transport_id:1`) caused regex
lazy-matching to backtrack, incorrectly capturing `ABCDEFG device` into
Group 1 (the device ID).

This change:
* Updates `_kDeviceRegex` in `android_device_discovery.dart` to
explicitly match known ADB device states (`device`, `offline`,
`unauthorized`, `no permissions`, etc.) and require a column delimiter
of at least two spaces or a tab (`(?:\s{2,}|\t+)`).
* Adds regression unit test coverage in
`android_device_discovery_test.dart`.

Related to flutter#189274

## Tests

* Added regression unit test in `android_device_discovery_test.dart` for
ADB output containing non-key-value attributes.
* Added unit test for wireless serial names containing spaces and state
keywords (`my device (2)`).

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@bkonyi bkonyi added the cp: review Cherry-picks in the review queue label Jul 14, 2026
@bkonyi
bkonyi requested a review from a team as a code owner July 14, 2026 15:36
@bkonyi
bkonyi requested review from reidbaker and removed request for a team July 14, 2026 15:36
@bkonyi bkonyi added the cp: review Cherry-picks in the review queue label Jul 14, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jul 14, 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 Jul 14, 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.

@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 ADB device parsing regular expression in android_device_discovery.dart to explicitly match known device states and require a stronger column separator, and adds unit tests to verify parsing with extra attributes and spaces in serials. The review feedback notes that the new regex fails to match devices in the no permissions state when followed by a semicolon suffix (common on Linux without udev rules), and suggests adjusting the regex to support semicolon separators and adding a test case for this scenario.

@reidbaker
reidbaker requested review from justinmc and mboetger and removed request for reidbaker July 14, 2026 21:23

@justinmc justinmc 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.

LGTM 👍

@justinmc justinmc added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 15, 2026
@auto-submit
auto-submit Bot merged commit c7edcb6 into flutter:flutter-3.47-candidate.0 Jul 15, 2026
153 checks passed
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.

3 participants