From bfce22414fd3173b9671140d77d2e8a927d5ff94 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 24 Nov 2021 22:39:46 +0100 Subject: [PATCH] Add adb connect and disconnect PR #2827 --- app/src/adb.c | 18 ++++++++++++++++++ app/src/adb.h | 17 +++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/app/src/adb.c b/app/src/adb.c index ce6aedbf..cb4f14da 100644 --- a/app/src/adb.c +++ b/app/src/adb.c @@ -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); } +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 * adb_get_serialno(struct sc_intr *intr, unsigned flags) { const char *const adb_cmd[] = {"get-serialno"}; diff --git a/app/src/adb.h b/app/src/adb.h index 7391500d..d5d9bb37 100644 --- a/app/src/adb.h +++ b/app/src/adb.h @@ -41,6 +41,23 @@ bool adb_install(struct sc_intr *intr, const char *serial, const char *local, unsigned flags); +/** + * Execute `adb connect ` + * + * `ip_port` may not be NULL. + */ +bool +adb_connect(struct sc_intr *intr, const char *ip_port, unsigned flags); + +/** + * Execute `adb disconnect []` + * + * If `ip_port` is NULL, execute `adb disconnect`. + * Otherwise, execute `adb disconnect `. + */ +bool +adb_disconnect(struct sc_intr *intr, const char *ip_port, unsigned flags); + /** * Execute `adb get-serialno` *