summaryrefslogtreecommitdiffstats
path: root/minadbd
diff options
context:
space:
mode:
Diffstat (limited to 'minadbd')
-rw-r--r--minadbd/Android.mk3
-rw-r--r--minadbd/adb_main.cpp6
-rw-r--r--minadbd/fuse_adb_provider.cpp21
-rw-r--r--minadbd/services.cpp19
4 files changed, 25 insertions, 24 deletions
diff --git a/minadbd/Android.mk b/minadbd/Android.mk
index cbfd76e4e..a7a3e087d 100644
--- a/minadbd/Android.mk
+++ b/minadbd/Android.mk
@@ -20,6 +20,7 @@ LOCAL_CFLAGS := $(minadbd_cflags)
LOCAL_CONLY_FLAGS := -Wimplicit-function-declaration
LOCAL_C_INCLUDES := bootable/recovery system/core/adb
LOCAL_WHOLE_STATIC_LIBRARIES := libadbd
+LOCAL_STATIC_LIBRARIES := libbase
include $(BUILD_STATIC_LIBRARY)
@@ -31,6 +32,6 @@ LOCAL_SRC_FILES := fuse_adb_provider_test.cpp
LOCAL_CFLAGS := $(minadbd_cflags)
LOCAL_C_INCLUDES := $(LOCAL_PATH) system/core/adb
LOCAL_STATIC_LIBRARIES := libminadbd
-LOCAL_SHARED_LIBRARIES := liblog
+LOCAL_SHARED_LIBRARIES := liblog libbase libcutils
include $(BUILD_NATIVE_TEST)
diff --git a/minadbd/adb_main.cpp b/minadbd/adb_main.cpp
index f6e240108..7fae99a9a 100644
--- a/minadbd/adb_main.cpp
+++ b/minadbd/adb_main.cpp
@@ -19,11 +19,12 @@
#include <stdio.h>
#include <stdlib.h>
-#define TRACE_TAG TRACE_ADB
+#define TRACE_TAG TRACE_ADB
#include "sysdeps.h"
#include "adb.h"
+#include "adb_auth.h"
#include "transport.h"
int adb_main(int is_daemon, int server_port)
@@ -35,6 +36,9 @@ int adb_main(int is_daemon, int server_port)
// No SIGCHLD. Let the service subproc handle its children.
signal(SIGPIPE, SIG_IGN);
+ // We can't require authentication for sideloading. http://b/22025550.
+ auth_required = false;
+
init_transport_registration();
usb_init();
diff --git a/minadbd/fuse_adb_provider.cpp b/minadbd/fuse_adb_provider.cpp
index 5da7fd76c..d71807dfb 100644
--- a/minadbd/fuse_adb_provider.cpp
+++ b/minadbd/fuse_adb_provider.cpp
@@ -26,13 +26,10 @@
#include "fuse_adb_provider.h"
#include "fuse_sideload.h"
-int read_block_adb(void* cookie, uint32_t block, uint8_t* buffer,
- uint32_t fetch_size) {
- struct adb_data* ad = (struct adb_data*)cookie;
+int read_block_adb(void* data, uint32_t block, uint8_t* buffer, uint32_t fetch_size) {
+ adb_data* ad = reinterpret_cast<adb_data*>(data);
- char buf[10];
- snprintf(buf, sizeof(buf), "%08u", block);
- if (!WriteStringFully(ad->sfd, buf)) {
+ if (!WriteFdFmt(ad->sfd, "%08u", block)) {
fprintf(stderr, "failed to write to adb host: %s\n", strerror(errno));
return -EIO;
}
@@ -45,20 +42,18 @@ int read_block_adb(void* cookie, uint32_t block, uint8_t* buffer,
return 0;
}
-static void close_adb(void* cookie) {
- struct adb_data* ad = (struct adb_data*)cookie;
-
- WriteStringFully(ad->sfd, "DONEDONE");
+static void close_adb(void* data) {
+ adb_data* ad = reinterpret_cast<adb_data*>(data);
+ WriteFdExactly(ad->sfd, "DONEDONE");
}
int run_adb_fuse(int sfd, uint64_t file_size, uint32_t block_size) {
- struct adb_data ad;
- struct provider_vtab vtab;
-
+ adb_data ad;
ad.sfd = sfd;
ad.file_size = file_size;
ad.block_size = block_size;
+ provider_vtab vtab;
vtab.read_block = read_block_adb;
vtab.close = close_adb;
diff --git a/minadbd/services.cpp b/minadbd/services.cpp
index a83256796..dd1fd7c4b 100644
--- a/minadbd/services.cpp
+++ b/minadbd/services.cpp
@@ -43,15 +43,16 @@ void* service_bootstrap_func(void* x) {
return 0;
}
-static void sideload_host_service(int sfd, void* cookie) {
- char* saveptr;
- const char* s = adb_strtok_r(reinterpret_cast<char*>(cookie), ":", &saveptr);
- uint64_t file_size = strtoull(s, NULL, 10);
- s = adb_strtok_r(NULL, ":", &saveptr);
- uint32_t block_size = strtoul(s, NULL, 10);
-
- printf("sideload-host file size %" PRIu64 " block size %" PRIu32 "\n",
- file_size, block_size);
+static void sideload_host_service(int sfd, void* data) {
+ const char* args = reinterpret_cast<const char*>(data);
+ int file_size;
+ int block_size;
+ if (sscanf(args, "%d:%d", &file_size, &block_size) != 2) {
+ printf("bad sideload-host arguments: %s\n", args);
+ exit(1);
+ }
+
+ printf("sideload-host file size %d block size %d\n", file_size, block_size);
int result = run_adb_fuse(sfd, file_size, block_size);