Use sc_ prefix for adb
This commit is contained in:
parent
7810ca61b0
commit
9e3902f30c
5 changed files with 85 additions and 81 deletions
|
@ -158,7 +158,8 @@ process_check_success_intr(struct sc_intr *intr, sc_pid pid, const char *name,
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char **
|
static const char **
|
||||||
adb_create_argv(const char *serial, const char *const adb_cmd[], size_t len) {
|
sc_adb_create_argv(const char *serial, const char *const adb_cmd[],
|
||||||
|
size_t len) {
|
||||||
const char **argv = malloc((len + 4) * sizeof(*argv));
|
const char **argv = malloc((len + 4) * sizeof(*argv));
|
||||||
if (!argv) {
|
if (!argv) {
|
||||||
LOG_OOM();
|
LOG_OOM();
|
||||||
|
@ -181,9 +182,9 @@ adb_create_argv(const char *serial, const char *const adb_cmd[], size_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static sc_pid
|
static sc_pid
|
||||||
adb_execute_p(const char *serial, const char *const adb_cmd[], size_t len,
|
sc_adb_execute_p(const char *serial, const char *const adb_cmd[], size_t len,
|
||||||
unsigned flags, sc_pipe *pout) {
|
unsigned flags, sc_pipe *pout) {
|
||||||
const char **argv = adb_create_argv(serial, adb_cmd, len);
|
const char **argv = sc_adb_create_argv(serial, adb_cmd, len);
|
||||||
if (!argv) {
|
if (!argv) {
|
||||||
return SC_PROCESS_NONE;
|
return SC_PROCESS_NONE;
|
||||||
}
|
}
|
||||||
|
@ -211,63 +212,63 @@ adb_execute_p(const char *serial, const char *const adb_cmd[], size_t len,
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_pid
|
sc_pid
|
||||||
adb_execute(const char *serial, const char *const adb_cmd[], size_t len,
|
sc_adb_execute(const char *serial, const char *const adb_cmd[], size_t len,
|
||||||
unsigned flags) {
|
unsigned flags) {
|
||||||
return adb_execute_p(serial, adb_cmd, len, flags, NULL);
|
return sc_adb_execute_p(serial, adb_cmd, len, flags, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
adb_forward(struct sc_intr *intr, const char *serial, uint16_t local_port,
|
sc_adb_forward(struct sc_intr *intr, const char *serial, uint16_t local_port,
|
||||||
const char *device_socket_name, unsigned flags) {
|
const char *device_socket_name, unsigned flags) {
|
||||||
char local[4 + 5 + 1]; // tcp:PORT
|
char local[4 + 5 + 1]; // tcp:PORT
|
||||||
char remote[108 + 14 + 1]; // localabstract:NAME
|
char remote[108 + 14 + 1]; // localabstract:NAME
|
||||||
sprintf(local, "tcp:%" PRIu16, local_port);
|
sprintf(local, "tcp:%" PRIu16, local_port);
|
||||||
snprintf(remote, sizeof(remote), "localabstract:%s", device_socket_name);
|
snprintf(remote, sizeof(remote), "localabstract:%s", device_socket_name);
|
||||||
const char *const adb_cmd[] = {"forward", local, remote};
|
const char *const adb_cmd[] = {"forward", local, remote};
|
||||||
|
|
||||||
sc_pid pid = adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd), flags);
|
sc_pid pid = sc_adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd), flags);
|
||||||
return process_check_success_intr(intr, pid, "adb forward", flags);
|
return process_check_success_intr(intr, pid, "adb forward", flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
adb_forward_remove(struct sc_intr *intr, const char *serial,
|
sc_adb_forward_remove(struct sc_intr *intr, const char *serial,
|
||||||
uint16_t local_port, unsigned flags) {
|
uint16_t local_port, unsigned flags) {
|
||||||
char local[4 + 5 + 1]; // tcp:PORT
|
char local[4 + 5 + 1]; // tcp:PORT
|
||||||
sprintf(local, "tcp:%" PRIu16, local_port);
|
sprintf(local, "tcp:%" PRIu16, local_port);
|
||||||
const char *const adb_cmd[] = {"forward", "--remove", local};
|
const char *const adb_cmd[] = {"forward", "--remove", local};
|
||||||
|
|
||||||
sc_pid pid = adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd), flags);
|
sc_pid pid = sc_adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd), flags);
|
||||||
return process_check_success_intr(intr, pid, "adb forward --remove", flags);
|
return process_check_success_intr(intr, pid, "adb forward --remove", flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
adb_reverse(struct sc_intr *intr, const char *serial,
|
sc_adb_reverse(struct sc_intr *intr, const char *serial,
|
||||||
const char *device_socket_name, uint16_t local_port,
|
const char *device_socket_name, uint16_t local_port,
|
||||||
unsigned flags) {
|
unsigned flags) {
|
||||||
char local[4 + 5 + 1]; // tcp:PORT
|
char local[4 + 5 + 1]; // tcp:PORT
|
||||||
char remote[108 + 14 + 1]; // localabstract:NAME
|
char remote[108 + 14 + 1]; // localabstract:NAME
|
||||||
sprintf(local, "tcp:%" PRIu16, local_port);
|
sprintf(local, "tcp:%" PRIu16, local_port);
|
||||||
snprintf(remote, sizeof(remote), "localabstract:%s", device_socket_name);
|
snprintf(remote, sizeof(remote), "localabstract:%s", device_socket_name);
|
||||||
const char *const adb_cmd[] = {"reverse", remote, local};
|
const char *const adb_cmd[] = {"reverse", remote, local};
|
||||||
|
|
||||||
sc_pid pid = adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd), flags);
|
sc_pid pid = sc_adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd), flags);
|
||||||
return process_check_success_intr(intr, pid, "adb reverse", flags);
|
return process_check_success_intr(intr, pid, "adb reverse", flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
adb_reverse_remove(struct sc_intr *intr, const char *serial,
|
sc_adb_reverse_remove(struct sc_intr *intr, const char *serial,
|
||||||
const char *device_socket_name, unsigned flags) {
|
const char *device_socket_name, unsigned flags) {
|
||||||
char remote[108 + 14 + 1]; // localabstract:NAME
|
char remote[108 + 14 + 1]; // localabstract:NAME
|
||||||
snprintf(remote, sizeof(remote), "localabstract:%s", device_socket_name);
|
snprintf(remote, sizeof(remote), "localabstract:%s", device_socket_name);
|
||||||
const char *const adb_cmd[] = {"reverse", "--remove", remote};
|
const char *const adb_cmd[] = {"reverse", "--remove", remote};
|
||||||
|
|
||||||
sc_pid pid = adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd), flags);
|
sc_pid pid = sc_adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd), flags);
|
||||||
return process_check_success_intr(intr, pid, "adb reverse --remove", flags);
|
return process_check_success_intr(intr, pid, "adb reverse --remove", flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
adb_push(struct sc_intr *intr, const char *serial, const char *local,
|
sc_adb_push(struct sc_intr *intr, const char *serial, const char *local,
|
||||||
const char *remote, unsigned flags) {
|
const char *remote, unsigned flags) {
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
// Windows will parse the string, so the paths must be quoted
|
// Windows will parse the string, so the paths must be quoted
|
||||||
// (see sys/win/command.c)
|
// (see sys/win/command.c)
|
||||||
|
@ -283,7 +284,7 @@ adb_push(struct sc_intr *intr, const char *serial, const char *local,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *const adb_cmd[] = {"push", local, remote};
|
const char *const adb_cmd[] = {"push", local, remote};
|
||||||
sc_pid pid = adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd), flags);
|
sc_pid pid = sc_adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd), flags);
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
free((void *) remote);
|
free((void *) remote);
|
||||||
|
@ -294,8 +295,8 @@ adb_push(struct sc_intr *intr, const char *serial, const char *local,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
adb_install(struct sc_intr *intr, const char *serial, const char *local,
|
sc_adb_install(struct sc_intr *intr, const char *serial, const char *local,
|
||||||
unsigned flags) {
|
unsigned flags) {
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
// Windows will parse the string, so the local name must be quoted
|
// Windows will parse the string, so the local name must be quoted
|
||||||
// (see sys/win/command.c)
|
// (see sys/win/command.c)
|
||||||
|
@ -306,7 +307,7 @@ adb_install(struct sc_intr *intr, const char *serial, const char *local,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *const adb_cmd[] = {"install", "-r", local};
|
const char *const adb_cmd[] = {"install", "-r", local};
|
||||||
sc_pid pid = adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd), flags);
|
sc_pid pid = sc_adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd), flags);
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
free((void *) local);
|
free((void *) local);
|
||||||
|
@ -316,22 +317,23 @@ adb_install(struct sc_intr *intr, const char *serial, const char *local,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
adb_tcpip(struct sc_intr *intr, const char *serial, uint16_t port,
|
sc_adb_tcpip(struct sc_intr *intr, const char *serial, uint16_t port,
|
||||||
unsigned flags) {
|
unsigned flags) {
|
||||||
char port_string[5 + 1];
|
char port_string[5 + 1];
|
||||||
sprintf(port_string, "%" PRIu16, port);
|
sprintf(port_string, "%" PRIu16, port);
|
||||||
const char *const adb_cmd[] = {"tcpip", port_string};
|
const char *const adb_cmd[] = {"tcpip", port_string};
|
||||||
|
|
||||||
sc_pid pid = adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd), flags);
|
sc_pid pid = sc_adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd), flags);
|
||||||
return process_check_success_intr(intr, pid, "adb tcpip", flags);
|
return process_check_success_intr(intr, pid, "adb tcpip", flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
adb_connect(struct sc_intr *intr, const char *ip_port, unsigned flags) {
|
sc_adb_connect(struct sc_intr *intr, const char *ip_port, unsigned flags) {
|
||||||
const char *const adb_cmd[] = {"connect", ip_port};
|
const char *const adb_cmd[] = {"connect", ip_port};
|
||||||
|
|
||||||
sc_pipe pout;
|
sc_pipe pout;
|
||||||
sc_pid pid = adb_execute_p(NULL, adb_cmd, ARRAY_LEN(adb_cmd), flags, &pout);
|
sc_pid pid =
|
||||||
|
sc_adb_execute_p(NULL, adb_cmd, ARRAY_LEN(adb_cmd), flags, &pout);
|
||||||
if (pid == SC_PROCESS_NONE) {
|
if (pid == SC_PROCESS_NONE) {
|
||||||
LOGE("Could not execute \"adb connect\"");
|
LOGE("Could not execute \"adb connect\"");
|
||||||
return false;
|
return false;
|
||||||
|
@ -364,23 +366,23 @@ adb_connect(struct sc_intr *intr, const char *ip_port, unsigned flags) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
adb_disconnect(struct sc_intr *intr, const char *ip_port, unsigned flags) {
|
sc_adb_disconnect(struct sc_intr *intr, const char *ip_port, unsigned flags) {
|
||||||
const char *const adb_cmd[] = {"disconnect", ip_port};
|
const char *const adb_cmd[] = {"disconnect", ip_port};
|
||||||
size_t len = ip_port ? ARRAY_LEN(adb_cmd)
|
size_t len = ip_port ? ARRAY_LEN(adb_cmd)
|
||||||
: ARRAY_LEN(adb_cmd) - 1;
|
: ARRAY_LEN(adb_cmd) - 1;
|
||||||
|
|
||||||
sc_pid pid = adb_execute(NULL, adb_cmd, len, flags);
|
sc_pid pid = sc_adb_execute(NULL, adb_cmd, len, flags);
|
||||||
return process_check_success_intr(intr, pid, "adb disconnect", flags);
|
return process_check_success_intr(intr, pid, "adb disconnect", flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
adb_getprop(struct sc_intr *intr, const char *serial, const char *prop,
|
sc_adb_getprop(struct sc_intr *intr, const char *serial, const char *prop,
|
||||||
unsigned flags) {
|
unsigned flags) {
|
||||||
const char *const adb_cmd[] = {"shell", "getprop", prop};
|
const char *const adb_cmd[] = {"shell", "getprop", prop};
|
||||||
|
|
||||||
sc_pipe pout;
|
sc_pipe pout;
|
||||||
sc_pid pid =
|
sc_pid pid =
|
||||||
adb_execute_p(serial, adb_cmd, ARRAY_LEN(adb_cmd), flags, &pout);
|
sc_adb_execute_p(serial, adb_cmd, ARRAY_LEN(adb_cmd), flags, &pout);
|
||||||
if (pid == SC_PROCESS_NONE) {
|
if (pid == SC_PROCESS_NONE) {
|
||||||
LOGE("Could not execute \"adb getprop\"");
|
LOGE("Could not execute \"adb getprop\"");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -405,11 +407,12 @@ adb_getprop(struct sc_intr *intr, const char *serial, const char *prop,
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
adb_get_serialno(struct sc_intr *intr, unsigned flags) {
|
sc_adb_get_serialno(struct sc_intr *intr, unsigned flags) {
|
||||||
const char *const adb_cmd[] = {"get-serialno"};
|
const char *const adb_cmd[] = {"get-serialno"};
|
||||||
|
|
||||||
sc_pipe pout;
|
sc_pipe pout;
|
||||||
sc_pid pid = adb_execute_p(NULL, adb_cmd, ARRAY_LEN(adb_cmd), flags, &pout);
|
sc_pid pid =
|
||||||
|
sc_adb_execute_p(NULL, adb_cmd, ARRAY_LEN(adb_cmd), flags, &pout);
|
||||||
if (pid == SC_PROCESS_NONE) {
|
if (pid == SC_PROCESS_NONE) {
|
||||||
LOGE("Could not execute \"adb get-serialno\"");
|
LOGE("Could not execute \"adb get-serialno\"");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -434,11 +437,11 @@ adb_get_serialno(struct sc_intr *intr, unsigned flags) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
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) {
|
||||||
const char *const cmd[] = {"shell", "ip", "route"};
|
const char *const cmd[] = {"shell", "ip", "route"};
|
||||||
|
|
||||||
sc_pipe pout;
|
sc_pipe pout;
|
||||||
sc_pid pid = adb_execute_p(serial, cmd, ARRAY_LEN(cmd), flags, &pout);
|
sc_pid pid = sc_adb_execute_p(serial, cmd, ARRAY_LEN(cmd), flags, &pout);
|
||||||
if (pid == SC_PROCESS_NONE) {
|
if (pid == SC_PROCESS_NONE) {
|
||||||
LOGD("Could not execute \"ip route\"");
|
LOGD("Could not execute \"ip route\"");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -15,40 +15,40 @@
|
||||||
#define SC_ADB_SILENT (SC_ADB_NO_STDOUT | SC_ADB_NO_STDERR | SC_ADB_NO_LOGERR)
|
#define SC_ADB_SILENT (SC_ADB_NO_STDOUT | SC_ADB_NO_STDERR | SC_ADB_NO_LOGERR)
|
||||||
|
|
||||||
sc_pid
|
sc_pid
|
||||||
adb_execute(const char *serial, const char *const adb_cmd[], size_t len,
|
sc_adb_execute(const char *serial, const char *const adb_cmd[], size_t len,
|
||||||
unsigned flags);
|
unsigned flags);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
adb_forward(struct sc_intr *intr, const char *serial, uint16_t local_port,
|
sc_adb_forward(struct sc_intr *intr, const char *serial, uint16_t local_port,
|
||||||
const char *device_socket_name, unsigned flags);
|
const char *device_socket_name, unsigned flags);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
adb_forward_remove(struct sc_intr *intr, const char *serial,
|
sc_adb_forward_remove(struct sc_intr *intr, const char *serial,
|
||||||
uint16_t local_port, unsigned flags);
|
uint16_t local_port, unsigned flags);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
adb_reverse(struct sc_intr *intr, const char *serial,
|
sc_adb_reverse(struct sc_intr *intr, const char *serial,
|
||||||
const char *device_socket_name, uint16_t local_port,
|
const char *device_socket_name, uint16_t local_port,
|
||||||
unsigned flags);
|
unsigned flags);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
adb_reverse_remove(struct sc_intr *intr, const char *serial,
|
sc_adb_reverse_remove(struct sc_intr *intr, const char *serial,
|
||||||
const char *device_socket_name, unsigned flags);
|
const char *device_socket_name, unsigned flags);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
adb_push(struct sc_intr *intr, const char *serial, const char *local,
|
sc_adb_push(struct sc_intr *intr, const char *serial, const char *local,
|
||||||
const char *remote, unsigned flags);
|
const char *remote, unsigned flags);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
adb_install(struct sc_intr *intr, const char *serial, const char *local,
|
sc_adb_install(struct sc_intr *intr, const char *serial, const char *local,
|
||||||
unsigned flags);
|
unsigned flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute `adb tcpip <port>`
|
* Execute `adb tcpip <port>`
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
adb_tcpip(struct sc_intr *intr, const char *serial, uint16_t port,
|
sc_adb_tcpip(struct sc_intr *intr, const char *serial, uint16_t port,
|
||||||
unsigned flags);
|
unsigned flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute `adb connect <ip_port>`
|
* Execute `adb connect <ip_port>`
|
||||||
|
@ -56,7 +56,7 @@ adb_tcpip(struct sc_intr *intr, const char *serial, uint16_t port,
|
||||||
* `ip_port` may not be NULL.
|
* `ip_port` may not be NULL.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
adb_connect(struct sc_intr *intr, const char *ip_port, unsigned flags);
|
sc_adb_connect(struct sc_intr *intr, const char *ip_port, unsigned flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute `adb disconnect [<ip_port>]`
|
* Execute `adb disconnect [<ip_port>]`
|
||||||
|
@ -65,14 +65,14 @@ adb_connect(struct sc_intr *intr, const char *ip_port, unsigned flags);
|
||||||
* Otherwise, execute `adb disconnect <ip_port>`.
|
* Otherwise, execute `adb disconnect <ip_port>`.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
adb_disconnect(struct sc_intr *intr, const char *ip_port, unsigned flags);
|
sc_adb_disconnect(struct sc_intr *intr, const char *ip_port, unsigned flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute `adb getprop <prop>`
|
* Execute `adb getprop <prop>`
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
adb_getprop(struct sc_intr *intr, const char *serial, const char *prop,
|
sc_adb_getprop(struct sc_intr *intr, const char *serial, const char *prop,
|
||||||
unsigned flags);
|
unsigned flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute `adb get-serialno`
|
* Execute `adb get-serialno`
|
||||||
|
@ -80,7 +80,7 @@ adb_getprop(struct sc_intr *intr, const char *serial, const char *prop,
|
||||||
* Return the result, to be freed by the caller, or NULL on error.
|
* Return the result, to be freed by the caller, or NULL on error.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
adb_get_serialno(struct sc_intr *intr, unsigned flags);
|
sc_adb_get_serialno(struct sc_intr *intr, unsigned flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to retrieve the device IP
|
* Attempt to retrieve the device IP
|
||||||
|
@ -89,6 +89,6 @@ adb_get_serialno(struct sc_intr *intr, unsigned flags);
|
||||||
* caller, or NULL on error.
|
* caller, or NULL on error.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
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);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,8 +20,8 @@ enable_tunnel_reverse_any_port(struct sc_adb_tunnel *tunnel,
|
||||||
struct sc_port_range port_range) {
|
struct sc_port_range port_range) {
|
||||||
uint16_t port = port_range.first;
|
uint16_t port = port_range.first;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (!adb_reverse(intr, serial, SC_SOCKET_NAME, port,
|
if (!sc_adb_reverse(intr, serial, SC_SOCKET_NAME, port,
|
||||||
SC_ADB_NO_STDOUT)) {
|
SC_ADB_NO_STDOUT)) {
|
||||||
// the command itself failed, it will fail on any port
|
// the command itself failed, it will fail on any port
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ enable_tunnel_reverse_any_port(struct sc_adb_tunnel *tunnel,
|
||||||
}
|
}
|
||||||
|
|
||||||
// failure, disable tunnel and try another port
|
// failure, disable tunnel and try another port
|
||||||
if (!adb_reverse_remove(intr, serial, SC_SOCKET_NAME,
|
if (!sc_adb_reverse_remove(intr, serial, SC_SOCKET_NAME,
|
||||||
SC_ADB_NO_STDOUT)) {
|
SC_ADB_NO_STDOUT)) {
|
||||||
LOGW("Could not remove reverse tunnel on port %" PRIu16, port);
|
LOGW("Could not remove reverse tunnel on port %" PRIu16, port);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,8 @@ enable_tunnel_forward_any_port(struct sc_adb_tunnel *tunnel,
|
||||||
|
|
||||||
uint16_t port = port_range.first;
|
uint16_t port = port_range.first;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (adb_forward(intr, serial, port, SC_SOCKET_NAME, SC_ADB_NO_STDOUT)) {
|
if (sc_adb_forward(intr, serial, port, SC_SOCKET_NAME,
|
||||||
|
SC_ADB_NO_STDOUT)) {
|
||||||
// success
|
// success
|
||||||
tunnel->local_port = port;
|
tunnel->local_port = port;
|
||||||
tunnel->enabled = true;
|
tunnel->enabled = true;
|
||||||
|
@ -148,11 +149,11 @@ sc_adb_tunnel_close(struct sc_adb_tunnel *tunnel, struct sc_intr *intr,
|
||||||
|
|
||||||
bool ret;
|
bool ret;
|
||||||
if (tunnel->forward) {
|
if (tunnel->forward) {
|
||||||
ret = adb_forward_remove(intr, serial, tunnel->local_port,
|
ret = sc_adb_forward_remove(intr, serial, tunnel->local_port,
|
||||||
SC_ADB_NO_STDOUT);
|
SC_ADB_NO_STDOUT);
|
||||||
} else {
|
} else {
|
||||||
ret = adb_reverse_remove(intr, serial, SC_SOCKET_NAME,
|
ret = sc_adb_reverse_remove(intr, serial, SC_SOCKET_NAME,
|
||||||
SC_ADB_NO_STDOUT);
|
SC_ADB_NO_STDOUT);
|
||||||
|
|
||||||
assert(tunnel->server_socket != SC_SOCKET_NONE);
|
assert(tunnel->server_socket != SC_SOCKET_NONE);
|
||||||
if (!net_close(tunnel->server_socket)) {
|
if (!net_close(tunnel->server_socket)) {
|
||||||
|
|
|
@ -129,7 +129,7 @@ run_file_pusher(void *data) {
|
||||||
|
|
||||||
if (req.action == SC_FILE_PUSHER_ACTION_INSTALL_APK) {
|
if (req.action == SC_FILE_PUSHER_ACTION_INSTALL_APK) {
|
||||||
LOGI("Installing %s...", req.file);
|
LOGI("Installing %s...", req.file);
|
||||||
bool ok = adb_install(intr, serial, req.file, 0);
|
bool ok = sc_adb_install(intr, serial, req.file, 0);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
LOGI("%s successfully installed", req.file);
|
LOGI("%s successfully installed", req.file);
|
||||||
} else {
|
} else {
|
||||||
|
@ -137,7 +137,7 @@ run_file_pusher(void *data) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOGI("Pushing %s...", req.file);
|
LOGI("Pushing %s...", req.file);
|
||||||
bool ok = adb_push(intr, serial, req.file, push_target, 0);
|
bool ok = sc_adb_push(intr, serial, req.file, push_target, 0);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
LOGI("%s successfully pushed to %s", req.file, push_target);
|
LOGI("%s successfully pushed to %s", req.file, push_target);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -114,7 +114,7 @@ push_server(struct sc_intr *intr, const char *serial) {
|
||||||
free(server_path);
|
free(server_path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool ok = adb_push(intr, serial, server_path, SC_DEVICE_SERVER_PATH, 0);
|
bool ok = sc_adb_push(intr, serial, server_path, SC_DEVICE_SERVER_PATH, 0);
|
||||||
free(server_path);
|
free(server_path);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ execute_server(struct sc_server *server,
|
||||||
// Then click on "Debug"
|
// Then click on "Debug"
|
||||||
#endif
|
#endif
|
||||||
// Inherit both stdout and stderr (all server logs are printed to stdout)
|
// Inherit both stdout and stderr (all server logs are printed to stdout)
|
||||||
pid = adb_execute(params->serial, cmd, count, 0);
|
pid = sc_adb_execute(params->serial, cmd, count, 0);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
for (unsigned i = dyn_idx; i < count; ++i) {
|
for (unsigned i = dyn_idx; i < count; ++i) {
|
||||||
|
@ -501,7 +501,7 @@ sc_server_fill_serial(struct sc_server *server) {
|
||||||
// device/emulator" error)
|
// device/emulator" error)
|
||||||
if (!server->params.serial) {
|
if (!server->params.serial) {
|
||||||
// The serial is owned by sc_server_params, and will be freed on destroy
|
// The serial is owned by sc_server_params, and will be freed on destroy
|
||||||
server->params.serial = adb_get_serialno(&server->intr, 0);
|
server->params.serial = sc_adb_get_serialno(&server->intr, 0);
|
||||||
if (!server->params.serial) {
|
if (!server->params.serial) {
|
||||||
LOGE("Could not get device serial");
|
LOGE("Could not get device serial");
|
||||||
return false;
|
return false;
|
||||||
|
@ -519,7 +519,7 @@ is_tcpip_mode_enabled(struct sc_server *server) {
|
||||||
const char *serial = server->params.serial;
|
const char *serial = server->params.serial;
|
||||||
|
|
||||||
char *current_port =
|
char *current_port =
|
||||||
adb_getprop(intr, serial, "service.adb.tcp.port", SC_ADB_SILENT);
|
sc_adb_getprop(intr, serial, "service.adb.tcp.port", SC_ADB_SILENT);
|
||||||
if (!current_port) {
|
if (!current_port) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -580,7 +580,7 @@ sc_server_switch_to_tcpip(struct sc_server *server, char **out_ip_port) {
|
||||||
|
|
||||||
struct sc_intr *intr = &server->intr;
|
struct sc_intr *intr = &server->intr;
|
||||||
|
|
||||||
char *ip = adb_get_device_ip(intr, serial, 0);
|
char *ip = sc_adb_get_device_ip(intr, serial, 0);
|
||||||
if (!ip) {
|
if (!ip) {
|
||||||
LOGE("Device IP not found");
|
LOGE("Device IP not found");
|
||||||
return false;
|
return false;
|
||||||
|
@ -595,7 +595,7 @@ sc_server_switch_to_tcpip(struct sc_server *server, char **out_ip_port) {
|
||||||
bool tcp_mode = is_tcpip_mode_enabled(server);
|
bool tcp_mode = is_tcpip_mode_enabled(server);
|
||||||
|
|
||||||
if (!tcp_mode) {
|
if (!tcp_mode) {
|
||||||
bool ok = adb_tcpip(intr, serial, 5555, SC_ADB_NO_STDOUT);
|
bool ok = sc_adb_tcpip(intr, serial, 5555, SC_ADB_NO_STDOUT);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
LOGE("Could not restart adbd in TCP/IP mode");
|
LOGE("Could not restart adbd in TCP/IP mode");
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -623,9 +623,9 @@ sc_server_connect_to_tcpip(struct sc_server *server, const char *ip_port) {
|
||||||
struct sc_intr *intr = &server->intr;
|
struct sc_intr *intr = &server->intr;
|
||||||
|
|
||||||
// Error expected if not connected, do not report any error
|
// Error expected if not connected, do not report any error
|
||||||
adb_disconnect(intr, ip_port, SC_ADB_SILENT);
|
sc_adb_disconnect(intr, ip_port, SC_ADB_SILENT);
|
||||||
|
|
||||||
bool ok = adb_connect(intr, ip_port, 0);
|
bool ok = sc_adb_connect(intr, ip_port, 0);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
LOGE("Could not connect to %s", ip_port);
|
LOGE("Could not connect to %s", ip_port);
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue