fix(tool): parse ADB device lists by connection state (#189973) 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`](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 #189369](https://github.com/flutter/flutter/pull/189369) correctly protects serials containing whitespace by requiring two spaces or a tab before the state. [PR #189431](https://github.com/flutter/flutter/pull/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: - 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.
Flutter is Google's SDK for crafting beautiful, fast user experiences for mobile, web, and desktop from a single codebase. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source.
For release and other announcements, join the flutter-announce mailing list. Our documentation also tracks breaking changes across releases.
The Flutter tool may occasionally download resources from Google servers. By downloading or using the Flutter SDK, you agree to the Google Terms of Service: https://policies.google.com/terms
For example, when installed from GitHub (as opposed to from a prepackaged archive), the Flutter tool will download the Dart SDK from Google servers immediately when first run, as it is used to execute the flutter tool itself. This will also occur when Flutter is upgraded (e.g. by running the flutter upgrade command).
We think Flutter will help you create beautiful, fast apps, with a productive, extensible and open development model, whether you're targeting iOS or Android, web, Windows, macOS, Linux or embedding it as the UI toolkit for a platform of your choice.
We want to enable designers to deliver their full creative vision without being forced to water it down due to limitations of the underlying framework. Flutter‘s layered architecture gives you control over every pixel on the screen and its powerful compositing capabilities let you overlay and animate graphics, video, text, and controls without limitation. Flutter includes a full set of widgets that deliver pixel-perfect experiences whether you’re building for iOS (Cupertino) or other platforms (Material), along with support for customizing or creating entirely new visual components.
Flutter is fast. It's powered by hardware-accelerated 2D graphics libraries like Skia (which underpins Chrome and Android) and Impeller. We architected Flutter to support glitch-free, jank-free graphics at the native speed of your device.
Flutter code is powered by the world-class Dart programming language, which enables compilation to 32-bit and 64-bit ARM machine code for iOS and Android, JavaScript and WebAssembly for the web, as well as Intel x64 and ARM for desktop devices.
Flutter offers stateful hot reload, allowing you to make changes to your code and see the results instantly without restarting your app or losing its state.
Flutter works with any development tool (or none at all), and also includes editor plug-ins for both Visual Studio Code and IntelliJ / Android Studio. Flutter provides tens of thousands of packages to speed your development, regardless of your target platform. And accessing other native code is easy, with support for both FFI (on Android, on iOS, on macOS, and on Windows) as well as platform-specific APIs.
Flutter is a fully open-source project, and we welcome contributions. Information on how to get started can be found in our contributor guide.