Privatize low-level adb functions
Only expose the interruptible user-friendly API.
This commit is contained in:
parent
ce225f019a
commit
3fdbd994e0
2 changed files with 8 additions and 41 deletions
|
@ -110,7 +110,7 @@ show_adb_err_msg(enum sc_process_result err, const char *const argv[]) {
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_pid
|
static sc_pid
|
||||||
adb_execute_p(const char *serial, const char *const adb_cmd[],
|
adb_execute_p(const char *serial, const char *const adb_cmd[],
|
||||||
size_t len, sc_pipe *pout) {
|
size_t len, sc_pipe *pout) {
|
||||||
int i;
|
int i;
|
||||||
|
@ -148,7 +148,7 @@ adb_execute(const char *serial, const char *const adb_cmd[], size_t len) {
|
||||||
return adb_execute_p(serial, adb_cmd, len, NULL);
|
return adb_execute_p(serial, adb_cmd, len, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_pid
|
static sc_pid
|
||||||
adb_exec_forward(const char *serial, uint16_t local_port,
|
adb_exec_forward(const char *serial, uint16_t local_port,
|
||||||
const char *device_socket_name) {
|
const char *device_socket_name) {
|
||||||
char local[4 + 5 + 1]; // tcp:PORT
|
char local[4 + 5 + 1]; // tcp:PORT
|
||||||
|
@ -159,7 +159,7 @@ adb_exec_forward(const char *serial, uint16_t local_port,
|
||||||
return adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd));
|
return adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_pid
|
static sc_pid
|
||||||
adb_exec_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
|
char local[4 + 5 + 1]; // tcp:PORT
|
||||||
sprintf(local, "tcp:%" PRIu16, local_port);
|
sprintf(local, "tcp:%" PRIu16, local_port);
|
||||||
|
@ -167,7 +167,7 @@ adb_exec_forward_remove(const char *serial, uint16_t local_port) {
|
||||||
return adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd));
|
return adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_pid
|
static sc_pid
|
||||||
adb_exec_reverse(const char *serial, const char *device_socket_name,
|
adb_exec_reverse(const char *serial, const char *device_socket_name,
|
||||||
uint16_t local_port) {
|
uint16_t local_port) {
|
||||||
char local[4 + 5 + 1]; // tcp:PORT
|
char local[4 + 5 + 1]; // tcp:PORT
|
||||||
|
@ -178,7 +178,7 @@ adb_exec_reverse(const char *serial, const char *device_socket_name,
|
||||||
return adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd));
|
return adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_pid
|
static sc_pid
|
||||||
adb_exec_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
|
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);
|
||||||
|
@ -186,7 +186,7 @@ adb_exec_reverse_remove(const char *serial, const char *device_socket_name) {
|
||||||
return adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd));
|
return adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_pid
|
static sc_pid
|
||||||
adb_exec_push(const char *serial, const char *local, const char *remote) {
|
adb_exec_push(const char *serial, const char *local, const char *remote) {
|
||||||
#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
|
||||||
|
@ -213,7 +213,7 @@ adb_exec_push(const char *serial, const char *local, const char *remote) {
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_pid
|
static sc_pid
|
||||||
adb_exec_install(const char *serial, const char *local) {
|
adb_exec_install(const char *serial, const char *local) {
|
||||||
#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
|
||||||
|
@ -234,7 +234,7 @@ adb_exec_install(const char *serial, const char *local) {
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_pid
|
static sc_pid
|
||||||
adb_exec_get_serialno(sc_pipe *pout) {
|
adb_exec_get_serialno(sc_pipe *pout) {
|
||||||
const char *const adb_cmd[] = {"get-serialno"};
|
const char *const adb_cmd[] = {"get-serialno"};
|
||||||
return adb_execute_p(NULL, adb_cmd, ARRAY_LEN(adb_cmd), pout);
|
return adb_execute_p(NULL, adb_cmd, ARRAY_LEN(adb_cmd), pout);
|
||||||
|
|
|
@ -6,44 +6,11 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "util/process.h"
|
|
||||||
#include "util/intr.h"
|
#include "util/intr.h"
|
||||||
|
|
||||||
sc_pid
|
sc_pid
|
||||||
adb_execute(const char *serial, const char *const adb_cmd[], size_t len);
|
adb_execute(const char *serial, const char *const adb_cmd[], size_t len);
|
||||||
|
|
||||||
sc_pid
|
|
||||||
adb_execute_p(const char *serial, const char *const adb_cmd[], size_t len,
|
|
||||||
sc_pipe *pout);
|
|
||||||
|
|
||||||
sc_pid
|
|
||||||
adb_exec_forward(const char *serial, uint16_t local_port,
|
|
||||||
const char *device_socket_name);
|
|
||||||
|
|
||||||
sc_pid
|
|
||||||
adb_exec_forward_remove(const char *serial, uint16_t local_port);
|
|
||||||
|
|
||||||
sc_pid
|
|
||||||
adb_exec_reverse(const char *serial, const char *device_socket_name,
|
|
||||||
uint16_t local_port);
|
|
||||||
|
|
||||||
sc_pid
|
|
||||||
adb_exec_reverse_remove(const char *serial, const char *device_socket_name);
|
|
||||||
|
|
||||||
sc_pid
|
|
||||||
adb_exec_push(const char *serial, const char *local, const char *remote);
|
|
||||||
|
|
||||||
sc_pid
|
|
||||||
adb_exec_install(const char *serial, const char *local);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute `adb get-serialno`
|
|
||||||
*
|
|
||||||
* The result can be read from the output parameter `pout`.
|
|
||||||
*/
|
|
||||||
sc_pid
|
|
||||||
adb_exec_get_serialno(sc_pipe *pout);
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
adb_forward(struct sc_intr *intr, const char *serial, uint16_t local_port,
|
adb_forward(struct sc_intr *intr, const char *serial, uint16_t local_port,
|
||||||
const char *device_socket_name);
|
const char *device_socket_name);
|
||||||
|
|
Loading…
Reference in a new issue