From: Jinhyung Choi Date: Wed, 6 Jan 2016 04:55:10 +0000 (+0900) Subject: ecs: reduce header definition for ecs.h X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~104 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=762b3604679b25133bf32d03cdd4da7f68911e69;p=sdk%2Femulator%2Fqemu.git ecs: reduce header definition for ecs.h - clean-up and re-arrange the definitions and inclusion - remove unused function definition Change-Id: Ic54e9d81da2e91f6e534c45f9c7064a53d7e54cc Signed-off-by: Jinhyung Choi --- diff --git a/tizen/src/ecs/ecs.c b/tizen/src/ecs/ecs.c index 663d7f89ed..32ddd68d8b 100644 --- a/tizen/src/ecs/ecs.c +++ b/tizen/src/ecs/ecs.c @@ -4,7 +4,7 @@ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: - * Jinhyung choi + * Jinhyung Choi * MunKyu Im * Daiyoung Kim * YeongKyoon Lee @@ -50,8 +50,6 @@ #include "ecs.h" #include "emul_state.h" -#include "genmsg/ecs.pb-c.h" - #include "debug_ch.h" MULTI_DEBUG_CHANNEL(qemu, ecs); @@ -278,6 +276,83 @@ static void reset_sbuf(sbuf* sbuf) sbuf->_netlen = 0; } +static bool handle_protobuf_msg(ECS_Client* cli, char* data, int len) +{ + ECS__Master* master = ecs__master__unpack(NULL, (size_t)len, (const uint8_t*)data); + if (!master) + return false; + + if (master->type == ECS__MASTER__TYPE__INJECTOR_REQ) { + ECS__InjectorReq* msg = master->injector_req; + if (!msg) + goto fail; + msgproc_injector_req(cli, msg); + } else if (master->type == ECS__MASTER__TYPE__MONITOR_REQ) { + ECS__MonitorReq* msg = master->monitor_req; + if (!msg) + goto fail; + msgproc_monitor_req(cli, msg); + } else if (master->type == ECS__MASTER__TYPE__DEVICE_REQ) { + cli->client_type = TYPE_ECP; + ECS__DeviceReq* msg = master->device_req; + if (!msg) + goto fail; + msgproc_device_req(cli, msg); + } else if (master->type == ECS__MASTER__TYPE__NFC_REQ) { + ECS__NfcReq* msg = master->nfc_req; + if (!msg) + goto fail; + + qemu_mutex_lock(&mutex_clilist); + if(cli->client_type == TYPE_NONE) { + if (!strncmp(msg->category, MSG_TYPE_NFC, 3)) { + QTAILQ_REMOVE(&clients, cli, next); + cli->client_type = TYPE_ECP; + if(g_client_id > 255) { + g_client_id = 1; + } + cli->client_id = g_client_id++; + + QTAILQ_INSERT_TAIL(&clients, cli, next); + } else if (!strncmp(msg->category, MSG_TYPE_SIMUL_NFC, 9)) { + QTAILQ_REMOVE(&clients, cli, next); + cli->client_type = TYPE_SIMUL_NFC; + if(g_client_id > 255) { + g_client_id = 1; + } + cli->client_id = g_client_id++; + QTAILQ_INSERT_TAIL(&clients, cli, next); + } else { + LOG_SEVERE("unsupported category is found: %s\n", msg->category); + qemu_mutex_unlock(&mutex_clilist); + goto fail; + } + } + qemu_mutex_unlock(&mutex_clilist); + + msgproc_nfc_req(cli, msg); + } else if (master->type == ECS__MASTER__TYPE__KEEPALIVE_ANS) { + ECS__KeepAliveAns* msg = master->keepalive_ans; + if (!msg) + goto fail; + msgproc_keepalive_ans(cli, msg); + } else if (master->type == ECS__MASTER__TYPE__EVENTCAST_REQ) { + ECS__EventCastReq* msg = master->eventcast_req; + if (!msg) + goto fail; + msgproc_eventcast_req(cli, msg); + } else { + goto fail; + } + + ecs__master__free_unpacked(master, NULL); + return true; +fail: + LOG_SEVERE("invalid message type : %d\n", master->type); + ecs__master__free_unpacked(master, NULL); + return false; +} + static void ecs_read(ECS_Client *cli) { int read = 0; @@ -743,99 +818,3 @@ int start_ecs(void) { return 0; } -bool handle_protobuf_msg(ECS_Client* cli, char* data, int len) -{ - ECS__Master* master = ecs__master__unpack(NULL, (size_t)len, (const uint8_t*)data); - if (!master) - return false; - - if (master->type == ECS__MASTER__TYPE__INJECTOR_REQ) - { - ECS__InjectorReq* msg = master->injector_req; - if (!msg) - goto fail; - msgproc_injector_req(cli, msg); - } - else if (master->type == ECS__MASTER__TYPE__MONITOR_REQ) - { - ECS__MonitorReq* msg = master->monitor_req; - if (!msg) - goto fail; - msgproc_monitor_req(cli, msg); - } - else if (master->type == ECS__MASTER__TYPE__DEVICE_REQ) - { - cli->client_type = TYPE_ECP; - ECS__DeviceReq* msg = master->device_req; - if (!msg) - goto fail; - msgproc_device_req(cli, msg); - } - else if (master->type == ECS__MASTER__TYPE__NFC_REQ) - { - ECS__NfcReq* msg = master->nfc_req; - if (!msg) - goto fail; - - qemu_mutex_lock(&mutex_clilist); - if(cli->client_type == TYPE_NONE) { - if (!strncmp(msg->category, MSG_TYPE_NFC, 3)) { - QTAILQ_REMOVE(&clients, cli, next); - cli->client_type = TYPE_ECP; - if(g_client_id > 255) { - g_client_id = 1; - } - cli->client_id = g_client_id++; - - QTAILQ_INSERT_TAIL(&clients, cli, next); - } - else if (!strncmp(msg->category, MSG_TYPE_SIMUL_NFC, 9)) { - QTAILQ_REMOVE(&clients, cli, next); - cli->client_type = TYPE_SIMUL_NFC; - if(g_client_id > 255) { - g_client_id = 1; - } - cli->client_id = g_client_id++; - QTAILQ_INSERT_TAIL(&clients, cli, next); - } - else { - LOG_SEVERE("unsupported category is found: %s\n", msg->category); - qemu_mutex_unlock(&mutex_clilist); - goto fail; - } - } - qemu_mutex_unlock(&mutex_clilist); - - msgproc_nfc_req(cli, msg); - } -#if 0 - else if (master->type == ECS__MASTER__TYPE__CHECKVERSION_REQ) - { - ECS__CheckVersionReq* msg = master->checkversion_req; - if (!msg) - goto fail; - msgproc_checkversion_req(cli, msg); - } -#endif - else if (master->type == ECS__MASTER__TYPE__KEEPALIVE_ANS) - { - ECS__KeepAliveAns* msg = master->keepalive_ans; - if (!msg) - goto fail; - msgproc_keepalive_ans(cli, msg); - } - else if (master->type == ECS__MASTER__TYPE__EVENTCAST_REQ) - { - ECS__EventCastReq* msg = master->eventcast_req; - if (!msg) - goto fail; - msgproc_eventcast_req(cli, msg); - } - - ecs__master__free_unpacked(master, NULL); - return true; -fail: - LOG_SEVERE("invalid message type : %d\n", master->type); - ecs__master__free_unpacked(master, NULL); - return false; -} diff --git a/tizen/src/ecs/ecs.h b/tizen/src/ecs/ecs.h index fbfdae4864..19e43d4046 100644 --- a/tizen/src/ecs/ecs.h +++ b/tizen/src/ecs/ecs.h @@ -4,7 +4,7 @@ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: - * Jinhyung choi + * Jinhyung Choi * MunKyu Im * Daiyoung Kim * YeongKyoon Lee @@ -31,15 +31,7 @@ #ifndef __ECS_H__ #define __ECS_H__ -#ifdef CONFIG_LINUX -#include -#endif - -#include "qapi/qmp/qerror.h" -#include "qemu-common.h" -#include "ecs-json-streamer.h" -#include "genmsg/ecs.pb-c.h" -#include "genmsg/ecs_ids.pb-c.h" +#include "ecs_internal.h" #define HOST_LISTEN_ADDR "127.0.0.1" @@ -50,7 +42,6 @@ #define COMMAND_TYPE_CONTROL "control" #define COMMAND_TYPE_MONITOR "monitor" #define COMMAND_TYPE_DEVICE "device" - #define COMMAND_TYPE_TETHERING "eventcast" #define MSG_TYPE_SENSOR "sensor" @@ -66,102 +57,6 @@ #define MSG_GROUP_STATUS 15 -enum message_action { - MSG_ACT_BATTERY_LEVEL = 100, - MSG_ACT_BATTERY_CHARGER = 101, - MSG_ACT_USB = 102, - MSG_ACT_EARJACK = 103, - MSG_ACT_RSSI = 104, - MSG_ACT_ACCEL = 110, - MSG_ACT_GYRO = 111, - MSG_ACT_MAG = 112, - MSG_ACT_LIGHT = 113, - MSG_ACT_PROXI = 114, - MSG_ACT_MOTION = 115, - MSG_ACT_PRESSURE = 116, - MSG_ACT_UV = 117, - MSG_ACT_HRM = 118, - MSG_ACT_LOCATION = 120, - MSG_ACT_NETBRIDGE = 123 -}; - -#define TIMER_ALIVE_S 60 -#define TYPE_DATA_SELF "self" - -enum injector_level { - level_accel = 1, - level_proxi = 2, - level_light = 3, - level_gyro = 4, - level_geo = 5, - level_battery = 8, - level_tilt = 12, - level_magnetic = 13, - level_pressure = 20, - level_uv = 21, - level_hrm = 22, -}; - -#define MAX_CATEGORY_LEN 10 -typedef unsigned short type_length; -typedef unsigned char type_group; -typedef unsigned char type_action; - -#define OUT_BUF_SIZE 4096 -#define READ_BUF_LEN 4096 -#define MAX_ID_SIZE 255 -#define MAX_INJECTOR_REQ_DATA 128 -typedef struct sbuf -{ - int _netlen; - int _use; - char _buf[OUT_BUF_SIZE]; -}sbuf; - -struct Monitor { - int suspend_cnt; - uint8_t outbuf[OUT_BUF_SIZE]; - int outbuf_index; - void *password_opaque; - Error *error; - QLIST_HEAD(,mon_fd_t) fds; - QLIST_ENTRY(Monitor) entry; -}; - -#define MAX_EVENTS 1000 -#define MAX_FD_NUM 300 -typedef struct ECS_State { - int listen_fd; -#ifdef CONFIG_LINUX - int epoll_fd; - struct epoll_event events[MAX_EVENTS]; -#else - fd_set reads; -#endif - int is_unix; - int ecs_running; - QEMUTimer *alive_timer; - Monitor *mon; -} ECS_State; - -#define TYPE_NONE 0x00 -#define TYPE_ECP 0x01 -#define TYPE_SIMUL_NFC 0x02 - -typedef struct ECS_Client { - int client_fd; - unsigned char client_id; - unsigned char client_type; - int keep_alive; - const char* type; - - sbuf sbuf; - - ECS_State *cs; - JSONMessageParser parser; - QTAILQ_ENTRY(ECS_Client) next; -} ECS_Client; - #define NFC_MAX_BUF_SIZE 4096 typedef struct nfc_msg_info { @@ -175,16 +70,10 @@ typedef struct nfc_msg_info { int start_ecs(void); bool is_ecs_running(void); -ECS_Client *find_client(unsigned char id, unsigned char type); -bool handle_protobuf_msg(ECS_Client* cli, char* data, const int len); - -bool ntf_to_injector(const char* data, const int len); -bool ntf_to_control(const char* data, const int len); -bool ntf_to_monitor(const char* data, const int len); - bool send_msg_to_guest(const char* cmd, int group, int action, char* data, int data_len); +/* System request */ enum ecs_system_action { ECS_SYSTEM_ACTION_FORCE_CLOSE, ECS_SYSTEM_ACTION_REBOOT @@ -194,59 +83,16 @@ void send_shutdown_request(int action); void make_send_device_ntf (char* cmd, int group, int action, char* data); -bool pb_to_all_clients(ECS__Master* master); -bool pb_to_single_client(ECS__Master* master, ECS_Client *clii); - bool send_injector_ntf(const char* data, const int len); bool send_monitor_ntf(const char* data, const int len); bool send_device_ntf(const char* data, const int len); bool send_nfc_ntf(struct nfc_msg_info *msg); -void send_to_single_client(ECS_Client *clii, const char* data, const int len); -bool send_to_all_client(const char* data, const int len); -void send_to_client(int fd, const char* data, const int len); - -void ecs_client_close(ECS_Client* clii); -int ecs_write(int fd, const uint8_t *buf, int len); -void ecs_make_header(QDict* obj, type_length length, type_group group, type_action action); - -void read_val_short(const char* data, unsigned short* ret_val); -void read_val_char(const char* data, unsigned char* ret_val); -void read_val_str(const char* data, char* ret_val, int len); -void print_binary(const char* data, const int len); - -bool msgproc_injector_req(ECS_Client* ccli, ECS__InjectorReq* msg); -bool msgproc_monitor_req(ECS_Client *ccli, ECS__MonitorReq* msg); -bool msgproc_device_req(ECS_Client* ccli, ECS__DeviceReq* msg); -bool msgproc_device_req_ext(ECS_Client* ccli, ECS__DeviceReq* msg); -bool msgproc_nfc_req(ECS_Client* ccli, ECS__NfcReq* msg); -void msgproc_checkversion_req(ECS_Client* ccli, ECS__CheckVersionReq* msg); -void msgproc_keepalive_ans(ECS_Client* ccli, ECS__KeepAliveAns* msg); -bool msgproc_eventcast_req(ECS_Client* ccli, ECS__EventCastReq* msg); - -char *get_tizen_sdk_data_path(void); - -/* version check */ -//void send_ecs_version_check(ECS_Client* ccli); - -/* Suspend/resume */ +/* Suspend-resume */ #define SUSPEND_LOCK 1 #define SUSPEND_UNLOCK 0 int ecs_get_suspend_state(void); void ecs_set_suspend_state(int state); void ecs_suspend_lock_state(int state); -void send_host_keyboard_ntf(int on); - -void send_target_image_information(ECS_Client* ccli); - -/* request */ -int accel_min_max(double value); -void req_set_sensor_accel(int x, int y, int z); -void req_set_sensor_accel_angle(int angle); -void set_injector_data(const char* data); - -/* Monitor */ -void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens, void *opaque); - #endif /* __ECS_H__ */ diff --git a/tizen/src/ecs/ecs_eventcast.c b/tizen/src/ecs/ecs_eventcast.c index 45261b9895..a922399a1c 100644 --- a/tizen/src/ecs/ecs_eventcast.c +++ b/tizen/src/ecs/ecs_eventcast.c @@ -30,6 +30,7 @@ #include "ui/console.h" #include "ecs.h" +#include "ecs_sensor.h" #include "ecs_eventcast.h" #include "eventcast/common.h" #include "eventcast/sensor.h" @@ -259,7 +260,7 @@ static bool send_eventcast_ntf(const char *data) void send_eventcast_sensor_data(const char *data, int len) { - set_injector_data(data); + ecs_sensor_set_injector_data(data); } void send_eventcast_touch_data(int x, int y, int index, int status) diff --git a/tizen/src/ecs/ecs_internal.h b/tizen/src/ecs/ecs_internal.h new file mode 100644 index 0000000000..02da13bfd6 --- /dev/null +++ b/tizen/src/ecs/ecs_internal.h @@ -0,0 +1,162 @@ +/* + * Emulator Control Server - internal + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Contact: + * Jinhyung Choi + * SeokYeon Hwang + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef __ECS_INTERNAL_H__ +#define __ECS_INTERNAL_H__ + +#ifdef CONFIG_LINUX +#include +#endif + +#include "qemu-common.h" +#include "qapi/qmp/qerror.h" +#include "ecs-json-streamer.h" +#include "genmsg/ecs.pb-c.h" +#include "genmsg/ecs_ids.pb-c.h" +#include "ecs_sensor.h" + +#define TIMER_ALIVE_S 60 +#define TYPE_DATA_SELF "self" + +#define OUT_BUF_SIZE 4096 +#define READ_BUF_LEN 4096 +#define MAX_ID_SIZE 255 +#define MAX_INJECTOR_REQ_DATA 128 + +enum message_action { + MSG_ACT_BATTERY_LEVEL = 100, + MSG_ACT_BATTERY_CHARGER = 101, + MSG_ACT_USB = 102, + MSG_ACT_EARJACK = 103, + MSG_ACT_RSSI = 104, + MSG_ACT_ACCEL = 110, + MSG_ACT_GYRO = 111, + MSG_ACT_MAG = 112, + MSG_ACT_LIGHT = 113, + MSG_ACT_PROXI = 114, + MSG_ACT_MOTION = 115, + MSG_ACT_PRESSURE = 116, + MSG_ACT_UV = 117, + MSG_ACT_HRM = 118, + MSG_ACT_LOCATION = 120, + MSG_ACT_NETBRIDGE = 123 +}; + +typedef struct sbuf +{ + int _netlen; + int _use; + char _buf[OUT_BUF_SIZE]; +} sbuf; + +struct Monitor { + int suspend_cnt; + uint8_t outbuf[OUT_BUF_SIZE]; + int outbuf_index; + void *password_opaque; + Error *error; + QLIST_HEAD(,mon_fd_t) fds; + QLIST_ENTRY(Monitor) entry; +}; + +#define MAX_EVENTS 1000 +#define MAX_FD_NUM 300 +typedef struct ECS_State { + int listen_fd; +#ifdef CONFIG_LINUX + int epoll_fd; + struct epoll_event events[MAX_EVENTS]; +#else + fd_set reads; +#endif + int is_unix; + int ecs_running; + QEMUTimer *alive_timer; + Monitor *mon; +} ECS_State; + +#define TYPE_NONE 0x00 +#define TYPE_ECP 0x01 +#define TYPE_SIMUL_NFC 0x02 + +typedef struct ECS_Client { + int client_fd; + unsigned char client_id; + unsigned char client_type; + int keep_alive; + const char* type; + + sbuf sbuf; + + ECS_State *cs; + JSONMessageParser parser; + QTAILQ_ENTRY(ECS_Client) next; +} ECS_Client; + +#define MAX_CATEGORY_LEN 10 +typedef unsigned short type_length; +typedef unsigned char type_group; +typedef unsigned char type_action; + + +void read_val_short(const char* data, unsigned short* ret_val); +void read_val_char(const char* data, unsigned char* ret_val); +void read_val_str(const char* data, char* ret_val, int len); +void print_binary(const char* data, const int len); + +bool msgproc_injector_req(ECS_Client* ccli, ECS__InjectorReq* msg); +bool msgproc_monitor_req(ECS_Client *ccli, ECS__MonitorReq* msg); +bool msgproc_device_req(ECS_Client* ccli, ECS__DeviceReq* msg); +bool msgproc_device_req_ext(ECS_Client* ccli, ECS__DeviceReq* msg); +bool msgproc_nfc_req(ECS_Client* ccli, ECS__NfcReq* msg); +void msgproc_keepalive_ans(ECS_Client* ccli, ECS__KeepAliveAns* msg); +bool msgproc_eventcast_req(ECS_Client* ccli, ECS__EventCastReq* msg); + +ECS_Client *find_client(unsigned char id, unsigned char type); + +bool ntf_to_injector(const char* data, const int len); +bool ntf_to_control(const char* data, const int len); +bool ntf_to_monitor(const char* data, const int len); + +bool pb_to_all_clients(ECS__Master* master); +bool pb_to_single_client(ECS__Master* master, ECS_Client *clii); + +void send_to_single_client(ECS_Client *clii, const char* data, const int len); +bool send_to_all_client(const char* data, const int len); +void send_to_client(int fd, const char* data, const int len); + +void ecs_client_close(ECS_Client* clii); +int ecs_write(int fd, const uint8_t *buf, int len); +void ecs_make_header(QDict* obj, type_length length, type_group group, type_action action); + + +/* Monitor */ +void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens, void *opaque); + +#endif /* __ECS_INTERNAL_H__ */ diff --git a/tizen/src/ecs/ecs_msg_device.c b/tizen/src/ecs/ecs_msg_device.c index 53707ed2e4..dfc2a793ed 100644 --- a/tizen/src/ecs/ecs_msg_device.c +++ b/tizen/src/ecs/ecs_msg_device.c @@ -3,7 +3,7 @@ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: - * Jinhyung choi + * Jinhyung Choi * MunKyu Im * Daiyoung Kim * YeongKyoon Lee @@ -39,6 +39,7 @@ #include "hw/virtio/maru_virtio_nfc.h" #include "util/ui_operations.h" +#include "ecs_sensor.h" #include "ecs_hds.h" #include "emul_state.h" #include "ecs.h" @@ -85,7 +86,7 @@ static void msgproc_device_ans(ECS_Client* ccli, const char* category, bool succ g_free(ans.category); } -void send_target_image_information(ECS_Client* ccli) { +static void send_target_image_information(ECS_Client* ccli) { ECS__Master master = ECS__MASTER__INIT; ECS__DeviceAns ans = ECS__DEVICE_ANS__INIT; const char *drive_image_file = get_drive_image_file(); @@ -155,7 +156,7 @@ static void msgproc_device_req_sensor(ECS_Client* ccli, ECS__DeviceReq* msg, cha } } else { if (data != NULL) { - set_injector_data(data); + ecs_sensor_set_injector_data(data); msgproc_device_ans(ccli, cmd, true, NULL); } else { LOG_SEVERE("sensor set data is null\n"); diff --git a/tizen/src/ecs/ecs_msg_injector.c b/tizen/src/ecs/ecs_msg_injector.c index c98fbd28f5..6f1a3bfbc2 100644 --- a/tizen/src/ecs/ecs_msg_injector.c +++ b/tizen/src/ecs/ecs_msg_injector.c @@ -3,7 +3,7 @@ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: - * Jinhyung choi + * Jinhyung Choi * MunKyu Im * Daiyoung Kim * YeongKyoon Lee @@ -40,6 +40,7 @@ #include "emul_state.h" #include "ecs_hds.h" +#include "ecs_sensor.h" #include "debug_ch.h" #include "util/osutil.h" #include "util/exported_strings.h" @@ -207,7 +208,7 @@ static bool injector_req_sensor(ECS_Client* ccli, ECS__InjectorReq* msg, char *c send_status_injector_ntf(MSG_TYPE_SENSOR, 6, action, data); return true; } else if (msg->data.data && msg->data.len > 0) { - set_injector_data((char*) msg->data.data); + ecs_sensor_set_injector_data((char*) msg->data.data); return injector_send(ccli, msg, cmd); } diff --git a/tizen/src/ecs/ecs_sensor.c b/tizen/src/ecs/ecs_sensor.c index 707f445abd..35ad486e4a 100644 --- a/tizen/src/ecs/ecs_sensor.c +++ b/tizen/src/ecs/ecs_sensor.c @@ -4,7 +4,7 @@ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved * * Contact: - * Jinhyung choi + * Jinhyung Choi * MunKyu Im * Daiyoung Kim * YeongKyoon Lee @@ -29,11 +29,6 @@ */ #include "qemu-common.h" -//#include "qemu_socket.h" -//#include "qemu-queue.h" -//#include "qemu-option.h" -//#include "qemu-config.h" -//#include "qemu-timer.h" #include @@ -104,6 +99,7 @@ static int _accel_min_max(char* tmp) return accel_min_max(atof(tmp)); } +#if defined(CONFIG_JAVA_UI) void req_set_sensor_accel(int x, int y, int z) { char tmp[TEMP_BUF_SIZE] = { 0, }; @@ -112,7 +108,9 @@ void req_set_sensor_accel(int x, int y, int z) set_sensor_accel(tmp, strlen(tmp)); } +#endif +#if defined(CONFIG_QT) static int convert_abs_angle(int angle) { if (angle < SENSOR_ANGLE_MIN) { return convert_abs_angle(angle + SENSOR_ANGLE_MAX); @@ -174,6 +172,7 @@ void req_set_sensor_accel_angle(int angle) set_sensor_accel(accel, strlen(accel)); } +#endif static void _req_set_sensor_accel(int len, const char* data) { @@ -473,7 +472,7 @@ static void set_battery_data(int len, const char* data) { } } -void set_injector_data(const char* data) +void ecs_sensor_set_injector_data(const char* data) { char tmpbuf[TEMP_BUF_SIZE]; int len = get_parse_val(data, tmpbuf); diff --git a/tizen/src/ecs/ecs_sensor.h b/tizen/src/ecs/ecs_sensor.h new file mode 100644 index 0000000000..f8df3d8c29 --- /dev/null +++ b/tizen/src/ecs/ecs_sensor.h @@ -0,0 +1,57 @@ +/* + * Emulator Control Server - Sensor Device Handler + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Contact: + * Jinhyung Choi + * SeokYeon Hwang + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef __ECS_SENSOR_H__ +#define __ECS_SENSOR_H__ + +enum injector_level { + level_accel = 1, + level_proxi = 2, + level_light = 3, + level_gyro = 4, + level_geo = 5, + level_battery = 8, + level_tilt = 12, + level_magnetic = 13, + level_pressure = 20, + level_uv = 21, + level_hrm = 22, +}; + +/* skin rotation request */ +int accel_min_max(double value); +#if defined(CONFIG_QT) +void req_set_sensor_accel_angle(int angle); +#elif defined(CONFIG_JAVA_UI) +void req_set_sensor_accel(int x, int y, int z); +#endif + +void ecs_sensor_set_injector_data(const char* data); + +#endif // __ECS_SENSOR_H__