diff options
author | Munkyu Im <munkyu.im@samsung.com> | 2017-08-28 13:54:06 +0900 |
---|---|---|
committer | SeokYeon Hwang <syeon.hwang@samsung.com> | 2017-09-05 10:31:33 +0000 |
commit | 067a261fd9cd359178959e3941b6fe1b3b19491b (patch) | |
tree | 30a7d98d4da7a2cb80583385aae0a32b4fc067cb | |
parent | 621ca99238c0feef5501b2c1d1cd105cc5f56a65 (diff) | |
download | qemu-067a261fd9cd359178959e3941b6fe1b3b19491b.tar.gz qemu-067a261fd9cd359178959e3941b6fe1b3b19491b.tar.bz2 qemu-067a261fd9cd359178959e3941b6fe1b3b19491b.zip |
net: add checking device state before run command
If device state is "device", run sdb command.
Change-Id: I8ee09a24e07514613f899ec012eac2dea376846c
Signed-off-by: Munkyu Im <munkyu.im@samsung.com>
-rw-r--r-- | tizen/src/util/net_helper.c | 60 |
1 files changed, 51 insertions, 9 deletions
diff --git a/tizen/src/util/net_helper.c b/tizen/src/util/net_helper.c index c6298d8df9..b97acbf82a 100644 --- a/tizen/src/util/net_helper.c +++ b/tizen/src/util/net_helper.c @@ -389,6 +389,43 @@ static void suspend_lock_state(int state) ecs_suspend_lock_state(state); } +static bool is_ready(void) +{ + FILE *fp; + char state_name[BUF_SIZE] = { 0, }; +#ifndef CONFIG_WIN32 + const char *sdb_path = "../../../../../tools/sdb"; + const char *bin_dir = get_bin_path(); + char *cmd_get_state = g_strdup_printf("\"%s%s\" -s emulator-%d get-state 2> /dev/null", + bin_dir, sdb_path, get_vm_device_serial_number()); +#else + const char *sdb_path = "..\\..\\..\\..\\..\\tools\\sdb.exe"; + const char *bin_dir = get_bin_path(); + char *cmd_get_state = g_strdup_printf("\"%s%s\" -s emulator-%d get-state 2> NUL", + bin_dir, sdb_path, get_vm_device_serial_number()); +#endif + fp = popen(cmd_get_state, "r"); + if (fp == NULL) { + LOG_WARNING("Failed to run command\n"); + g_free(cmd_get_state); + return false; + } + + if (fgets(state_name, sizeof(state_name), fp)) { + g_strstrip(state_name); + if (strncmp(state_name, "device", 6) == 0) { + g_free(cmd_get_state); + pclose(fp); + LOG_INFO("device is ready to get command"); + return true; + } + } + + g_free(cmd_get_state); + pclose(fp); + return false; +} + static void *get_user_home_path(void *args) { FILE *fp; @@ -418,15 +455,6 @@ static void *get_user_home_path(void *args) char *cmd_get_home = g_strdup_printf("\"%s%s\" -s emulator-%d shell id -un 2> NUL", bin_dir, sdb_path, get_vm_device_serial_number()); #endif - //FIXME: (sdb) cannot check sdb root status - fp = popen(cmd_root_off, "r"); - if (fp == NULL) { - LOG_WARNING("Failed to run command\n"); - g_free(cmd_root_off); - return NULL; - } - g_free(cmd_root_off); - pclose(fp); while (true) { if (trial >= MAX_TRIAL) { sleep_time = 2000; @@ -438,6 +466,20 @@ static void *get_user_home_path(void *args) #else usleep(sleep_time * 1000); #endif + if (!is_ready()) { + continue; + } + + //FIXME: (sdb) cannot check sdb root status + fp = popen(cmd_root_off, "r"); + if (fp == NULL) { + LOG_WARNING("Failed to run command\n"); + g_free(cmd_root_off); + break; + } + g_free(cmd_root_off); + pclose(fp); + fp = popen(cmd_get_home, "r"); if (fp == NULL) { LOG_WARNING("Failed to run command\n"); |