Improve adb devices parsing by rom1v · Pull Request #6664 · Genymobile/scrcpy (original) (raw)
This was referenced
Feb 9, 2026
rom1v added a commit that referenced this pull request
adb devices -l prints one device per line, containing, separated by
spaces:
- the device serial,
- the device state,
- a list of key:value pairs.
However, the device serial itself may contain spaces, making a simple split ambiguous.
To avoid ambiguity, parse the string backwards:
- first, parse all the trailing values until the device state, identified using a list of well-known values;
- finally, treat the remaining leading token as the device serial.
adb devices -l prints one device per line, containing, separated by
spaces:
- the device serial,
- the device state,
- a list of key:value pairs.
However, the device serial itself may contain spaces, making a simple split ambiguous.
To avoid ambiguity, parse the string backwards:
- first, parse all the trailing values until the device state, identified using a list of well-known values;
- finally, treat the remaining leading token as the device serial.
Fixes #3537 <#3537> Refs #6248 <#6248> PR #6664 <#6664>
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
[ Show hidden characters]({{ revealButtonHref }})