* commit '87f73de9e9b0a74e4b963e8b49d90bbe81a38bb0': Remove confusing variable HOST.
This commit is contained in:
commit
63a29199f3
6 changed files with 39 additions and 49 deletions
14
adb/adb.cpp
14
adb/adb.cpp
|
|
@ -55,8 +55,6 @@
|
||||||
|
|
||||||
ADB_MUTEX_DEFINE(D_lock);
|
ADB_MUTEX_DEFINE(D_lock);
|
||||||
|
|
||||||
int HOST = 0;
|
|
||||||
|
|
||||||
#if !ADB_HOST
|
#if !ADB_HOST
|
||||||
const char* adb_device_banner = "device";
|
const char* adb_device_banner = "device";
|
||||||
static android::base::LogdLogger gLogdLogger;
|
static android::base::LogdLogger gLogdLogger;
|
||||||
|
|
@ -423,7 +421,9 @@ void handle_packet(apacket *p, atransport *t)
|
||||||
case A_SYNC:
|
case A_SYNC:
|
||||||
if(p->msg.arg0){
|
if(p->msg.arg0){
|
||||||
send_packet(p, t);
|
send_packet(p, t);
|
||||||
if(HOST) send_connect(t);
|
#if ADB_HOST
|
||||||
|
send_connect(t);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
t->connection_state = kCsOffline;
|
t->connection_state = kCsOffline;
|
||||||
handle_offline(t);
|
handle_offline(t);
|
||||||
|
|
@ -440,12 +440,16 @@ void handle_packet(apacket *p, atransport *t)
|
||||||
t->update_version(p->msg.arg0, p->msg.arg1);
|
t->update_version(p->msg.arg0, p->msg.arg1);
|
||||||
parse_banner(reinterpret_cast<const char*>(p->data), t);
|
parse_banner(reinterpret_cast<const char*>(p->data), t);
|
||||||
|
|
||||||
if (HOST || !auth_required) {
|
#if ADB_HOST
|
||||||
|
handle_online(t);
|
||||||
|
#else
|
||||||
|
if (!auth_required) {
|
||||||
handle_online(t);
|
handle_online(t);
|
||||||
if (!HOST) send_connect(t);
|
send_connect(t);
|
||||||
} else {
|
} else {
|
||||||
send_auth_request(t);
|
send_auth_request(t);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case A_AUTH:
|
case A_AUTH:
|
||||||
|
|
|
||||||
|
|
@ -381,7 +381,6 @@ int adb_commandline(int argc, const char **argv);
|
||||||
ConnectionState connection_state(atransport *t);
|
ConnectionState connection_state(atransport *t);
|
||||||
|
|
||||||
extern const char *adb_device_banner;
|
extern const char *adb_device_banner;
|
||||||
extern int HOST;
|
|
||||||
#if !ADB_HOST
|
#if !ADB_HOST
|
||||||
extern int SHELL_EXIT_NOTIFY_FD;
|
extern int SHELL_EXIT_NOTIFY_FD;
|
||||||
#endif // !ADB_HOST
|
#endif // !ADB_HOST
|
||||||
|
|
|
||||||
|
|
@ -137,8 +137,6 @@ static void setup_daemon_logging(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int adb_main(int is_daemon, int server_port, int ack_reply_fd) {
|
int adb_main(int is_daemon, int server_port, int ack_reply_fd) {
|
||||||
HOST = 1;
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
SetConsoleCtrlHandler(ctrlc_handler, TRUE);
|
SetConsoleCtrlHandler(ctrlc_handler, TRUE);
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
|
|
@ -465,9 +465,9 @@ int service_to_fd(const char *name)
|
||||||
ret = create_service_thread(framebuffer_service, 0);
|
ret = create_service_thread(framebuffer_service, 0);
|
||||||
} else if (!strncmp(name, "jdwp:", 5)) {
|
} else if (!strncmp(name, "jdwp:", 5)) {
|
||||||
ret = create_jdwp_connection_fd(atoi(name+5));
|
ret = create_jdwp_connection_fd(atoi(name+5));
|
||||||
} else if(!HOST && !strncmp(name, "shell:", 6)) {
|
} else if(!strncmp(name, "shell:", 6)) {
|
||||||
ret = create_subproc_thread(name + 6, true);
|
ret = create_subproc_thread(name + 6, true);
|
||||||
} else if(!HOST && !strncmp(name, "exec:", 5)) {
|
} else if(!strncmp(name, "exec:", 5)) {
|
||||||
ret = create_subproc_thread(name + 5);
|
ret = create_subproc_thread(name + 5);
|
||||||
} else if(!strncmp(name, "sync:", 5)) {
|
} else if(!strncmp(name, "sync:", 5)) {
|
||||||
ret = create_service_thread(file_sync_service, NULL);
|
ret = create_service_thread(file_sync_service, NULL);
|
||||||
|
|
|
||||||
|
|
@ -120,10 +120,9 @@ int local_connect_arbitrary_ports(int console_port, int adb_port, std::string* e
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ADB_HOST
|
||||||
static void *client_socket_thread(void *x)
|
static void *client_socket_thread(void *x)
|
||||||
{
|
{
|
||||||
#if ADB_HOST
|
|
||||||
D("transport: client_socket_thread() starting\n");
|
D("transport: client_socket_thread() starting\n");
|
||||||
while (true) {
|
while (true) {
|
||||||
int port = DEFAULT_ADB_LOCAL_TRANSPORT_PORT;
|
int port = DEFAULT_ADB_LOCAL_TRANSPORT_PORT;
|
||||||
|
|
@ -135,10 +134,11 @@ static void *client_socket_thread(void *x)
|
||||||
}
|
}
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else // ADB_HOST
|
||||||
|
|
||||||
static void *server_socket_thread(void * arg)
|
static void *server_socket_thread(void * arg)
|
||||||
{
|
{
|
||||||
int serverfd, fd;
|
int serverfd, fd;
|
||||||
|
|
@ -175,7 +175,6 @@ static void *server_socket_thread(void * arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is relevant only for ADB daemon running inside the emulator. */
|
/* This is relevant only for ADB daemon running inside the emulator. */
|
||||||
#if !ADB_HOST
|
|
||||||
/*
|
/*
|
||||||
* Redefine open and write for qemu_pipe.h that contains inlined references
|
* Redefine open and write for qemu_pipe.h that contains inlined references
|
||||||
* to those routines. We will redifine them back after qemu_pipe.h inclusion.
|
* to those routines. We will redifine them back after qemu_pipe.h inclusion.
|
||||||
|
|
@ -287,31 +286,29 @@ static const char _ok_resp[] = "ok";
|
||||||
void local_init(int port)
|
void local_init(int port)
|
||||||
{
|
{
|
||||||
void* (*func)(void *);
|
void* (*func)(void *);
|
||||||
|
const char* debug_name = "";
|
||||||
|
|
||||||
if(HOST) {
|
|
||||||
func = client_socket_thread;
|
|
||||||
} else {
|
|
||||||
#if ADB_HOST
|
#if ADB_HOST
|
||||||
func = server_socket_thread;
|
func = client_socket_thread;
|
||||||
|
debug_name = "client";
|
||||||
#else
|
#else
|
||||||
/* For the adbd daemon in the system image we need to distinguish
|
/* For the adbd daemon in the system image we need to distinguish
|
||||||
* between the device, and the emulator. */
|
* between the device, and the emulator. */
|
||||||
char is_qemu[PROPERTY_VALUE_MAX];
|
char is_qemu[PROPERTY_VALUE_MAX];
|
||||||
property_get("ro.kernel.qemu", is_qemu, "");
|
property_get("ro.kernel.qemu", is_qemu, "");
|
||||||
if (!strcmp(is_qemu, "1")) {
|
if (!strcmp(is_qemu, "1")) {
|
||||||
/* Running inside the emulator: use QEMUD pipe as the transport. */
|
/* Running inside the emulator: use QEMUD pipe as the transport. */
|
||||||
func = qemu_socket_thread;
|
func = qemu_socket_thread;
|
||||||
} else {
|
} else {
|
||||||
/* Running inside the device: use TCP socket as the transport. */
|
/* Running inside the device: use TCP socket as the transport. */
|
||||||
func = server_socket_thread;
|
func = server_socket_thread;
|
||||||
}
|
|
||||||
#endif // !ADB_HOST
|
|
||||||
}
|
}
|
||||||
|
debug_name = "server";
|
||||||
|
#endif // !ADB_HOST
|
||||||
|
|
||||||
D("transport: local %s init\n", HOST ? "client" : "server");
|
D("transport: local %s init\n", debug_name);
|
||||||
|
|
||||||
if (!adb_thread_create(func, (void *) (uintptr_t) port)) {
|
if (!adb_thread_create(func, (void *) (uintptr_t) port)) {
|
||||||
fatal_errno("cannot create local socket %s thread", HOST ? "client" : "server");
|
fatal_errno("cannot create local socket %s thread", debug_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -323,17 +320,15 @@ static void remote_kick(atransport *t)
|
||||||
adb_close(fd);
|
adb_close(fd);
|
||||||
|
|
||||||
#if ADB_HOST
|
#if ADB_HOST
|
||||||
if(HOST) {
|
int nn;
|
||||||
int nn;
|
adb_mutex_lock( &local_transports_lock );
|
||||||
adb_mutex_lock( &local_transports_lock );
|
for (nn = 0; nn < ADB_LOCAL_TRANSPORT_MAX; nn++) {
|
||||||
for (nn = 0; nn < ADB_LOCAL_TRANSPORT_MAX; nn++) {
|
if (local_transports[nn] == t) {
|
||||||
if (local_transports[nn] == t) {
|
local_transports[nn] = NULL;
|
||||||
local_transports[nn] = NULL;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
adb_mutex_unlock( &local_transports_lock );
|
|
||||||
}
|
}
|
||||||
|
adb_mutex_unlock( &local_transports_lock );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -404,7 +399,7 @@ int init_socket_transport(atransport *t, int s, int adb_port, int local)
|
||||||
t->adb_port = 0;
|
t->adb_port = 0;
|
||||||
|
|
||||||
#if ADB_HOST
|
#if ADB_HOST
|
||||||
if (HOST && local) {
|
if (local) {
|
||||||
adb_mutex_lock( &local_transports_lock );
|
adb_mutex_lock( &local_transports_lock );
|
||||||
{
|
{
|
||||||
t->adb_port = adb_port;
|
t->adb_port = adb_port;
|
||||||
|
|
|
||||||
|
|
@ -91,12 +91,6 @@ void init_usb_transport(atransport *t, usb_handle *h, ConnectionState state)
|
||||||
t->connection_state = state;
|
t->connection_state = state;
|
||||||
t->type = kTransportUsb;
|
t->type = kTransportUsb;
|
||||||
t->usb = h;
|
t->usb = h;
|
||||||
|
|
||||||
#if ADB_HOST
|
|
||||||
HOST = 1;
|
|
||||||
#else
|
|
||||||
HOST = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ADB_HOST
|
#if ADB_HOST
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue