Add adb connect and disconnect
PR #2827 <https://github.com/Genymobile/scrcpy/pull/2827>
This commit is contained in:
parent
e6e6f865a0
commit
bfce22414f
2 changed files with 35 additions and 0 deletions
|
@ -314,6 +314,24 @@ adb_install(struct sc_intr *intr, const char *serial, const char *local,
|
||||||
return process_check_success_intr(intr, pid, "adb install", flags);
|
return process_check_success_intr(intr, pid, "adb install", flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
adb_connect(struct sc_intr *intr, const char *ip_port, unsigned flags) {
|
||||||
|
const char *const adb_cmd[] = {"connect", ip_port};
|
||||||
|
|
||||||
|
sc_pid pid = adb_execute(NULL, adb_cmd, ARRAY_LEN(adb_cmd), flags);
|
||||||
|
return process_check_success_intr(intr, pid, "adb connect", flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
adb_disconnect(struct sc_intr *intr, const char *ip_port, unsigned flags) {
|
||||||
|
const char *const adb_cmd[] = {"disconnect", ip_port};
|
||||||
|
size_t len = ip_port ? ARRAY_LEN(adb_cmd)
|
||||||
|
: ARRAY_LEN(adb_cmd) - 1;
|
||||||
|
|
||||||
|
sc_pid pid = adb_execute(NULL, adb_cmd, len, flags);
|
||||||
|
return process_check_success_intr(intr, pid, "adb disconnect", flags);
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
adb_get_serialno(struct sc_intr *intr, unsigned flags) {
|
adb_get_serialno(struct sc_intr *intr, unsigned flags) {
|
||||||
const char *const adb_cmd[] = {"get-serialno"};
|
const char *const adb_cmd[] = {"get-serialno"};
|
||||||
|
|
|
@ -41,6 +41,23 @@ bool
|
||||||
adb_install(struct sc_intr *intr, const char *serial, const char *local,
|
adb_install(struct sc_intr *intr, const char *serial, const char *local,
|
||||||
unsigned flags);
|
unsigned flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute `adb connect <ip_port>`
|
||||||
|
*
|
||||||
|
* `ip_port` may not be NULL.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
adb_connect(struct sc_intr *intr, const char *ip_port, unsigned flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute `adb disconnect [<ip_port>]`
|
||||||
|
*
|
||||||
|
* If `ip_port` is NULL, execute `adb disconnect`.
|
||||||
|
* Otherwise, execute `adb disconnect <ip_port>`.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
adb_disconnect(struct sc_intr *intr, const char *ip_port, unsigned flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute `adb get-serialno`
|
* Execute `adb get-serialno`
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue