Rename adb functions to adb_exec_*

This paves the way to replace them by more user-friendly functions that
will call them internally.
This commit is contained in:
Romain Vimont 2021-11-18 21:47:17 +01:00
parent 84334cf7db
commit afb5a5e80f
5 changed files with 26 additions and 26 deletions

View file

@ -148,8 +148,8 @@ adb_execute(const char *serial, const char *const adb_cmd[], size_t len) {
}
sc_pid
adb_forward(const char *serial, uint16_t local_port,
const char *device_socket_name) {
adb_exec_forward(const char *serial, uint16_t local_port,
const char *device_socket_name) {
char local[4 + 5 + 1]; // tcp:PORT
char remote[108 + 14 + 1]; // localabstract:NAME
sprintf(local, "tcp:%" PRIu16, local_port);
@ -159,7 +159,7 @@ adb_forward(const char *serial, uint16_t local_port,
}
sc_pid
adb_forward_remove(const char *serial, uint16_t local_port) {
adb_exec_forward_remove(const char *serial, uint16_t local_port) {
char local[4 + 5 + 1]; // tcp:PORT
sprintf(local, "tcp:%" PRIu16, local_port);
const char *const adb_cmd[] = {"forward", "--remove", local};
@ -167,8 +167,8 @@ adb_forward_remove(const char *serial, uint16_t local_port) {
}
sc_pid
adb_reverse(const char *serial, const char *device_socket_name,
uint16_t local_port) {
adb_exec_reverse(const char *serial, const char *device_socket_name,
uint16_t local_port) {
char local[4 + 5 + 1]; // tcp:PORT
char remote[108 + 14 + 1]; // localabstract:NAME
sprintf(local, "tcp:%" PRIu16, local_port);
@ -178,7 +178,7 @@ adb_reverse(const char *serial, const char *device_socket_name,
}
sc_pid
adb_reverse_remove(const char *serial, const char *device_socket_name) {
adb_exec_reverse_remove(const char *serial, const char *device_socket_name) {
char remote[108 + 14 + 1]; // localabstract:NAME
snprintf(remote, sizeof(remote), "localabstract:%s", device_socket_name);
const char *const adb_cmd[] = {"reverse", "--remove", remote};
@ -186,7 +186,7 @@ adb_reverse_remove(const char *serial, const char *device_socket_name) {
}
sc_pid
adb_push(const char *serial, const char *local, const char *remote) {
adb_exec_push(const char *serial, const char *local, const char *remote) {
#ifdef __WINDOWS__
// Windows will parse the string, so the paths must be quoted
// (see sys/win/command.c)
@ -213,7 +213,7 @@ adb_push(const char *serial, const char *local, const char *remote) {
}
sc_pid
adb_install(const char *serial, const char *local) {
adb_exec_install(const char *serial, const char *local) {
#ifdef __WINDOWS__
// Windows will parse the string, so the local name must be quoted
// (see sys/win/command.c)
@ -234,7 +234,7 @@ adb_install(const char *serial, const char *local) {
}
sc_pid
adb_get_serialno(sc_pipe *pout) {
adb_exec_get_serialno(sc_pipe *pout) {
const char *const adb_cmd[] = {"get-serialno"};
return adb_execute_p(NULL, adb_cmd, ARRAY_LEN(adb_cmd), pout);
}

View file

@ -16,24 +16,24 @@ adb_execute_p(const char *serial, const char *const adb_cmd[], size_t len,
sc_pipe *pout);
sc_pid
adb_forward(const char *serial, uint16_t local_port,
const char *device_socket_name);
adb_exec_forward(const char *serial, uint16_t local_port,
const char *device_socket_name);
sc_pid
adb_forward_remove(const char *serial, uint16_t local_port);
adb_exec_forward_remove(const char *serial, uint16_t local_port);
sc_pid
adb_reverse(const char *serial, const char *device_socket_name,
uint16_t local_port);
adb_exec_reverse(const char *serial, const char *device_socket_name,
uint16_t local_port);
sc_pid
adb_reverse_remove(const char *serial, const char *device_socket_name);
adb_exec_reverse_remove(const char *serial, const char *device_socket_name);
sc_pid
adb_push(const char *serial, const char *local, const char *remote);
adb_exec_push(const char *serial, const char *local, const char *remote);
sc_pid
adb_install(const char *serial, const char *local);
adb_exec_install(const char *serial, const char *local);
/**
* Execute `adb get-serialno`
@ -41,6 +41,6 @@ adb_install(const char *serial, const char *local);
* The result can be read from the output parameter `pout`.
*/
sc_pid
adb_get_serialno(sc_pipe *pout);
adb_exec_get_serialno(sc_pipe *pout);
#endif

View file

@ -12,13 +12,13 @@
static bool
enable_tunnel_reverse(struct sc_intr *intr, const char *serial,
uint16_t local_port) {
sc_pid pid = adb_reverse(serial, SC_SOCKET_NAME, local_port);
sc_pid pid = adb_exec_reverse(serial, SC_SOCKET_NAME, local_port);
return sc_process_check_success_intr(intr, pid, "adb reverse", true);
}
static bool
disable_tunnel_reverse(struct sc_intr *intr, const char *serial) {
sc_pid pid = adb_reverse_remove(serial, SC_SOCKET_NAME);
sc_pid pid = adb_exec_reverse_remove(serial, SC_SOCKET_NAME);
return sc_process_check_success_intr(intr, pid, "adb reverse --remove",
true);
}
@ -26,14 +26,14 @@ disable_tunnel_reverse(struct sc_intr *intr, const char *serial) {
static bool
enable_tunnel_forward(struct sc_intr *intr, const char *serial,
uint16_t local_port) {
sc_pid pid = adb_forward(serial, local_port, SC_SOCKET_NAME);
sc_pid pid = adb_exec_forward(serial, local_port, SC_SOCKET_NAME);
return sc_process_check_success_intr(intr, pid, "adb forward", true);
}
static bool
disable_tunnel_forward(struct sc_intr *intr, const char *serial,
uint16_t local_port) {
sc_pid pid = adb_forward_remove(serial, local_port);
sc_pid pid = adb_exec_forward_remove(serial, local_port);
return sc_process_check_success_intr(intr, pid, "adb forward --remove",
true);
}

View file

@ -129,10 +129,10 @@ run_file_handler(void *data) {
sc_pid pid;
if (req.action == ACTION_INSTALL_APK) {
LOGI("Installing %s...", req.file);
pid = adb_install(serial, req.file);
pid = adb_exec_install(serial, req.file);
} else {
LOGI("Pushing %s...", req.file);
pid = adb_push(serial, req.file, push_target);
pid = adb_exec_push(serial, req.file, push_target);
}
if (req.action == ACTION_INSTALL_APK) {

View file

@ -112,7 +112,7 @@ push_server(struct sc_intr *intr, const char *serial) {
free(server_path);
return false;
}
sc_pid pid = adb_push(serial, server_path, SC_DEVICE_SERVER_PATH);
sc_pid pid = adb_exec_push(serial, server_path, SC_DEVICE_SERVER_PATH);
free(server_path);
return sc_process_check_success_intr(intr, pid, "adb push", true);
}
@ -425,7 +425,7 @@ sc_server_on_terminated(void *userdata) {
static char *
sc_server_get_serialno(struct sc_intr *intr) {
sc_pipe pout;
sc_pid pid = adb_get_serialno(&pout);
sc_pid pid = adb_exec_get_serialno(&pout);
if (pid == SC_PROCESS_NONE) {
return false;
}