Expose function to test if a serial is TCP/IP
In practice, it just tests if the serial contains a ':', which is sufficient to distinguish ip:port from a real USB serial. PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005>
This commit is contained in:
parent
4389de1c23
commit
02d46b2262
3 changed files with 15 additions and 4 deletions
|
@ -482,3 +482,8 @@ sc_adb_get_device_ip(struct sc_intr *intr, const char *serial, unsigned flags) {
|
||||||
|
|
||||||
return sc_adb_parse_device_ip_from_output(buf);
|
return sc_adb_parse_device_ip_from_output(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
sc_adb_is_serial_tcpip(const char *serial) {
|
||||||
|
return strchr(serial, ':');
|
||||||
|
}
|
||||||
|
|
|
@ -93,4 +93,13 @@ sc_adb_get_serialno(struct sc_intr *intr, unsigned flags);
|
||||||
char *
|
char *
|
||||||
sc_adb_get_device_ip(struct sc_intr *intr, const char *serial, unsigned flags);
|
sc_adb_get_device_ip(struct sc_intr *intr, const char *serial, unsigned flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate if the serial represents an IP address
|
||||||
|
*
|
||||||
|
* In practice, it just returns true if and only if it contains a ':', which is
|
||||||
|
* sufficient to distinguish an ip:port from a real USB serial.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
sc_adb_is_serial_tcpip(const char *serial);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -659,10 +659,7 @@ sc_server_configure_tcpip_known_address(struct sc_server *server,
|
||||||
static bool
|
static bool
|
||||||
sc_server_configure_tcpip_unknown_address(struct sc_server *server,
|
sc_server_configure_tcpip_unknown_address(struct sc_server *server,
|
||||||
const char *serial) {
|
const char *serial) {
|
||||||
// The serial is either the real serial when connected via USB, or
|
bool is_already_tcpip = sc_adb_is_serial_tcpip(serial);
|
||||||
// the IP:PORT when connected over TCP/IP. Only the latter contains
|
|
||||||
// a colon.
|
|
||||||
bool is_already_tcpip = strchr(serial, ':');
|
|
||||||
if (is_already_tcpip) {
|
if (is_already_tcpip) {
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
LOGI("Device already connected via TCP/IP: %s", serial);
|
LOGI("Device already connected via TCP/IP: %s", serial);
|
||||||
|
|
Loading…
Reference in a new issue