From ae6426733ecceb0543c9ba7eed9f69518af80e47 Mon Sep 17 00:00:00 2001 From: Jinhyung Choi Date: Thu, 8 Jan 2015 14:49:34 +0900 Subject: [PATCH] pkg: added extra package installation - tabspace: using 4spaces as a tab - build: removed arm build Change-Id: I28b9e93c846ce7832dad9b8987a99b5df6f11c12 Signed-off-by: Jinhyung Choi --- include/emuld.h | 41 +++++---- include/mobile.h | 4 +- include/synbuf.h | 6 +- include/wearable.h | 4 +- packaging/emuld.spec | 3 +- src/common.cpp | 239 ++++++++++++++++++++++++++++++++++++++++++++++++--- src/common_dev.cpp | 34 ++------ src/emuld.cpp | 31 +++++-- src/mobile.cpp | 34 ++++---- src/mobile_dev.cpp | 63 +++++++------- src/wearable.cpp | 36 ++++---- src/wearable_dev.cpp | 12 +-- 12 files changed, 365 insertions(+), 142 deletions(-) diff --git a/include/emuld.h b/include/emuld.h index 093738a..95c2f3d 100644 --- a/include/emuld.h +++ b/include/emuld.h @@ -32,6 +32,7 @@ #define __EMULD_H__ #include +#include #include #include @@ -39,7 +40,7 @@ #include "evdi.h" -#define FDTYPE_MAX 6 +#define FDTYPE_MAX 6 enum { @@ -56,9 +57,9 @@ enum #define HEADER_SIZE 4 // Thread TID profile uses >= 5 -#define TID_SDCARD 1 -#define TID_LOCATION 2 -#define TID_HDS 3 +#define TID_SDCARD 1 +#define TID_LOCATION 2 +#define TID_HDS 3 extern pthread_t tid[MAX_CLIENT + 1]; extern int g_fd[fdtype_max]; @@ -66,16 +67,18 @@ extern bool exit_flag; extern int g_epoll_fd; extern struct epoll_event g_events[MAX_EVENTS]; +void writelog(const char* fmt, ...); + #if defined(ENABLE_DLOG_OUT) -# define LOG_TAG "EMULATOR_DAEMON" +# define LOG_TAG "EMULD" # include # define LOGINFO LOGI # define LOGERR LOGE # define LOGDEBUG LOGD #else -# define LOGINFO(fmt, arg...) printf(fmt, arg...) -# define LOGERR(fmt, arg...) printf(fmt, arg...) -# define LOGDEBUG(fmt, arg...) printf(fmt, arg...) +# define LOGINFO(fmt, ...) { writelog(fmt, ##__VA_ARGS__); } +# define LOGERR LOGINFO +# define LOGDEBUG LOGINFO #endif typedef unsigned short CliSN; @@ -163,11 +166,10 @@ struct _auto_mutex struct setting_device_param { - setting_device_param() : get_status_sockfd(-1), ActionID(0) + setting_device_param() : ActionID(0) { memset(type_cmd, 0, ID_SIZE); } - int get_status_sockfd; unsigned char ActionID; char type_cmd[ID_SIZE]; }; @@ -177,17 +179,24 @@ int recv_data(int event_fd, char** r_databuf, int size); void recv_from_evdi(evdi_fd fd); bool accept_proc(const int server_fd); +void send_to_ecs(const char* cat, int group, int action, char* data); +void send_emuld_connection(void); void send_default_suspend_req(void); void systemcall(const char* param); int parse_val(char *buff, unsigned char data, char *parsbuf); -void msgproc_suspend(int fd, ijcommand* ijcmd); -void msgproc_system(int fd, ijcommand* ijcmd); -void msgproc_hds(int fd, ijcommand* ijcmd); -void msgproc_location(int fd, ijcommand* ijcmd); -void msgproc_sdcard(int fd, ijcommand* ijcmd); +#define IJTYPE_SUSPEND "suspend" +#define IJTYPE_GUEST "guest" +#define IJTYPE_PACKAGE "package" + +void msgproc_suspend(ijcommand* ijcmd); +void msgproc_system(ijcommand* ijcmd); +void msgproc_package(ijcommand* ijcmd); +void msgproc_hds(ijcommand* ijcmd); +void msgproc_location(ijcommand* ijcmd); +void msgproc_sdcard(ijcommand* ijcmd); void* exec_cmd_thread(void *args); -void msgproc_cmd(int fd, ijcommand* ijcmd); +void msgproc_cmd(ijcommand* ijcmd); /* * For the multi-profile diff --git a/include/mobile.h b/include/mobile.h index 2348566..47bf1a0 100644 --- a/include/mobile.h +++ b/include/mobile.h @@ -30,8 +30,8 @@ #ifndef __MOBILE_H__ #define __MOBILE_H__ -#define TID_SENSOR 5 +#define TID_SENSOR 5 -void msgproc_sensor(const int sockfd, ijcommand* ijcmd); +void msgproc_sensor(ijcommand* ijcmd); #endif diff --git a/include/synbuf.h b/include/synbuf.h index 7fd64ac..1b77a1d 100644 --- a/include/synbuf.h +++ b/include/synbuf.h @@ -50,10 +50,10 @@ public: m_readptr = m_buf; } - ~synbuf() - { + ~synbuf() + { freebuf(); - } + } void reset_buf() { diff --git a/include/wearable.h b/include/wearable.h index 9fa2d8f..401864d 100644 --- a/include/wearable.h +++ b/include/wearable.h @@ -30,7 +30,7 @@ #ifndef __WEARABLE_H__ #define __WEARABLE_H__ -#define TID_PEDOMETER 5 -void msgproc_sensor(const int sockfd, ijcommand* ijcmd); +#define TID_PEDOMETER 5 +void msgproc_sensor(ijcommand* ijcmd); #endif diff --git a/packaging/emuld.spec b/packaging/emuld.spec index b568080..2a8bd15 100644 --- a/packaging/emuld.spec +++ b/packaging/emuld.spec @@ -1,10 +1,11 @@ Name: emuld -Version: 0.8.3 +Version: 0.8.4 Release: 0 Summary: Emulator daemon License: Apache-2.0 Source0: %{name}-%{version}.tar.gz Group: SDK/Other +ExclusiveArch: %{ix86} BuildRequires: cmake BuildRequires: pkgconfig(vconf) diff --git a/src/common.cpp b/src/common.cpp index 79514ee..9ef00b5 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include "emuld.h" @@ -37,11 +38,16 @@ #define PMAPI_RETRY_COUNT 3 #define POWEROFF_DURATION 2 -#define IJTYPE_SUSPEND "suspend" - #define SUSPEND_UNLOCK 0 #define SUSPEND_LOCK 1 +#define MAX_PKGS_BUF 1024 + +#define PATH_PACKAGE_INSTALL "/opt/usr/apps/tmp/sdk_tools/" +#define RPM_CMD_QUERY "-q" +#define RPM_CMD_INSTALL "-U" +static pthread_mutex_t mutex_pkg = PTHREAD_MUTEX_INITIALIZER; + static struct timeval tv_start_poweroff; void systemcall(const char* param) @@ -95,7 +101,7 @@ void powerdown_by_force(void) reboot(RB_POWER_OFF); } -void msgproc_system(const int sockfd, ijcommand* ijcmd) +void msgproc_system(ijcommand* ijcmd) { LOGDEBUG("msgproc_system"); @@ -111,7 +117,7 @@ void msgproc_system(const int sockfd, ijcommand* ijcmd) } static void set_lock_state(int state) { -#if 0 // public does not support dd-display, yet. ERIC 12.20.2014 +#if 0 int i = 0; int ret = 0; // Now we blocking to enter "SLEEP". @@ -131,7 +137,7 @@ static void set_lock_state(int state) { #endif } -void msgproc_suspend(int fd, ijcommand* ijcmd) +void msgproc_suspend(ijcommand* ijcmd) { if (ijcmd->msg.action == SUSPEND_LOCK) { set_lock_state(SUSPEND_LOCK); @@ -142,22 +148,229 @@ void msgproc_suspend(int fd, ijcommand* ijcmd) LOGINFO("[Suspend] Set lock state as %d (1: lock, other: unlock)", ijcmd->msg.action); } -void send_default_suspend_req(void) +void send_to_ecs(const char* cat, int group, int action, char* data) { - int group = 5; - int action = 15; - char* tmp = (char*) malloc(HEADER_SIZE); + int datalen = 0; + int tmplen = HEADER_SIZE; + if (data != NULL) { + datalen = strlen(data); + tmplen += datalen; + } + + char* tmp = (char*) malloc(tmplen); if (!tmp) return; - memset(tmp, 0, HEADER_SIZE); - memcpy(tmp + 2, &group, 1); - memcpy(tmp + 3, &action , 1); + if (data != NULL) { + memcpy(tmp, &datalen, 2); + } + memcpy(tmp + 2, &group, 1); + memcpy(tmp + 3, &action, 1); + if (data != NULL) { + memcpy(tmp + 4, data, datalen); + } - ijmsg_send_to_evdi(g_fd[fdtype_device], IJTYPE_SUSPEND, (const char*) tmp, HEADER_SIZE); + ijmsg_send_to_evdi(g_fd[fdtype_device], cat, (const char*) tmp, tmplen); if (tmp) free(tmp); } +void send_emuld_connection(void) +{ + send_to_ecs(IJTYPE_GUEST, 0, 1, NULL); +} + +void send_default_suspend_req(void) +{ + send_to_ecs(IJTYPE_SUSPEND, 5, 15, NULL); +} + +static bool do_validate(char* pkgs) +{ + char buf[MAX_PKGS_BUF]; + + FILE* fp = popen(pkgs, "r"); + if (fp == NULL) { + LOGERR("Failed to popen %s", pkgs); + return false; + } + + memset(buf, 0, sizeof(buf)); + while(fgets(buf, sizeof(buf), fp)) { + LOGINFO("[rpm]%s", buf); + if (!strncmp(buf, IJTYPE_PACKAGE, 7)) { + pclose(fp); + return false; + } + memset(buf, 0, sizeof(buf)); + } + + pclose(fp); + return true; +} + +static bool do_install(char* pkgs) +{ + char buf[MAX_PKGS_BUF]; + bool ret = true; + + FILE* fp = popen(pkgs, "r"); + if (fp == NULL) { + LOGERR("Failed to popen %s", pkgs); + return false; + } + + memset(buf, 0, sizeof(buf)); + while(fgets(buf, sizeof(buf), fp)) { + LOGINFO("[rpm] %s", buf); + + if (!strncmp(buf, "error", 5)) { + ret = false; + } + memset(buf, 0, sizeof(buf)); + } + + pclose(fp); + + return ret; +} + +static void remove_package(char* data) +{ + char token[] = ", "; + char pkg_list[MAX_PKGS_BUF]; + char *addon = NULL; + char *copy = strdup(data); + if (copy == NULL) { + LOGERR("Failed to copy data."); + return; + } + + memset(pkg_list, 0, sizeof(pkg_list)); + + strcpy(pkg_list, "rm -rf "); + + strcat(pkg_list, PATH_PACKAGE_INSTALL); + addon = strtok(copy, token); + strcat(pkg_list, addon); + + LOGINFO("remove packages: %s", pkg_list); + + systemcall(pkg_list); + + free(copy); +} + +static bool do_package(int action, char* data) +{ + char token[] = ", "; + char *pkg = NULL; + char *addon = NULL; + char pkg_list[MAX_PKGS_BUF]; + + memset(pkg_list, 0, sizeof(pkg_list)); + + strcpy(pkg_list, "rpm"); + + if (action == 1) { + strcat(pkg_list, " "); + strcat(pkg_list, RPM_CMD_QUERY); + } else if (action == 2) { + strcat(pkg_list, " "); + strcat(pkg_list, RPM_CMD_INSTALL); + } else { + LOGERR("Unknown action."); + return false; + } + addon = strtok(data, token); // for addon path + + pkg = strtok(NULL, token); + while (pkg != NULL) { + if (action == 1) { + pkg[strlen(pkg) - 4] = 0; //remove .rpm + } + strcat(pkg_list, " "); + if (action == 2) { + strcat(pkg_list, PATH_PACKAGE_INSTALL); + strcat(pkg_list, addon); + strcat(pkg_list, "/"); + } + strcat(pkg_list, pkg); + + pkg = strtok(NULL, token); + } + + strcat(pkg_list, " "); + strcat(pkg_list, "2>&1"); + + LOGINFO("[cmd]%s", pkg_list); + if (action == 1 && do_validate(pkg_list)) { + return true; + } else if (action == 2 && do_install(pkg_list)) { + return true; + } + + return false; +} + +static void* package_thread(void* args) +{ + LOGINFO("install package_thread starts."); + int action = 0; + ijcommand* ijcmd = (ijcommand*)args; + char* data = strdup(ijcmd->data); + if (data == NULL) { + LOGERR("install data is failed to copied."); + return NULL; + } + + if (ijcmd->msg.action == 1) { // validate packages + if (do_package(1, data)) { + action = 1; // already installed + } else { + action = 2; // need to install + } + } else if (ijcmd->msg.action == 2) { // install packages + if (do_package(2, data)) { + action = 3; // install success + } else { + action = 4; // failed to install + } + remove_package(ijcmd->data); + } else { + LOGERR("invalid command (action:%d)", ijcmd->msg.action); + } + + LOGINFO("send %d, with %s", action, ijcmd->data); + send_to_ecs(IJTYPE_PACKAGE, 0, action, ijcmd->data); + + free(data); + + return NULL; +} + +void msgproc_package(ijcommand* ijcmd) +{ + _auto_mutex _(&mutex_pkg); + int ret = 0; + void* retval = NULL; + pthread_t pkg_thread_id; + + if (!ijcmd->data) { + LOGERR("package data is empty."); + return; + } + + LOGINFO("received %d, with %s", ijcmd->msg.action, ijcmd->data); + + if (pthread_create(&pkg_thread_id, NULL, package_thread, (void*)ijcmd) != 0) + { + LOGERR("validate package pthread creation is failed!"); + } + ret = pthread_join(pkg_thread_id, &retval); + if (ret < 0) { + LOGERR("validate package pthread join is failed."); + } +} diff --git a/src/common_dev.cpp b/src/common_dev.cpp index 979f247..dde5cf3 100644 --- a/src/common_dev.cpp +++ b/src/common_dev.cpp @@ -65,13 +65,7 @@ char command[512]; * SD Card functions */ -struct mount_param -{ - mount_param(int _fd) : fd(_fd) {} - int fd; -}; - -char* get_mount_info() { +static char* get_mount_info() { struct mntent *ent; FILE *aFile; @@ -125,8 +119,6 @@ int is_mounted() void* mount_sdcard(void* data) { - mount_param* param = (mount_param*) data; - int ret = -1, i = 0; struct stat buf; char file_name[128], command[256]; @@ -202,15 +194,10 @@ void* mount_sdcard(void* data) packet = NULL; } - if (param) - { - delete param; - param = NULL; - } pthread_exit((void *) 0); } -int umount_sdcard(const int fd) +static int umount_sdcard(void) { int ret = -1, i = 0; char file_name[128]; @@ -269,7 +256,7 @@ int umount_sdcard(const int fd) } -void msgproc_sdcard(const int sockfd, ijcommand* ijcmd) +void msgproc_sdcard(ijcommand* ijcmd) { LOGDEBUG("msgproc_sdcard"); @@ -291,7 +278,7 @@ void msgproc_sdcard(const int sockfd, ijcommand* ijcmd) { case 0: // umount { - mount_status = umount_sdcard(sockfd); + mount_status = umount_sdcard(); } break; case 1: // mount @@ -301,11 +288,7 @@ void msgproc_sdcard(const int sockfd, ijcommand* ijcmd) strncpy(SDpath, ret, strlen(ret)); LOGDEBUG("sdcard path is %s", SDpath); - mount_param* param = new mount_param(sockfd); - if (!param) - break; - - if (pthread_create(&tid[TID_SDCARD], NULL, mount_sdcard, (void*) param) != 0) + if (pthread_create(&tid[TID_SDCARD], NULL, mount_sdcard, NULL) != 0) LOGERR("mount sdcard pthread create fail!"); } @@ -414,7 +397,7 @@ void* exec_cmd_thread(void *args) pthread_exit(NULL); } -void msgproc_cmd(int fd, ijcommand* ijcmd) +void msgproc_cmd(ijcommand* ijcmd) { _auto_mutex _(&mutex_cmd); pthread_t cmd_thread_id; @@ -649,7 +632,7 @@ void setting_location(char* databuf) } } -void msgproc_location(const int sockfd, ijcommand* ijcmd) +void msgproc_location(ijcommand* ijcmd) { LOGDEBUG("msgproc_location"); if (ijcmd->msg.group == STATUS) @@ -658,7 +641,6 @@ void msgproc_location(const int sockfd, ijcommand* ijcmd) if (!param) return; - param->get_status_sockfd = sockfd; param->ActionID = ijcmd->msg.action; memcpy(param->type_cmd, ijcmd->cmd, ID_SIZE); @@ -769,7 +751,7 @@ int umount_hds(void) return 0; } -void msgproc_hds(const int sockfd, ijcommand* ijcmd) +void msgproc_hds(ijcommand* ijcmd) { LOGDEBUG("msgproc_hds"); diff --git a/src/emuld.cpp b/src/emuld.cpp index aba365e..ba059af 100644 --- a/src/emuld.cpp +++ b/src/emuld.cpp @@ -29,6 +29,8 @@ #include #include +#include +#include #include #include @@ -139,10 +141,10 @@ static int read_header(int fd, LXT_MESSAGE* packet) char* readbuf = NULL; int readed = recv_data(fd, &readbuf, HEADER_SIZE); if (readed <= 0){ - if (readbuf) - free(readbuf); + if (readbuf) + free(readbuf); return 0; - } + } memcpy((void*) packet, (void*) readbuf, HEADER_SIZE); if (readbuf) @@ -195,7 +197,7 @@ void recv_from_evdi(evdi_fd fd) { LOGDEBUG("recv_from_evdi"); int readed; - synbuf g_synbuf; + synbuf g_synbuf; struct msg_info _msg; int to_read = sizeof(struct msg_info); @@ -220,7 +222,7 @@ void recv_from_evdi(evdi_fd fd) } } - LOGINFO("total readed = %d, read count = %d, index = %d, use = %d, msg = %s", + LOGDEBUG("total readed = %d, read count = %d, index = %d, use = %d, msg = %s", readed, _msg.count, _msg.index, _msg.use, _msg.buf); g_synbuf.reset_buf(); @@ -241,7 +243,7 @@ void recv_from_evdi(evdi_fd fd) return; LOGDEBUG("HEADER : action = %d, group = %d, length = %d", - ijcmd.msg.action, ijcmd.msg.group, ijcmd.msg.length); + ijcmd.msg.action, ijcmd.msg.group, ijcmd.msg.length); if (ijcmd.msg.length > 0) { @@ -264,6 +266,17 @@ void recv_from_evdi(evdi_fd fd) process_evdi_command(&ijcmd); } +void writelog(const char* fmt, ...) +{ + FILE* logfile = fopen("/tmp/emuld.log", "a+"); + va_list args; + va_start(args, fmt); + vfprintf(logfile, fmt, args); + vfprintf(logfile, "\n", NULL); + va_end(args); + fclose(logfile); +} + int main( int argc , char *argv[]) { init_fd(); @@ -281,7 +294,9 @@ int main( int argc , char *argv[]) LOGINFO("[START] epoll & device init success"); - init_profile(); + init_profile(); + + send_emuld_connection(); send_default_suspend_req(); @@ -290,7 +305,7 @@ int main( int argc , char *argv[]) exit_flag = server_process(); } - exit_profile(); + exit_profile(); stop_listen(); diff --git a/src/mobile.cpp b/src/mobile.cpp index 620c5cd..d05b5a8 100644 --- a/src/mobile.cpp +++ b/src/mobile.cpp @@ -38,35 +38,37 @@ void process_evdi_command(ijcommand* ijcmd) { - int fd = -1; - if (strncmp(ijcmd->cmd, "sensor", 6) == 0) { - msgproc_sensor(fd, ijcmd); + msgproc_sensor(ijcmd); + } + else if (strcmp(ijcmd->cmd, IJTYPE_SUSPEND) == 0) + { + msgproc_suspend(ijcmd); } - else if (strncmp(ijcmd->cmd, "suspend", 7) == 0) + else if (strcmp(ijcmd->cmd, "location") == 0) { - msgproc_suspend(fd, ijcmd); + msgproc_location(ijcmd); } - else if (strncmp(ijcmd->cmd, "location", 8) == 0) + else if (strcmp(ijcmd->cmd, "hds") == 0) { - msgproc_location(fd, ijcmd); + msgproc_hds(ijcmd); } - else if (strncmp(ijcmd->cmd, "hds", 3) == 0) + else if (strcmp(ijcmd->cmd, "system") == 0) { - msgproc_hds(fd, ijcmd); + msgproc_system(ijcmd); } - else if (strncmp(ijcmd->cmd, "system", 6) == 0) + else if (strcmp(ijcmd->cmd, IJTYPE_PACKAGE) == 0) { - msgproc_system(fd, ijcmd); + msgproc_package(ijcmd); } - else if (strncmp(ijcmd->cmd, "sdcard", 6) == 0) + else if (strcmp(ijcmd->cmd, "sdcard") == 0) { - msgproc_sdcard(fd, ijcmd); + msgproc_sdcard(ijcmd); } - else if (strncmp(ijcmd->cmd, "cmd", 3) == 0) + else if (strcmp(ijcmd->cmd, "cmd") == 0) { - msgproc_cmd(fd, ijcmd); + msgproc_cmd(ijcmd); } else { @@ -96,7 +98,7 @@ bool server_process(void) } else { - LOGERR("unknown request event fd : (%d)", fd_tmp); + LOGERR("unknown request event fd : (%d)", fd_tmp); } } diff --git a/src/mobile_dev.cpp b/src/mobile_dev.cpp index 1bef0fa..cfc700c 100644 --- a/src/mobile_dev.cpp +++ b/src/mobile_dev.cpp @@ -120,11 +120,11 @@ static void dbus_send_power_supply(int capacity, int charger) memset(option, 0, 128); if (capacity == 100 && charger == 1) { - memcpy(state, FULL, 4); + memcpy(state, FULL, 4); } else if (charger == 1) { - memcpy(state, CHARGING, 8); + memcpy(state, CHARGING, 8); } else { - memcpy(state, DISCHARGING, 11); + memcpy(state, DISCHARGING, 11); } sprintf(option, "int32:5 string:\"%d\" string:\"%s\" string:\"Good\" string:\"%d\" string:\"1\"", @@ -148,7 +148,7 @@ static void dbus_send_usb(int on) static void dbus_send_earjack(int on) { - const char* earjack_device = DEVICE_CHANGED; + const char* earjack_device = DEVICE_CHANGED; char option [128]; memset(option, 0, 128); @@ -337,9 +337,9 @@ int parse_earjack_data(int len, char *buffer) fclose(fd); // because time based polling - //FIXME: change to dbus + //FIXME: change to dbus //system_cmd("/usr/bin/sys_event device_earjack_chgdet"); - dbus_send_earjack(x); + dbus_send_earjack(x); return 0; } @@ -509,30 +509,30 @@ static void* getting_sensor(void* data) break; } - if (msg == 0) - { - LOGDEBUG("send error message to injector"); - memset(packet, 0, sizeof(LXT_MESSAGE)); - packet->length = 0; - packet->group = STATUS; - packet->action = param->ActionID; - } - else - { - LOGDEBUG("send data to injector"); - } - - const int tmplen = HEADER_SIZE + packet->length; - char* tmp = (char*) malloc(tmplen); - if (tmp) - { - memcpy(tmp, packet, HEADER_SIZE); - if (packet->length > 0) - memcpy(tmp + HEADER_SIZE, msg, packet->length); - - ijmsg_send_to_evdi(g_fd[fdtype_device], param->type_cmd, (const char*) tmp, tmplen); - - free(tmp); + if (msg == 0) + { + LOGDEBUG("send error message to injector"); + memset(packet, 0, sizeof(LXT_MESSAGE)); + packet->length = 0; + packet->group = STATUS; + packet->action = param->ActionID; + } + else + { + LOGDEBUG("send data to injector"); + } + + const int tmplen = HEADER_SIZE + packet->length; + char* tmp = (char*) malloc(tmplen); + if (tmp) + { + memcpy(tmp, packet, HEADER_SIZE); + if (packet->length > 0) + memcpy(tmp + HEADER_SIZE, msg, packet->length); + + ijmsg_send_to_evdi(g_fd[fdtype_device], param->type_cmd, (const char*) tmp, tmplen); + + free(tmp); } if(msg != 0) @@ -549,7 +549,7 @@ static void* getting_sensor(void* data) pthread_exit((void *) 0); } -void msgproc_sensor(const int sockfd, ijcommand* ijcmd) +void msgproc_sensor(ijcommand* ijcmd) { LOGDEBUG("msgproc_sensor"); @@ -561,7 +561,6 @@ void msgproc_sensor(const int sockfd, ijcommand* ijcmd) memset(param, 0, sizeof(*param)); - param->get_status_sockfd = sockfd; param->ActionID = ijcmd->msg.action; memcpy(param->type_cmd, ijcmd->cmd, ID_SIZE); diff --git a/src/wearable.cpp b/src/wearable.cpp index 312ddc8..9836aac 100644 --- a/src/wearable.cpp +++ b/src/wearable.cpp @@ -35,35 +35,37 @@ void process_evdi_command(ijcommand* ijcmd) { - int fd = -1; - - if (strncmp(ijcmd->cmd, "suspend", 7) == 0) + if (strcmp(ijcmd->cmd, "suspend") == 0) + { + msgproc_suspend(ijcmd); + } + else if (strcmp(ijcmd->cmd, "sensor") == 0) { - msgproc_suspend(fd, ijcmd); + msgproc_sensor(ijcmd); } - else if (strncmp(ijcmd->cmd, "sensor", 6) == 0) + else if (strcmp(ijcmd->cmd, "location") == 0) { - msgproc_sensor(fd, ijcmd); + msgproc_location(ijcmd); } - else if (strncmp(ijcmd->cmd, "location", 8) == 0) + else if (strcmp(ijcmd->cmd, "hds") == 0) { - msgproc_location(fd, ijcmd); + msgproc_hds(ijcmd); } - else if (strncmp(ijcmd->cmd, "hds", 3) == 0) + else if (strcmp(ijcmd->cmd, "system") == 0) { - msgproc_hds(fd, ijcmd); + msgproc_system(ijcmd); } - else if (strncmp(ijcmd->cmd, "system", 6) == 0) + else if (strcmp(ijcmd->cmd, IJTYPE_PACKAGE) == 0) { - msgproc_system(fd, ijcmd); + msgproc_package(ijcmd); } - else if (strncmp(ijcmd->cmd, "sdcard", 6) == 0) + else if (strcmp(ijcmd->cmd, "sdcard") == 0) { - msgproc_sdcard(fd, ijcmd); + msgproc_sdcard(ijcmd); } - else if (strncmp(ijcmd->cmd, "cmd", 3) == 0) + else if (strcmp(ijcmd->cmd, "cmd") == 0) { - msgproc_cmd(fd, ijcmd); + msgproc_cmd(ijcmd); } else { @@ -93,7 +95,7 @@ bool server_process(void) } else { - LOGERR("unknown request event fd : (%d)", fd_tmp); + LOGERR("unknown request event fd : (%d)", fd_tmp); } } diff --git a/src/wearable_dev.cpp b/src/wearable_dev.cpp index 5816e37..454f6b1 100644 --- a/src/wearable_dev.cpp +++ b/src/wearable_dev.cpp @@ -75,11 +75,11 @@ static void dbus_send_power_supply(int capacity, int charger) memset(option, 0, 128); if (capacity == 100 && charger == 1) { - memcpy(state, FULL, 4); + memcpy(state, FULL, 4); } else if (charger == 1) { - memcpy(state, CHARGING, 8); + memcpy(state, CHARGING, 8); } else { - memcpy(state, DISCHARGING, 11); + memcpy(state, DISCHARGING, 11); } sprintf(option, "int32:5 string:\"%d\" string:\"%s\" string:\"Good\" string:\"%d\" string:\"1\"", @@ -102,7 +102,7 @@ static void dbus_send_usb(int on) static void dbus_send_earjack(int on) { - const char* earjack_device = DEVICE_CHANGED; + const char* earjack_device = DEVICE_CHANGED; char option [128]; memset(option, 0, 128); @@ -202,7 +202,7 @@ int parse_earjack_data(int len, char *buffer) fprintf(fd, "%d", x); fclose(fd); - dbus_send_earjack(x); + dbus_send_earjack(x); return 0; } @@ -267,7 +267,7 @@ static void device_parser(char *buffer) } } -void msgproc_sensor(const int sockfd, ijcommand* ijcmd) +void msgproc_sensor(ijcommand* ijcmd) { LOGDEBUG("msgproc_sensor"); -- 2.7.4