Merge "adb: add track-jdwp and track-devices commands."
am: f8f40a1e2e
* commit 'f8f40a1e2e6162b7f334f83a10f6a5d9ef44f75f':
adb: add track-jdwp and track-devices commands.
Change-Id: I96e185b1235aaa2c82371a53415fa44c57444dac
This commit is contained in:
commit
32045567be
3 changed files with 8 additions and 87 deletions
|
|
@ -208,24 +208,6 @@ LOCAL_MULTILIB := first
|
||||||
|
|
||||||
include $(BUILD_HOST_NATIVE_TEST)
|
include $(BUILD_HOST_NATIVE_TEST)
|
||||||
|
|
||||||
# adb device tracker (used by ddms) test tool
|
|
||||||
# =========================================================
|
|
||||||
|
|
||||||
ifeq ($(HOST_OS),linux)
|
|
||||||
include $(CLEAR_VARS)
|
|
||||||
LOCAL_MODULE := adb_device_tracker_test
|
|
||||||
LOCAL_CFLAGS := -DADB_HOST=1 $(LIBADB_CFLAGS)
|
|
||||||
LOCAL_CFLAGS_windows := $(LIBADB_windows_CFLAGS)
|
|
||||||
LOCAL_CFLAGS_linux := $(LIBADB_linux_CFLAGS)
|
|
||||||
LOCAL_CFLAGS_darwin := $(LIBADB_darwin_CFLAGS)
|
|
||||||
LOCAL_SRC_FILES := test_track_devices.cpp
|
|
||||||
LOCAL_SANITIZE := $(adb_host_sanitize)
|
|
||||||
LOCAL_SHARED_LIBRARIES := libbase
|
|
||||||
LOCAL_STATIC_LIBRARIES := libadb libcrypto_utils_static libcrypto_static libcutils
|
|
||||||
LOCAL_LDLIBS += -lrt -ldl -lpthread
|
|
||||||
include $(BUILD_HOST_EXECUTABLE)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# adb host tool
|
# adb host tool
|
||||||
# =========================================================
|
# =========================================================
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
|
||||||
|
|
@ -1902,6 +1902,14 @@ int adb_commandline(int argc, const char **argv) {
|
||||||
else if (!strcmp(argv[0], "jdwp")) {
|
else if (!strcmp(argv[0], "jdwp")) {
|
||||||
return adb_connect_command("jdwp");
|
return adb_connect_command("jdwp");
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(argv[0], "track-jdwp")) {
|
||||||
|
return adb_connect_command("track-jdwp");
|
||||||
|
}
|
||||||
|
else if (!strcmp(argv[0], "track-devices")) {
|
||||||
|
return adb_connect_command("host:track-devices");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* "adb /?" is a common idiom under Windows */
|
/* "adb /?" is a common idiom under Windows */
|
||||||
else if (!strcmp(argv[0], "help") || !strcmp(argv[0], "/?")) {
|
else if (!strcmp(argv[0], "help") || !strcmp(argv[0], "/?")) {
|
||||||
help();
|
help();
|
||||||
|
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
||||||
// TODO: replace this with a shell/python script.
|
|
||||||
|
|
||||||
/* a simple test program, connects to ADB server, and opens a track-devices session */
|
|
||||||
#include <errno.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <android-base/file.h>
|
|
||||||
|
|
||||||
static void
|
|
||||||
panic( const char* msg )
|
|
||||||
{
|
|
||||||
fprintf(stderr, "PANIC: %s: %s\n", msg, strerror(errno));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
|
||||||
const char* request = "host:track-devices";
|
|
||||||
|
|
||||||
if (argv[1] && strcmp(argv[1], "--jdwp") == 0) {
|
|
||||||
request = "track-jdwp";
|
|
||||||
}
|
|
||||||
|
|
||||||
int ret;
|
|
||||||
struct sockaddr_in server;
|
|
||||||
char buffer[1024];
|
|
||||||
|
|
||||||
memset( &server, 0, sizeof(server) );
|
|
||||||
server.sin_family = AF_INET;
|
|
||||||
server.sin_port = htons(5037);
|
|
||||||
server.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
|
||||||
|
|
||||||
int s = socket( PF_INET, SOCK_STREAM, 0 );
|
|
||||||
ret = connect( s, (struct sockaddr*) &server, sizeof(server) );
|
|
||||||
if (ret < 0) panic( "could not connect to server" );
|
|
||||||
|
|
||||||
/* send the request */
|
|
||||||
int len = snprintf(buffer, sizeof(buffer), "%04zx%s", strlen(request), request);
|
|
||||||
if (!android::base::WriteFully(s, buffer, len))
|
|
||||||
panic( "could not send request" );
|
|
||||||
|
|
||||||
/* read the OKAY answer */
|
|
||||||
if (!android::base::ReadFully(s, buffer, 4))
|
|
||||||
panic( "could not read request" );
|
|
||||||
|
|
||||||
printf( "server answer: %.*s\n", 4, buffer );
|
|
||||||
|
|
||||||
/* now loop */
|
|
||||||
while (true) {
|
|
||||||
char head[5] = "0000";
|
|
||||||
|
|
||||||
if (!android::base::ReadFully(s, head, 4))
|
|
||||||
panic("could not read length");
|
|
||||||
|
|
||||||
int len;
|
|
||||||
if (sscanf(head, "%04x", &len) != 1 )
|
|
||||||
panic("could not decode length");
|
|
||||||
|
|
||||||
if (!android::base::ReadFully(s, buffer, len))
|
|
||||||
panic("could not read data");
|
|
||||||
|
|
||||||
printf( "received header %.*s (%d bytes):\n%.*s----\n", 4, head, len, len, buffer );
|
|
||||||
}
|
|
||||||
close(s);
|
|
||||||
}
|
|
||||||
Loading…
Add table
Reference in a new issue