summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Goby <benoit@android.com>2013-02-20 15:04:53 -0800
committerBenoit Goby <benoit@android.com>2013-04-24 21:31:45 -0700
commit9470c2f1ab555311633d52e5ed8303a813061cdf (patch)
treea37585e3fa59304b3c42e0515773b8bdfa57459d
parent49edc0acf8c78171751676af0f530d9529987075 (diff)
downloadsystem_core-9470c2f1ab555311633d52e5ed8303a813061cdf.zip
system_core-9470c2f1ab555311633d52e5ed8303a813061cdf.tar.gz
system_core-9470c2f1ab555311633d52e5ed8303a813061cdf.tar.bz2
adb: Cleanup dead code
dns_service is unused and recover_service has been replaced by adb sideload Change-Id: Ie90000d7f672e8299ee1622a9690c7371b214dc1
-rw-r--r--adb/Android.mk5
-rw-r--r--adb/SERVICES.TXT21
-rw-r--r--adb/adb.h5
-rw-r--r--adb/mutex_list.h1
-rw-r--r--adb/services.c103
-rw-r--r--adb/sockets.c12
-rw-r--r--adb/utils.c106
-rw-r--r--adb/utils.h68
8 files changed, 7 insertions, 314 deletions
diff --git a/adb/Android.mk b/adb/Android.mk
index a803978..36f595b 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -64,7 +64,6 @@ LOCAL_SRC_FILES := \
file_sync_client.c \
$(EXTRA_SRCS) \
$(USB_SRCS) \
- utils.c \
usb_vendors.c
LOCAL_C_INCLUDES += external/openssl/include
@@ -116,8 +115,7 @@ LOCAL_SRC_FILES := \
framebuffer_service.c \
remount_service.c \
usb_linux_client.c \
- log_service.c \
- utils.c
+ log_service.c
LOCAL_CFLAGS := -O2 -g -DADB_HOST=0 -Wall -Wno-unused-parameter
LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
@@ -157,7 +155,6 @@ LOCAL_SRC_FILES := \
file_sync_client.c \
get_my_path_linux.c \
usb_linux.c \
- utils.c \
usb_vendors.c \
fdevent.c
diff --git a/adb/SERVICES.TXT b/adb/SERVICES.TXT
index b53bc44..5966686 100644
--- a/adb/SERVICES.TXT
+++ b/adb/SERVICES.TXT
@@ -225,27 +225,6 @@ framebuffer:
If the adbd daemon doesn't have sufficient privileges to open
the framebuffer device, the connection is simply closed immediately.
-dns:<server-name>
- This service is an exception because it only runs within the ADB server.
- It is used to implement USB networking, i.e. to provide a network connection
- to the device through the host machine (note: this is the exact opposite of
- network tethering).
-
- It is used to perform a gethostbyname(<address>) on the host and return
- the corresponding IP address as a 4-byte string.
-
-recover:<size>
- This service is used to upload a recovery image to the device. <size>
- must be a number corresponding to the size of the file. The service works
- by:
-
- - creating a file named /tmp/update
- - reading 'size' bytes from the client and writing them to /tmp/update
- - when everything is read successfully, create a file named /tmp/update.start
-
- This service can only work when the device is in recovery mode. Otherwise,
- the /tmp directory doesn't exist and the connection will be closed immediately.
-
jdwp:<pid>
Connects to the JDWP thread running in the VM of process <pid>.
diff --git a/adb/adb.h b/adb/adb.h
index a01d460..38767e5 100644
--- a/adb/adb.h
+++ b/adb/adb.h
@@ -128,10 +128,7 @@ struct asocket {
*/
void (*close)(asocket *s);
- /* socket-type-specific extradata */
- void *extra;
-
- /* A socket is bound to atransport */
+ /* A socket is bound to atransport */
atransport *transport;
};
diff --git a/adb/mutex_list.h b/adb/mutex_list.h
index 652dd73..ff72751 100644
--- a/adb/mutex_list.h
+++ b/adb/mutex_list.h
@@ -6,7 +6,6 @@
#ifndef ADB_MUTEX
#error ADB_MUTEX not defined when including this file
#endif
-ADB_MUTEX(dns_lock)
ADB_MUTEX(socket_list_lock)
ADB_MUTEX(transport_lock)
#if ADB_HOST
diff --git a/adb/services.c b/adb/services.c
index e82a0ea..619199f 100644
--- a/adb/services.c
+++ b/adb/services.c
@@ -53,59 +53,7 @@ void *service_bootstrap_func(void *x)
return 0;
}
-#if ADB_HOST
-ADB_MUTEX_DEFINE( dns_lock );
-
-static void dns_service(int fd, void *cookie)
-{
- char *hostname = cookie;
- struct hostent *hp;
- unsigned zero = 0;
-
- adb_mutex_lock(&dns_lock);
- hp = gethostbyname(hostname);
- free(cookie);
- if(hp == 0) {
- writex(fd, &zero, 4);
- } else {
- writex(fd, hp->h_addr, 4);
- }
- adb_mutex_unlock(&dns_lock);
- adb_close(fd);
-}
-#else
-extern int recovery_mode;
-
-static void recover_service(int s, void *cookie)
-{
- unsigned char buf[4096];
- unsigned count = (unsigned) cookie;
- int fd;
-
- fd = adb_creat("/tmp/update", 0644);
- if(fd < 0) {
- adb_close(s);
- return;
- }
-
- while(count > 0) {
- unsigned xfer = (count > 4096) ? 4096 : count;
- if(readx(s, buf, xfer)) break;
- if(writex(fd, buf, xfer)) break;
- count -= xfer;
- }
-
- if(count == 0) {
- writex(s, "OKAY", 4);
- } else {
- writex(s, "FAIL", 4);
- }
- adb_close(fd);
- adb_close(s);
-
- fd = adb_creat("/tmp/update.begin", 0644);
- adb_close(fd);
-}
+#if !ADB_HOST
void restart_root_service(int fd, void *cookie)
{
@@ -202,40 +150,6 @@ cleanup:
#endif
-#if 0
-static void echo_service(int fd, void *cookie)
-{
- char buf[4096];
- int r;
- char *p;
- int c;
-
- for(;;) {
- r = adb_read(fd, buf, 4096);
- if(r == 0) goto done;
- if(r < 0) {
- if(errno == EINTR) continue;
- else goto done;
- }
-
- c = r;
- p = buf;
- while(c > 0) {
- r = write(fd, p, c);
- if(r > 0) {
- c -= r;
- p += r;
- continue;
- }
- if((r < 0) && (errno == EINTR)) continue;
- goto done;
- }
- }
-done:
- close(fd);
-}
-#endif
-
static int create_service_thread(void (*func)(int, void *), void *cookie)
{
stinfo *sti;
@@ -422,9 +336,7 @@ int service_to_fd(const char *name)
disable_tcp_nagle(ret);
} else {
#if ADB_HOST
- adb_mutex_lock(&dns_lock);
ret = socket_network_client(name + 1, port, SOCK_STREAM);
- adb_mutex_unlock(&dns_lock);
#else
return -1;
#endif
@@ -443,18 +355,11 @@ int service_to_fd(const char *name)
ret = socket_local_client(name + 16,
ANDROID_SOCKET_NAMESPACE_FILESYSTEM, SOCK_STREAM);
#endif
-#if ADB_HOST
- } else if(!strncmp("dns:", name, 4)){
- char *n = strdup(name + 4);
- if(n == 0) return -1;
- ret = create_service_thread(dns_service, n);
-#else /* !ADB_HOST */
+#if !ADB_HOST
} else if(!strncmp("dev:", name, 4)) {
ret = unix_open(name + 4, O_RDWR);
} else if(!strncmp(name, "framebuffer:", 12)) {
ret = create_service_thread(framebuffer_service, 0);
- } else if(recovery_mode && !strncmp(name, "recover:", 8)) {
- ret = create_service_thread(recover_service, (void*) atoi(name + 8));
} else if (!strncmp(name, "jdwp:", 5)) {
ret = create_jdwp_connection_fd(atoi(name+5));
} else if (!strncmp(name, "log:", 4)) {
@@ -490,10 +395,6 @@ int service_to_fd(const char *name)
} else if(!strncmp(name, "usb:", 4)) {
ret = create_service_thread(restart_usb_service, NULL);
#endif
-#if 0
- } else if(!strncmp(name, "echo:", 5)){
- ret = create_service_thread(echo_service, 0);
-#endif
}
if (ret >= 0) {
close_on_exec(ret);
diff --git a/adb/sockets.c b/adb/sockets.c
index 305cb44..f17608b 100644
--- a/adb/sockets.c
+++ b/adb/sockets.c
@@ -844,7 +844,7 @@ static void smart_socket_close(asocket *s)
free(s);
}
-asocket *create_smart_socket(void (*action_cb)(asocket *s, const char *act))
+static asocket *create_smart_socket(void)
{
D("Creating smart socket \n");
asocket *s = calloc(1, sizeof(asocket));
@@ -852,21 +852,15 @@ asocket *create_smart_socket(void (*action_cb)(asocket *s, const char *act))
s->enqueue = smart_socket_enqueue;
s->ready = smart_socket_ready;
s->close = smart_socket_close;
- s->extra = action_cb;
- D("SS(%d): created %p\n", s->id, action_cb);
+ D("SS(%d)\n", s->id);
return s;
}
-void smart_socket_action(asocket *s, const char *act)
-{
-
-}
-
void connect_to_smartsocket(asocket *s)
{
D("Connecting to smart socket \n");
- asocket *ss = create_smart_socket(smart_socket_action);
+ asocket *ss = create_smart_socket();
s->peer = ss;
ss->peer = s;
s->ready(s);
diff --git a/adb/utils.c b/adb/utils.c
deleted file mode 100644
index 91518ba..0000000
--- a/adb/utils.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "utils.h"
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-
-char*
-buff_addc (char* buff, char* buffEnd, int c)
-{
- int avail = buffEnd - buff;
-
- if (avail <= 0) /* already in overflow mode */
- return buff;
-
- if (avail == 1) { /* overflowing, the last byte is reserved for zero */
- buff[0] = 0;
- return buff + 1;
- }
-
- buff[0] = (char) c; /* add char and terminating zero */
- buff[1] = 0;
- return buff + 1;
-}
-
-char*
-buff_adds (char* buff, char* buffEnd, const char* s)
-{
- int slen = strlen(s);
-
- return buff_addb(buff, buffEnd, s, slen);
-}
-
-char*
-buff_addb (char* buff, char* buffEnd, const void* data, int len)
-{
- int avail = (buffEnd - buff);
-
- if (avail <= 0 || len <= 0) /* already overflowing */
- return buff;
-
- if (len > avail)
- len = avail;
-
- memcpy(buff, data, len);
-
- buff += len;
-
- /* ensure there is a terminating zero */
- if (buff >= buffEnd) { /* overflow */
- buff[-1] = 0;
- } else
- buff[0] = 0;
-
- return buff;
-}
-
-char*
-buff_add (char* buff, char* buffEnd, const char* format, ... )
-{
- int avail;
-
- avail = (buffEnd - buff);
-
- if (avail > 0) {
- va_list args;
- int nn;
-
- va_start(args, format);
- nn = vsnprintf( buff, avail, format, args);
- va_end(args);
-
- if (nn < 0) {
- /* some C libraries return -1 in case of overflow,
- * but they will also do that if the format spec is
- * invalid. We assume ADB is not buggy enough to
- * trigger that last case. */
- nn = avail;
- }
- else if (nn > avail) {
- nn = avail;
- }
-
- buff += nn;
-
- /* ensure that there is a terminating zero */
- if (buff >= buffEnd)
- buff[-1] = 0;
- else
- buff[0] = 0;
- }
- return buff;
-}
diff --git a/adb/utils.h b/adb/utils.h
deleted file mode 100644
index f70ecd2..0000000
--- a/adb/utils.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef _ADB_UTILS_H
-#define _ADB_UTILS_H
-
-/* bounded buffer functions */
-
-/* all these functions are used to append data to a bounded buffer.
- *
- * after each operation, the buffer is guaranteed to be zero-terminated,
- * even in the case of an overflow. they all return the new buffer position
- * which allows one to use them in succession, only checking for overflows
- * at the end. For example:
- *
- * BUFF_DECL(temp,p,end,1024);
- * char* p;
- *
- * p = buff_addc(temp, end, '"');
- * p = buff_adds(temp, end, string);
- * p = buff_addc(temp, end, '"');
- *
- * if (p >= end) {
- * overflow detected. note that 'temp' is
- * zero-terminated for safety.
- * }
- * return strdup(temp);
- */
-
-/* tries to add a character to the buffer, in case of overflow
- * this will only write a terminating zero and return buffEnd.
- */
-char* buff_addc (char* buff, char* buffEnd, int c);
-
-/* tries to add a string to the buffer */
-char* buff_adds (char* buff, char* buffEnd, const char* s);
-
-/* tries to add a bytes to the buffer. the input can contain zero bytes,
- * but a terminating zero will always be appended at the end anyway
- */
-char* buff_addb (char* buff, char* buffEnd, const void* data, int len);
-
-/* tries to add a formatted string to a bounded buffer */
-char* buff_add (char* buff, char* buffEnd, const char* format, ... );
-
-/* convenience macro used to define a bounded buffer, as well as
- * a 'cursor' and 'end' variables all in one go.
- *
- * note: this doesn't place an initial terminating zero in the buffer,
- * you need to use one of the buff_ functions for this. or simply
- * do _cursor[0] = 0 manually.
- */
-#define BUFF_DECL(_buff,_cursor,_end,_size) \
- char _buff[_size], *_cursor=_buff, *_end = _cursor + (_size)
-
-#endif /* _ADB_UTILS_H */