summaryrefslogtreecommitdiffstats
path: root/adb
diff options
context:
space:
mode:
Diffstat (limited to 'adb')
-rw-r--r--adb/Android.mk44
-rw-r--r--adb/adb.h10
-rw-r--r--adb/commandline.c20
-rw-r--r--adb/framebuffer_service.c89
4 files changed, 119 insertions, 44 deletions
diff --git a/adb/Android.mk b/adb/Android.mk
index 7faca9b..df96d58 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -152,3 +152,47 @@ else
endif
endif
+
+
+# adb host tool for device-as-host
+# =========================================================
+ifneq ($(TARGET_SIMULATOR),true)
+ifneq ($(SDK_ONLY),true)
+include $(CLEAR_VARS)
+
+LOCAL_LDLIBS := -lrt -lncurses -lpthread
+
+LOCAL_SRC_FILES := \
+ adb.c \
+ console.c \
+ transport.c \
+ transport_local.c \
+ transport_usb.c \
+ commandline.c \
+ adb_client.c \
+ sockets.c \
+ services.c \
+ file_sync_client.c \
+ get_my_path_linux.c \
+ usb_linux.c \
+ utils.c \
+ usb_vendors.c \
+ fdevent.c
+
+LOCAL_CFLAGS := \
+ -O2 \
+ -g \
+ -DADB_HOST=1 \
+ -DADB_HOST_ON_TARGET=1 \
+ -Wall \
+ -Wno-unused-parameter \
+ -D_XOPEN_SOURCE \
+ -D_GNU_SOURCE
+
+LOCAL_MODULE := adb
+
+LOCAL_STATIC_LIBRARIES := libzipfile libunz libcutils
+
+include $(BUILD_EXECUTABLE)
+endif
+endif
diff --git a/adb/adb.h b/adb/adb.h
index 3d2a77b..0aa98d3 100644
--- a/adb/adb.h
+++ b/adb/adb.h
@@ -366,7 +366,15 @@ typedef enum {
#define print_packet(tag,p) do {} while (0)
#endif
-#define DEFAULT_ADB_PORT 5037
+#if ADB_HOST_ON_TARGET
+/* adb and adbd are coexisting on the target, so use 5038 for adb
+ * to avoid conflicting with adbd's usage of 5037
+ */
+# define DEFAULT_ADB_PORT 5038
+#else
+# define DEFAULT_ADB_PORT 5037
+#endif
+
#define DEFAULT_ADB_LOCAL_TRANSPORT_PORT 5555
#define ADB_CLASS 0xff
diff --git a/adb/commandline.c b/adb/commandline.c
index dcba83b..3600e5a 100644
--- a/adb/commandline.c
+++ b/adb/commandline.c
@@ -838,12 +838,24 @@ top:
return adb_send_emulator_command(argc, argv);
}
- if(!strcmp(argv[0], "shell")) {
+ if(!strcmp(argv[0], "shell") || !strcmp(argv[0], "hell")) {
int r;
int fd;
+ char h = (argv[0][0] == 'h');
+
+ if (h) {
+ printf("\x1b[41;33m");
+ fflush(stdout);
+ }
+
if(argc < 2) {
- return interactive_shell();
+ r = interactive_shell();
+ if (h) {
+ printf("\x1b[0m");
+ fflush(stdout);
+ }
+ return r;
}
snprintf(buf, sizeof buf, "shell:%s", argv[1]);
@@ -877,6 +889,10 @@ top:
adb_sleep_ms(1000);
do_cmd(ttype, serial, "wait-for-device", 0);
} else {
+ if (h) {
+ printf("\x1b[0m");
+ fflush(stdout);
+ }
return r;
}
}
diff --git a/adb/framebuffer_service.c b/adb/framebuffer_service.c
index 2f45694..434eb1c 100644
--- a/adb/framebuffer_service.c
+++ b/adb/framebuffer_service.c
@@ -51,56 +51,63 @@ struct fbinfo {
void framebuffer_service(int fd, void *cookie)
{
- struct fb_var_screeninfo vinfo;
- int fb, offset;
- char x[256];
-
struct fbinfo fbinfo;
- unsigned i, bytespp;
-
- fb = open("/dev/graphics/fb0", O_RDONLY);
- if(fb < 0) goto done;
+ unsigned int i;
+ char buf[640];
+ int fd_screencap;
+ int w, h, f;
+ int fds[2];
+
+ if (pipe(fds) < 0) goto done;
+
+ pid_t pid = fork();
+ if (pid < 0) goto done;
+
+ if (pid == 0) {
+ dup2(fds[1], STDOUT_FILENO);
+ close(fds[0]);
+ close(fds[1]);
+ const char* command = "screencap";
+ const char *args[2] = {command, NULL};
+ execvp(command, (char**)args);
+ exit(1);
+ }
- if(ioctl(fb, FBIOGET_VSCREENINFO, &vinfo) < 0) goto done;
- fcntl(fb, F_SETFD, FD_CLOEXEC);
+ fd_screencap = fds[0];
- bytespp = vinfo.bits_per_pixel / 8;
+ /* read w, h & format */
+ if(readx(fd_screencap, &w, 4)) goto done;
+ if(readx(fd_screencap, &h, 4)) goto done;
+ if(readx(fd_screencap, &f, 4)) goto done;
+ /* for now always assume RGBX_8888 format */
fbinfo.version = DDMS_RAWIMAGE_VERSION;
- fbinfo.bpp = vinfo.bits_per_pixel;
- fbinfo.size = vinfo.xres * vinfo.yres * bytespp;
- fbinfo.width = vinfo.xres;
- fbinfo.height = vinfo.yres;
- fbinfo.red_offset = vinfo.red.offset;
- fbinfo.red_length = vinfo.red.length;
- fbinfo.green_offset = vinfo.green.offset;
- fbinfo.green_length = vinfo.green.length;
- fbinfo.blue_offset = vinfo.blue.offset;
- fbinfo.blue_length = vinfo.blue.length;
- fbinfo.alpha_offset = vinfo.transp.offset;
- fbinfo.alpha_length = vinfo.transp.length;
-
- /* HACK: for several of our 3d cores a specific alignment
- * is required so the start of the fb may not be an integer number of lines
- * from the base. As a result we are storing the additional offset in
- * xoffset. This is not the correct usage for xoffset, it should be added
- * to each line, not just once at the beginning */
- offset = vinfo.xoffset * bytespp;
-
- offset += vinfo.xres * vinfo.yoffset * bytespp;
-
+ fbinfo.bpp = 32;
+ fbinfo.size = w * h * 4;
+ fbinfo.width = w;
+ fbinfo.height = h;
+ fbinfo.red_offset = 0;
+ fbinfo.red_length = 8;
+ fbinfo.green_offset = 8;
+ fbinfo.green_length = 8;
+ fbinfo.blue_offset = 16;
+ fbinfo.blue_length = 8;
+ fbinfo.alpha_offset = 24;
+ fbinfo.alpha_length = 8;
+
+ /* write header */
if(writex(fd, &fbinfo, sizeof(fbinfo))) goto done;
- lseek(fb, offset, SEEK_SET);
- for(i = 0; i < fbinfo.size; i += 256) {
- if(readx(fb, &x, 256)) goto done;
- if(writex(fd, &x, 256)) goto done;
+ /* write data */
+ for(i = 0; i < fbinfo.size; i += sizeof(buf)) {
+ if(readx(fd_screencap, buf, sizeof(buf))) goto done;
+ if(writex(fd, buf, sizeof(buf))) goto done;
}
-
- if(readx(fb, &x, fbinfo.size % 256)) goto done;
- if(writex(fd, &x, fbinfo.size % 256)) goto done;
+ if(readx(fd_screencap, buf, fbinfo.size % sizeof(buf))) goto done;
+ if(writex(fd, buf, fbinfo.size % sizeof(buf))) goto done;
done:
- if(fb >= 0) close(fb);
+ close(fds[0]);
+ close(fds[1]);
close(fd);
}