diff options
author | Ethan Yonker <dees_troy@teamw.in> | 2017-10-01 05:22:13 +0200 |
---|---|---|
committer | Ethan Yonker <dees_troy@teamw.in> | 2017-11-28 23:03:41 +0100 |
commit | fefe5915b06a1121d885fba3680dd1b90027fd5d (patch) | |
tree | 2370923b618bdbe2592873cd311944628a1d0a62 /minadbd | |
parent | Merge "Support v2 fstab format" into android-8.0 (diff) | |
download | android_bootable_recovery-fefe5915b06a1121d885fba3680dd1b90027fd5d.tar android_bootable_recovery-fefe5915b06a1121d885fba3680dd1b90027fd5d.tar.gz android_bootable_recovery-fefe5915b06a1121d885fba3680dd1b90027fd5d.tar.bz2 android_bootable_recovery-fefe5915b06a1121d885fba3680dd1b90027fd5d.tar.lz android_bootable_recovery-fefe5915b06a1121d885fba3680dd1b90027fd5d.tar.xz android_bootable_recovery-fefe5915b06a1121d885fba3680dd1b90027fd5d.tar.zst android_bootable_recovery-fefe5915b06a1121d885fba3680dd1b90027fd5d.zip |
Diffstat (limited to 'minadbd')
-rw-r--r-- | minadbd/minadbd_services.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp index e558f9702..40f2cea7b 100644 --- a/minadbd/minadbd_services.cpp +++ b/minadbd/minadbd_services.cpp @@ -21,6 +21,9 @@ #include <string.h> #include <unistd.h> +#include <string> +#include <thread> + #include "adb.h" #include "fdevent.h" #include "fuse_adb_provider.h" @@ -40,15 +43,26 @@ void service_bootstrap_func(void* x) { free(sti); } +#if PLATFORM_SDK_VERSION < 26 static void sideload_host_service(int sfd, void* data) { char* args = reinterpret_cast<char*>(data); +#else +static void sideload_host_service(int sfd, const std::string& args) { +#endif int file_size; int block_size; +#if PLATFORM_SDK_VERSION < 26 if (sscanf(args, "%d:%d", &file_size, &block_size) != 2) { printf("bad sideload-host arguments: %s\n", args); +#else + if (sscanf(args.c_str(), "%d:%d", &file_size, &block_size) != 2) { + printf("bad sideload-host arguments: %s\n", args.c_str()); +#endif exit(1); } +#if PLATFORM_SDK_VERSION < 26 free(args); +#endif printf("sideload-host file size %d block size %d\n", file_size, block_size); @@ -59,6 +73,7 @@ static void sideload_host_service(int sfd, void* data) { exit(result == 0 ? 0 : 1); } +#if PLATFORM_SDK_VERSION < 26 static int create_service_thread(void (*func)(int, void *), void *cookie) { int s[2]; if (adb_socketpair(s)) { @@ -88,6 +103,20 @@ static int create_service_thread(void (*func)(int, void *), void *cookie) { //VLOG(SERVICES) << "service thread started, " << s[0] << ":" << s[1]; return s[0]; } +#else +static int create_service_thread(void (*func)(int, const std::string&), const std::string& args) { + int s[2]; + if (adb_socketpair(s)) { + printf("cannot create service socket pair\n"); + return -1; + } + + std::thread([s, func, args]() { func(s[1], args); }).detach(); + + //VLOG(SERVICES) << "service thread started, " << s[0] << ":" << s[1]; + return s[0]; +} +#endif int service_to_fd(const char* name, const atransport* transport) { int ret = -1; @@ -98,7 +127,11 @@ int service_to_fd(const char* name, const atransport* transport) { // sideload-host). exit(3); } else if (!strncmp(name, "sideload-host:", 14)) { +#if PLATFORM_SDK_VERSION < 26 char* arg = strdup(name + 14); +#else + std::string arg(name + 14); +#endif ret = create_service_thread(sideload_host_service, arg); } if (ret >= 0) { |