Commit Graph

11 Commits (master)

Author SHA1 Message Date
Romain Vimont 669e9a8d1e Fix "ip route" parsing
If a line did not end with '\r', then the final `\n' was replaced by
'\0' for parsing the current line. This `\0` was then mistakenly
considered as the end of the whole "ip route" output, so the remaining
lines were not parsed, causing "scrcpy --tcpip" to fail in some cases.

To fix the issue, read the final character of the current line before it
is (possibly) overwritten by '\0'.
1 year ago
Romain Vimont b1d8c72780 Rename function to simplify
For consistency with sc_adb_parse_device(), do not include "from_output"
in the function name.
2 years ago
Romain Vimont 55e65fa270 Add missing return 0 in tests 2 years ago
Romain Vimont 69fb5f6ee1 Fix function declarations
Add missing void in function parameters list.
2 years ago
Romain Vimont 4b8cb042c4 Use vector for listing ADB devices
This avoids the hardcoded maximum number of ADB devices detected (16).

Refs #3029 <https://github.com/Genymobile/scrcpy/pull/3029>
PR #3035 <https://github.com/Genymobile/scrcpy/pull/3035>

Co-authored-by: Daniel Ansorregui <d.ansorregui@samsung.com>
2 years ago
Romain Vimont 6edf50d447 Remove fprintf() in tests
It was committed by mistake.
2 years ago
Romain Vimont 4389de1c23 Add adb devices parser
Add a parser of `adb device -l` output, to extract a list of devices
with their serial, state and model.

PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005>
2 years ago
Romain Vimont 5d6bd8f9cd Fix adb device ip parsing
The parser assumed that its input was a NUL-terminated string, but it
was not the case: it is just the raw output of "adb devices ip route".

In practice, it was harmless, since the output always ended with '\n'
(which was replaced by '\0' on truncation), but it was incorrect
nonetheless.

Always write a '\0' at the end of the buffer, and explicitly parse as a
NUL-terminated string. For that purpose, avoid the error-prone
sc_str_truncate() util function.
2 years ago
Romain Vimont 7810ca61b0 Move ADB code to adb/ 2 years ago
Romain Vimont 1fbc590b26 Fix memory leaks in tests
Tests were failing when run with ASAN enabled.
2 years ago
Romain Vimont f609b406c9 Add function to find the device IP address
Parse the result of "adb shell ip route" to find the device IP address.

PR #2827 <https://github.com/Genymobile/scrcpy/pull/2827>
3 years ago