diff options
Diffstat (limited to 'adb')
| -rw-r--r-- | adb/adb.c | 3 | ||||
| -rw-r--r-- | adb/adb.h | 2 | ||||
| -rw-r--r-- | adb/commandline.c | 25 | ||||
| -rw-r--r-- | adb/services.c | 16 | ||||
| -rw-r--r-- | adb/usb_linux.c | 11 | ||||
| -rw-r--r-- | adb/usb_vendors.c | 12 |
6 files changed, 56 insertions, 13 deletions
@@ -895,9 +895,10 @@ int adb_main(int is_daemon) ** AID_GRAPHICS to access the frame buffer ** AID_NET_BT and AID_NET_BT_ADMIN to diagnose bluetooth (hcidump) ** AID_SDCARD_RW to allow writing to the SD card + ** AID_MOUNT to allow unmounting the SD card before rebooting */ gid_t groups[] = { AID_ADB, AID_LOG, AID_INPUT, AID_INET, AID_GRAPHICS, - AID_NET_BT, AID_NET_BT_ADMIN, AID_SDCARD_RW }; + AID_NET_BT, AID_NET_BT_ADMIN, AID_SDCARD_RW, AID_MOUNT }; setgroups(sizeof(groups)/sizeof(groups[0]), groups); /* then switch user and group to "shell" */ @@ -33,7 +33,7 @@ #define ADB_VERSION_MAJOR 1 // Used for help/version information #define ADB_VERSION_MINOR 0 // Used for help/version information -#define ADB_SERVER_VERSION 25 // Increment this when we want to force users to start a new adb server +#define ADB_SERVER_VERSION 26 // Increment this when we want to force users to start a new adb server typedef struct amessage amessage; typedef struct apacket apacket; diff --git a/adb/commandline.c b/adb/commandline.c index 57567524..857cee3b 100644 --- a/adb/commandline.c +++ b/adb/commandline.c @@ -105,8 +105,8 @@ void help() " environment variable is used, which must\n" " be an absolute path.\n" " devices - list all connected devices\n" - " connect <host>:<port> - connect to a device via TCP/IP" - " disconnect <host>:<port> - disconnect from a TCP/IP device" + " connect <host>:<port> - connect to a device via TCP/IP\n" + " disconnect <host>:<port> - disconnect from a TCP/IP device\n" "\n" "device commands:\n" " adb push <local> <remote> - copy file/dir to device\n" @@ -126,9 +126,10 @@ void help() " dev:<character device name>\n" " jdwp:<process pid> (remote only)\n" " adb jdwp - list PIDs of processes hosting a JDWP transport\n" - " adb install [-l] [-r] <file> - push this package file to the device and install it\n" + " adb install [-l] [-r] [-s] <file> - push this package file to the device and install it\n" " ('-l' means forward-lock the app)\n" " ('-r' means reinstall the app, keeping its data)\n" + " ('-s' means install on SD card instead of internal storage)\n" " adb uninstall [-k] <package> - remove this app package from the device\n" " ('-k' means keep the data and cache directories)\n" " adb bugreport - return all information from the device\n" @@ -220,8 +221,8 @@ static void read_and_dump(int fd) if(errno == EINTR) continue; break; } - /* we want to output to stdout, so no adb_write here !! */ - unix_write(1, buf, len); + fwrite(buf, 1, len, stdout); + fflush(stdout); } } @@ -1255,17 +1256,25 @@ int install_app(transport_type transport, char* serial, int argc, char** argv) { struct stat st; int err; - const char *const WHERE = "/data/local/tmp/%s"; + const char *const DATA_DEST = "/data/local/tmp/%s"; + const char *const SD_DEST = "/sdcard/tmp/%s"; + const char* where = DATA_DEST; char to[PATH_MAX]; char* filename = argv[argc - 1]; const char* p; + int i; + + for (i = 0; i < argc; i++) { + if (!strcmp(argv[i], "-s")) + where = SD_DEST; + } p = adb_dirstop(filename); if (p) { p++; - snprintf(to, sizeof to, WHERE, p); + snprintf(to, sizeof to, where, p); } else { - snprintf(to, sizeof to, WHERE, filename); + snprintf(to, sizeof to, where, filename); } if (p[0] == '\0') { } diff --git a/adb/services.c b/adb/services.c index b5df5542..487c7d37 100644 --- a/adb/services.c +++ b/adb/services.c @@ -176,9 +176,23 @@ void restart_usb_service(int fd, void *cookie) void reboot_service(int fd, void *arg) { char buf[100]; - int ret; + int pid, ret; sync(); + + /* Attempt to unmount the SD card first. + * No need to bother checking for errors. + */ + pid = fork(); + if (pid == 0) { + /* ask vdc to unmount it */ + execl("/system/bin/vdc", "/system/bin/vdc", "volume", "unmount", + getenv("EXTERNAL_STORAGE"), "force", NULL); + } else if (pid > 0) { + /* wait until vdc succeeds or fails */ + waitpid(pid, &ret, 0); + } + ret = __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, (char *)arg); if (ret < 0) { diff --git a/adb/usb_linux.c b/adb/usb_linux.c index 66ee317e..bb868135 100644 --- a/adb/usb_linux.c +++ b/adb/usb_linux.c @@ -21,6 +21,7 @@ #include <sys/ioctl.h> #include <sys/types.h> +#include <sys/time.h> #include <dirent.h> #include <fcntl.h> #include <errno.h> @@ -287,6 +288,8 @@ static int usb_bulk_write(usb_handle *h, const void *data, int len) { struct usbdevfs_urb *urb = &h->urb_out; int res; + struct timeval tv; + struct timespec ts; memset(urb, 0, sizeof(*urb)); urb->type = USBDEVFS_URB_TYPE_BULK; @@ -313,8 +316,12 @@ static int usb_bulk_write(usb_handle *h, const void *data, int len) res = -1; h->urb_out_busy = 1; for(;;) { - adb_cond_wait(&h->notify, &h->lock); - if(h->dead) { + /* time out after five seconds */ + gettimeofday(&tv, NULL); + ts.tv_sec = tv.tv_sec + 5; + ts.tv_nsec = tv.tv_usec * 1000L; + res = pthread_cond_timedwait(&h->notify, &h->lock, &ts); + if(res < 0 || h->dead) { break; } if(h->urb_out_busy == 0) { diff --git a/adb/usb_vendors.c b/adb/usb_vendors.c index 73bf4184..7f3cb543 100644 --- a/adb/usb_vendors.c +++ b/adb/usb_vendors.c @@ -59,6 +59,14 @@ #define VENDOR_ID_NVIDIA 0x0955 // Garmin-Asus's USB Vendor ID #define VENDOR_ID_GARMIN_ASUS 0x091E +// Sharp's USB Vendor ID +#define VENDOR_ID_SHARP 0x04dd +// ZTE's USB Vendor ID +#define VENDOR_ID_ZTE 0x19D2 +// Kyocera's USB Vendor ID +#define VENDOR_ID_KYOCERA 0x0482 +// Pantech's USB Vendor ID +#define VENDOR_ID_PANTECH 0x10A9 /** built-in vendor list */ @@ -75,6 +83,10 @@ int builtInVendorIds[] = { VENDOR_ID_DELL, VENDOR_ID_NVIDIA, VENDOR_ID_GARMIN_ASUS, + VENDOR_ID_SHARP, + VENDOR_ID_ZTE, + VENDOR_ID_KYOCERA, + VENDOR_ID_PANTECH, }; #define BUILT_IN_VENDOR_COUNT (sizeof(builtInVendorIds)/sizeof(builtInVendorIds[0])) |
