From: kh5325.kim Date: Tue, 16 Apr 2013 07:43:14 +0000 (+0900) Subject: Upload tizen_2.1 source X-Git-Tag: 2.1b_release~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=059d5051c337f6775227ab165097d46e6aa5479b;p=sdk%2Ftools%2Fsdb.git Upload tizen_2.1 source Change-Id: I21e31cad9e7116a7d348b14c2577824d20a6eb84 --- diff --git a/package/changelog b/package/changelog index 6986a91..18cfe9b 100644 --- a/package/changelog +++ b/package/changelog @@ -1,33 +1,39 @@ +* 2.1.23 +- change pkgcmd path +== yoonki.park 2013-04-13 +* 2.1.22 +- fixed build error for windows +== yoonki.park 2013-04-13 +* 2.1.21 +- Add wgt install / uninstall +== ho.namkoong 2013-04-12 +* 2.1.2 +- Make install path /opt/usr/apps/ +== ho.namkoong 2013-04-05 12:03 +* 2.1.1 +- add root command +== yoonki.park 2013-03-29 * 2.1.0 -- Update pkg version to the 2.1.0 +- update version to 2.1.0 == ho.namkoong 2013-03-11 -* 1.0.24 -- Check gksudo or sudo exist -== ho.namkoong 2013-03-08 -* 1.0.23 -- comment out goto fail when setting 2 configuration -== yoonki.park 2013-01-22 -* 1.0.21 -- fixed dlog bug -== ho.namkoong 2012-12-18 * 1.0.20 -- fixed install command -== yoonki.park 2012-12-18 00:10 +- comment out goto fail when setting 2 configuration +== yoonki.park 2013-01-22 00:11 * 1.0.19 -- add connect/disconnect command again -== yoonki.park 2012-12-17 22:30 +- remove stdout if command -serial +== yoonki.park 2012-12-22 00:11 * 1.0.18 -- fixed build error for windows -== yoonki.park 2012-12-17 21:30 +- fixed to install a application +== yoonki.park 2012-12-18 00:11 * 1.0.17 -- add connect/disconnect command -== yoonki.park 2012-12-17 17:30 +- fixed build error for windows +== yoonki.park 2012-12-17 21:11 * 1.0.16 -- fixed build error in macos -== yoonki.park 2012-11-27 17:30 +- version up to 1.0.16 +== yoonki.park 2012-12-17 17:11 * 1.0.15 -- support install/uninstall command -== yoonki.park 2012-11-27 17:30 +- add udev rule to give usb node permission 666 +== yoonki.park 2012-11-02 18:13 * 1.0.14 - remove ssh package from sdb == yoonki.park 2012-11-06 17:30 diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest index f911c19..29ab7df 100644 --- a/package/pkginfo.manifest +++ b/package/pkginfo.manifest @@ -1,4 +1,4 @@ -Version:2.1.0 +Version:2.1.23 Source:sdb Maintainer:Kangho Kim , Yoonki Park, Hyunsik Noh, Gun Kim, Ho Namkoong, Taeyoung Son diff --git a/src/android_reboot.c b/src/android_reboot.c index 238a3d6..db8a4a9 100644 --- a/src/android_reboot.c +++ b/src/android_reboot.c @@ -51,8 +51,8 @@ static int remount_ro_done(void) mount_dev, mount_dir, mount_type, mount_opts, &mount_freq, &mount_passno); mount_dev[255] = 0; - mount_dir[255] = 0; - mount_type[255] = 0; + //mount_dir[255] = 0; + //mount_type[255] = 0; mount_opts[255] = 0; if ((match == 6) && !strncmp(mount_dev, "/dev/block", 10) && strstr(mount_opts, "rw")) { found_rw_fs = 1; @@ -79,7 +79,6 @@ static int remount_ro_done(void) static void remount_ro(void) { int fd, cnt = 0; - int len = 0; /* Trigger the remount of the filesystems as read-only, * which also marks them clean. */ @@ -87,7 +86,7 @@ static void remount_ro(void) if (fd < 0) { return; } - len = write(fd, "u", 1); + write(fd, "u", 1); close(fd); /* Now poll /proc/mounts till it's done */ diff --git a/src/commandline.c b/src/commandline.c index 1e4ec1e..1b6bba8 100755 --- a/src/commandline.c +++ b/src/commandline.c @@ -46,7 +46,10 @@ int install_app(transport_type transport, char* serial, int argc, char** argv); int uninstall_app_sdb(const char *app_id); int install_app_sdb(const char *srcpath); int uninstall_app(transport_type transport, char* serial, int argc, char** argv); +int get_pkgtype_file_name(const char* file_name); +int get_pkgtype_from_app_id(const char* app_id); int sdb_command2(const char* cmd); +int launch_app(transport_type transport, char* serial, int argc, char** argv); void version_sdbd(transport_type ttype, char* serial); static const char *gProductOutPath = NULL; @@ -87,11 +90,11 @@ void help() " Usage : sdb [option] [parameters]\n" "\n" " options:\n" - " -d - directs command to the only connected USB device\n" - " returns an error if more than one USB device is present.\n" - " -e - directs command to the only running emulator.\n" - " returns an error if more than one emulator is running.\n" - " -s - directs command to the USB device or emulator with\n" + " -d - direct command to the only connected USB device\n" + " return an error if more than one USB device is present.\n" + " -e - direct command to the only running emulator.\n" + " return an error if more than one emulator is running.\n" + " -s - direct command to the USB device or emulator with\n" " the given serial number.\n" " devices - list all connected devices\n" " connect [:] - connect to a device via TCP/IP\n" @@ -108,8 +111,8 @@ void help() " sdb pull [] - copy file/dir from device\n" " sdb shell - run remote shell interactively\n" " sdb shell - run remote shell \n" - " sdb dlog [ ] - view device log\n" - " sdb install - push tpk package file and install it\n" + " sdb dlog [] - view device log\n" + " sdb install - push package file and install it\n" " sdb uninstall - uninstall this app from the device\n" " sdb forward - forward socket connections\n" @@ -120,11 +123,13 @@ void help() "\n" " sdb start-server - ensure that there is a server running\n" " sdb kill-server - kill the server if it is running\n" - " sdb get-state - prints: offline | bootloader | device\n" - " sdb get-serialno - prints: \n" + " sdb get-state - print: offline | bootloader | device\n" + " sdb get-serialno - print: \n" " sdb status-window - continuously print device status for a specified device\n" // " sdb usb - restarts the sdbd daemon listing on USB\n" -// " sdb tcpip - restarts the sdbd daemon listing on TCP" +// " sdb tcpip - restarts the sdbd daemon listing on TCP\n" + " sdb root - switch to root or developer account mode\n" + " 'on' means to root mode, and vice versa" "\n" ); } @@ -568,7 +573,7 @@ static int logcat(transport_type transport, char* serial, int argc, char **argv) char buf[4096]; snprintf(buf, sizeof(buf), - "shell:dlogutil"); + "shell:/usr/bin/dlogutil"); /* if (!strcmp(argv[0],"longcat")) { @@ -1101,24 +1106,24 @@ top: } } #endif - if(!strcmp(argv[0], "remount") || !strcmp(argv[0], "reboot") - || !strcmp(argv[0], "reboot-bootloader") - || !strcmp(argv[0], "tcpip") || !strcmp(argv[0], "usb") - || !strcmp(argv[0], "root")) { + if(!strcmp(argv[0], "root")) { char command[100]; - if (!strcmp(argv[0], "reboot-bootloader")) - snprintf(command, sizeof(command), "reboot:bootloader"); - else if (argc > 1) - snprintf(command, sizeof(command), "%s:%s", argv[0], argv[1]); - else - snprintf(command, sizeof(command), "%s:", argv[0]); + + if (argc != 2) { + return usage(); + } + if (strcmp(argv[1], "on") != 0 && strcmp(argv[1], "off") != 0) { + return usage(); + } + snprintf(command, sizeof(command), "%s:%s", argv[0], argv[1]); int fd = sdb_connect(command); if(fd >= 0) { read_and_dump(fd); sdb_close(fd); return 0; } - fprintf(stderr,"error: %s\n", sdb_error()); + //TODO: it may be here due to connection fail not version mis-match + fprintf(stderr, "root command requires at least version 2.1.0\n"); return 1; } @@ -1206,15 +1211,25 @@ top: } if(!strcmp(argv[0], "install")) { - if(argc != 2) return usage(); + if(argc == 2) { + return install_app_sdb(argv[1]); + } - return install_app_sdb(argv[1]); + return usage(); } if(!strcmp(argv[0], "uninstall")) { - if(argc != 2) return usage(); + if(argc == 2) { + return uninstall_app_sdb(argv[1]); + } - return uninstall_app_sdb(argv[1]); + return usage(); + } + + if(!strcmp(argv[0], "launch")) { + //if (argc < 2) return usage(); + //TODO : check argument validations + return launch_app(ttype, serial, argc, argv); } if(!strcmp(argv[0], "pull")) { @@ -1457,7 +1472,7 @@ int sdb_command2(const char* cmd) { int install_app_sdb(const char *srcpath) { D("Install start\n"); - const char * APP_DEST = "/opt/apps/PKGS/%s"; + const char * APP_DEST = "/opt/usr/apps/tmp/%s"; const char* filename = sdb_dirstop(srcpath); char destination[PATH_MAX]; @@ -1468,6 +1483,11 @@ int install_app_sdb(const char *srcpath) { snprintf(destination, sizeof destination, APP_DEST, srcpath); } + int tpk = get_pkgtype_file_name(srcpath); + if (tpk == -1) { + fprintf(stderr, "error: unknown package type\n"); + return -1; + } D("Push file: %s to %s\n", srcpath, destination); int result = do_sync_push(srcpath, destination, 0, 0); @@ -1476,9 +1496,18 @@ int install_app_sdb(const char *srcpath) { return -1; } - const char* SHELL_INSTALL_CMD ="shell:pkgcmd -i -t tpk -p %s -q"; + const char* SHELL_INSTALL_CMD ="shell:/usr/bin/pkgcmd -i -t %s -p %s -q"; char full_cmd[PATH_MAX]; - snprintf(full_cmd, sizeof full_cmd, SHELL_INSTALL_CMD, destination); + + if(tpk == 1) { + snprintf(full_cmd, sizeof full_cmd, SHELL_INSTALL_CMD, "tpk", destination); + } + else if(tpk == 0){ + snprintf(full_cmd, sizeof full_cmd, SHELL_INSTALL_CMD, "wgt", destination); + } + else { + return tpk; + } D("Install command: %s\n", full_cmd); result = sdb_command2(full_cmd); @@ -1501,10 +1530,19 @@ int install_app_sdb(const char *srcpath) { } int uninstall_app_sdb(const char *appid) { - const char* SHELL_UNINSTALL_CMD ="shell:pkgcmd -u -t tpk -n %s -q"; + const char* SHELL_UNINSTALL_CMD ="shell:/usr/bin/pkgcmd -u -t %s -n %s -q"; char full_cmd[PATH_MAX]; int result = 0; - snprintf(full_cmd, sizeof full_cmd, SHELL_UNINSTALL_CMD, appid); + int tpk = get_pkgtype_from_app_id(appid); + if(tpk == 1) { + snprintf(full_cmd, sizeof full_cmd, SHELL_UNINSTALL_CMD, "tpk", appid); + } + else if(tpk == 0){ + snprintf(full_cmd, sizeof full_cmd, SHELL_UNINSTALL_CMD, "wgt", appid); + } + else { + return tpk; + } result = sdb_command2(full_cmd); if(result < 0) { @@ -1533,6 +1571,56 @@ int uninstall_app(transport_type transport, char* serial, int argc, char** argv) return pm_command(transport, serial, argc, argv); } +// Returns 0 if pkg type is wgt. Returns 1 if pkg type is tpk. Returns minus if exception happens. +int get_pkgtype_file_name(const char* file_name) { + + char* pkg_type; + + int result = -1; + + pkg_type = strrchr(file_name, '.')+1; + if (pkg_type != NULL) { + if(!strcmp(pkg_type, "wgt")) { + result = 0; + } + else if(!strcmp(pkg_type, "tpk")) { + result = 1; + } + } + + return result; +} + +// Returns 0 if pkg type is wgt. Returns 1 if pkg type is tpk. Returns minus if exception happens. +int get_pkgtype_from_app_id(const char* app_id) { + + char* GET_PKG_TYPE_CMD = "shell:/usr/bin/pkgcmd -l | grep %s | awk '{print $2}'"; + char full_cmd[PATH_MAX]; + snprintf(full_cmd, sizeof full_cmd, GET_PKG_TYPE_CMD, app_id); + + int result = sdb_connect(full_cmd); + if(result < 0) { + return result; + } + char buf[100] = ""; + + int rl_result = read_line(result, buf, 100); + if(rl_result < 0) { + D("Error to read buffer (fd=%d)\n", rl_result); + return rl_result; + } + + sdb_close(result); + result = -1; + + if(strstr(buf, "[tpk]") != NULL) { + result = 1; + } else if(strstr(buf, "[wgt]") != NULL) { + result = 0; + } + return result; +} + static int delete_file(transport_type transport, char* serial, char* filename) { char buf[4096]; @@ -1670,6 +1758,39 @@ cleanup_apk: return err; } +int launch_app(transport_type transport, char* serial, int argc, char** argv) +{ + static const char *const SHELL_LAUNCH_CMD = "shell:/usr/bin/sdk_launch_app "; + char full_cmd[PATH_MAX]; + int i; + int result = 0; + + snprintf(full_cmd, sizeof full_cmd, "%s", SHELL_LAUNCH_CMD); + + //TODO: check argument validation + + for (i=1 ; ipid); - for (n = 1; n < proc->out_count; n++) + for (n = 1; n < proc->out_count; n++) { proc->out_fds[n-1] = proc->out_fds[n]; + } if (fcntl(proc->socket, F_SETFL, flags) == -1) { D("failed to set O_NONBLOCK flag for socket %d: %s\n", diff --git a/src/properties.c b/src/properties.c index 078afc9..886669a 100644 --- a/src/properties.c +++ b/src/properties.c @@ -155,10 +155,9 @@ int read_line(const int fd, char* ptr, const unsigned int maxlen) { unsigned int n = 0; char c[2]; - int rc; while(n != maxlen) { - if((rc = sdb_read(fd, c, 1)) != 1) + if(sdb_read(fd, c, 1) != 1) return -1; // eof or read err if(*c == '\n') { diff --git a/src/remount_service.c b/src/remount_service.c index 61d439b..21ed259 100644 --- a/src/remount_service.c +++ b/src/remount_service.c @@ -35,7 +35,6 @@ static char *find_mount(const char *dir) { int fd; int res; - int size; char *token = NULL; const char delims[] = "\n"; char buf[4096]; @@ -45,7 +44,7 @@ static char *find_mount(const char *dir) return NULL; buf[sizeof(buf) - 1] = '\0'; - size = sdb_read(fd, buf, sizeof(buf) - 1); + sdb_read(fd, buf, sizeof(buf) - 1); sdb_close(fd); token = strtok(buf, delims); diff --git a/src/sdb.h b/src/sdb.h index 4eef2af..3533da6 100755 --- a/src/sdb.h +++ b/src/sdb.h @@ -33,9 +33,9 @@ #define A_VERSION 0x01000000 // SDB protocol version #define SDB_VERSION_MAJOR 2 // Used for help/version information -#define SDB_VERSION_MINOR 0 // Used for help/version information +#define SDB_VERSION_MINOR 1 // Used for help/version information -#define SDB_SERVER_VERSION 2 // Increment this when we want to force users to start a new sdb server +#define SDB_SERVER_VERSION 0 // Increment this when we want to force users to start a new sdb server typedef struct amessage amessage; typedef struct apacket apacket; diff --git a/src/sdb_client.c b/src/sdb_client.c index 08766cd..18fd20b 100644 --- a/src/sdb_client.c +++ b/src/sdb_client.c @@ -124,6 +124,9 @@ static int switch_socket_transport(int fd) // no switch necessary return 0; break; + default: + D("unknown transport type\n"); + break; } snprintf(service, sizeof service, "host:%s", transport_type); diff --git a/src/transport_local.c b/src/transport_local.c index 8fcd04c..a87f39f 100644 --- a/src/transport_local.c +++ b/src/transport_local.c @@ -157,7 +157,6 @@ int get_devicename_from_shdmem(int port, char *device_name) D("faild to get shdmem key (%d) : %s\n", port, strerror(errno)); return -1; } - vms = strstr((char*)shared_memory, VMS_PATH); if (vms != NULL) strncpy(device_name, vms+strlen(VMS_PATH), DEVICENAME_MAX); @@ -194,6 +193,12 @@ int get_devicename_from_shdmem(int port, char *device_name) strncpy(device_name, DEFAULT_DEVICENAME, DEVICENAME_MAX); CloseHandle(hMapFile); #endif + // apply for new vms path policy from Jan 23 2013 + // vms path should be: ~/tizen-sdk-data/emulator-vms/vms/{name}/emulimg-em1.~~ + vms = strtok(device_name, OS_PATH_SEPARATOR_STR); + if (vms != NULL) { + strncpy(device_name, vms, DEVICENAME_MAX); + } D("init device name %s on port %d\n", device_name, port); return 0; @@ -203,10 +208,9 @@ int read_line(const int fd, char* ptr, size_t maxlen) { unsigned int n = 0; char c[2]; - int rc; while(n != maxlen) { - if((rc = sdb_read(fd, c, 1)) != 1) + if(sdb_read(fd, c, 1) != 1) return -1; // eof or read err if(*c == '\n') { diff --git a/src/usb_libusb.c b/src/usb_libusb.c index 8d12ea7..ab847bf 100644 --- a/src/usb_libusb.c +++ b/src/usb_libusb.c @@ -512,8 +512,9 @@ check_device(libusb_device *dev) int j = 0; r /= 2; - for (j = 1; j < r; ++j) + for (j = 1; j < r; ++j) { serial[j - 1] = buffer[j]; + } serial[j - 1] = '\0'; break; /* languagesCount cycle */ diff --git a/src/usb_linux.c b/src/usb_linux.c index 2e63183..158c686 100755 --- a/src/usb_linux.c +++ b/src/usb_linux.c @@ -599,7 +599,7 @@ static void register_device(const char *dev_name, n = ioctl(usb->desc, USBDEVFS_SETCONFIGURATION, &bConfigurationValue); if (n != 0) { D("[ usb set %d configuration failed %s fd = %d]\n", bConfigurationValue, usb->fname, usb->desc); - D("check kernel is supporting %dth configuration\n", bConfigurationValue); + D("check kernel is supporting %dth configuration\n", bConfigurationValue); } n = ioctl(usb->desc, USBDEVFS_CLAIMINTERFACE, &interface); @@ -649,12 +649,13 @@ static void register_device(const char *dev_name, result = ioctl(usb->desc, USBDEVFS_CONTROL, &ctrl); if (result > 0) { - int i; + int j; // skip first word, and copy the rest to the serial string, changing shorts to bytes. result /= 2; - for (i = 1; i < result; i++) - serial[i - 1] = __le16_to_cpu(buffer[i]); - serial[i - 1] = 0; + for (j = 1; j < result; j++) { + serial[j - 1] = __le16_to_cpu(buffer[j]); + } + serial[j - 1] = 0; break; } } diff --git a/src/usb_osx.c b/src/usb_osx.c index 5fbe1a6..683dadd 100644 --- a/src/usb_osx.c +++ b/src/usb_osx.c @@ -234,8 +234,9 @@ AndroidInterfaceAdded(void *refCon, io_iterator_t iterator) // skip first word, and copy the rest to the serial string, // changing shorts to bytes. count = (req.wLenDone - 1) / 2; - for (i = 0; i < count; i++) + for (i = 0; i < count; i++) { serial[i] = buffer[i + 1]; + } serial[i] = 0; break; } diff --git a/src/usb_vendors.c b/src/usb_vendors.c index 6364828..217aa8a 100644 --- a/src/usb_vendors.c +++ b/src/usb_vendors.c @@ -218,6 +218,7 @@ void usb_vendors_init(void) long value = strtol(temp, NULL, 0); if (errno == EINVAL || errno == ERANGE || value > INT_MAX || value < 0) { fprintf(stderr, "Invalid content in %s. Quitting.\n", ANDROID_SDB_INI); + fclose(f); exit(2); } @@ -228,6 +229,7 @@ void usb_vendors_init(void) break; } } + fclose(f); } } }