sensord: remove set_wakeup API and implementations 68/62168/1
authorkibak.yoon <kibak.yoon@samsung.com>
Tue, 15 Mar 2016 00:24:19 +0000 (09:24 +0900)
committerkibak.yoon <kibak.yoon@samsung.com>
Tue, 15 Mar 2016 00:24:19 +0000 (09:24 +0900)
Change-Id: I4ee5cdcbb06d97539fb163f604863722c4a2d10f
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
25 files changed:
src/client/client.cpp
src/client/command_channel.cpp
src/client/command_channel.h
src/client/sensor_client_info.cpp
src/client/sensor_client_info.h
src/client/sensor_handle_info.cpp
src/client/sensor_handle_info.h
src/client/sensor_internal.h
src/server/client_info_manager.cpp
src/server/client_info_manager.h
src/server/client_sensor_record.cpp
src/server/client_sensor_record.h
src/server/command_worker.cpp
src/server/command_worker.h
src/server/physical_sensor.cpp
src/server/physical_sensor.h
src/server/sensor_base.cpp
src/server/sensor_base.h
src/server/sensor_info_list.cpp
src/server/sensor_info_list.h
src/server/sensor_usage.cpp
src/server/sensor_usage.h
src/server/virtual_sensor.h
src/shared/command_common.h
src/shared/sensor_common.h

index cef182c..4366792 100644 (file)
@@ -999,40 +999,6 @@ API bool sensord_set_option(int handle, int option)
 
 }
 
-API bool sensord_set_wakeup(int handle, int wakeup)
-{
-       sensor_id_t sensor_id;
-       command_channel *cmd_channel;
-       int client_id;
-
-       AUTOLOCK(lock);
-
-       if (!sensor_client_info::get_instance().get_sensor_id(handle, sensor_id)) {
-               _E("client %s failed to get handle information", get_client_name());
-               return false;
-       }
-
-       retvm_if ((wakeup != SENSOR_WAKEUP_ON) && (wakeup != SENSOR_WAKEUP_OFF), false, "Invalid wakeup value : %d, handle: %d, %s, %s",
-               wakeup, handle, get_sensor_name(sensor_id), get_client_name());
-
-       sensor_client_info::get_instance().set_sensor_wakeup(handle, wakeup);
-
-       if (!sensor_client_info::get_instance().get_command_channel(sensor_id, &cmd_channel)) {
-               _E("client %s failed to get command channel for %s", get_client_name(), get_sensor_name(sensor_id));
-               return false;
-       }
-
-       client_id = sensor_client_info::get_instance().get_client_id();
-       retvm_if ((client_id < 0), false, "Invalid client id : %d, handle: %d, %s, %s", client_id, handle, get_sensor_name(sensor_id), get_client_name());
-
-       if (!cmd_channel->cmd_set_wakeup(wakeup)) {
-               _E("Sending cmd_set_wakeup(%d, %s, %d) failed for %s", client_id, get_sensor_name(sensor_id), wakeup, get_client_name());
-               return false;
-       }
-
-       return true;
-}
-
 API bool sensord_set_attribute_int(int handle, int attribute, int value)
 {
        sensor_id_t sensor_id;
index 4e978a8..d1c91c3 100644 (file)
@@ -374,45 +374,6 @@ bool command_channel::cmd_set_option(int option)
        return true;
 }
 
-bool command_channel::cmd_set_wakeup(int wakeup)
-{
-       cpacket *packet;
-       cmd_set_wakeup_t *cmd_set_wakeup;
-       cmd_done_t *cmd_done;
-
-       packet = new(std::nothrow) cpacket(sizeof(cmd_set_wakeup_t));
-       retvm_if(!packet, false, "Failed to allocate memory");
-
-       packet->set_cmd(CMD_SET_WAKEUP);
-
-       cmd_set_wakeup = (cmd_set_wakeup_t*)packet->data();
-       cmd_set_wakeup->wakeup = wakeup;
-
-       _I("%s send cmd_set_wakeup(client_id=%d, %s, wakeup=%d)",
-               get_client_name(), m_client_id, get_sensor_name(m_sensor_id), wakeup);
-
-       if (!command_handler(packet, (void **)&cmd_done)) {
-               _E("Client %s failed to send/receive command for sensor[%s] with client_id [%d], wakeup[%d]",
-                       get_client_name(), get_sensor_name(m_sensor_id), m_client_id, wakeup);
-               delete packet;
-               return false;
-       }
-
-       if (cmd_done->value < 0) {
-               _E("Client %s got error[%d] from server for sensor[%s] with client_id [%d], wakeup[%d]",
-                       get_client_name(), cmd_done->value, get_sensor_name(m_sensor_id), m_client_id, wakeup);
-
-               delete[] (char *)cmd_done;
-               delete packet;
-               return false;
-       }
-
-       delete[] (char *)cmd_done;
-       delete packet;
-
-       return true;
-}
-
 bool command_channel::cmd_register_event(unsigned int event_type)
 {
        cpacket *packet;
index faa3837..b99891b 100644 (file)
@@ -40,7 +40,6 @@ public:
        bool cmd_start(void);
        bool cmd_stop(void);
        bool cmd_set_option(int option);
-       bool cmd_set_wakeup(int wakeup);
        bool cmd_register_event(unsigned int event_type);
        bool cmd_register_events(event_type_vector &event_vec);
        bool cmd_unregister_event(unsigned int event_type);
index 684cd52..ded2acc 100644 (file)
@@ -524,38 +524,6 @@ bool sensor_client_info::get_sensor_state(int handle, int &sensor_state)
        return true;
 }
 
-bool sensor_client_info::get_sensor_wakeup(int handle, int &sensor_wakeup)
-{
-       AUTOLOCK(m_handle_info_lock);
-
-       auto it_handle = m_sensor_handle_infos.find(handle);
-
-       if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
-               return false;
-       }
-
-       sensor_wakeup = it_handle->second.m_sensor_wakeup;
-
-       return true;
-}
-
-bool sensor_client_info::set_sensor_wakeup(int handle, int sensor_wakeup)
-{
-       AUTOLOCK(m_handle_info_lock);
-
-       auto it_handle = m_sensor_handle_infos.find(handle);
-
-       if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
-               return false;
-       }
-
-       it_handle->second.m_sensor_wakeup = sensor_wakeup;
-
-       return true;
-}
-
 void sensor_client_info::get_active_event_types(sensor_id_t sensor, event_type_vector &active_event_types)
 {
        event_type_vector event_types;
index e3869d2..47a4adf 100644 (file)
@@ -89,8 +89,6 @@ public:
 
        bool get_sensor_id(int handle, sensor_id_t &sensor_id);
        bool get_sensor_state(int handle, int &state);
-       bool get_sensor_wakeup(int handle, int &sensor_wakeup);
-       bool set_sensor_wakeup(int handle, int sensor_wakeup);
 
        bool has_client_id(void);
        int get_client_id(void);
index 6d9e429..9ea4d0d 100644 (file)
@@ -30,7 +30,6 @@ sensor_handle_info::sensor_handle_info()
 , m_sensor_id(UNKNOWN_SENSOR)
 , m_sensor_state(SENSOR_STATE_UNKNOWN)
 , m_sensor_option(SENSOR_OPTION_DEFAULT)
-, m_sensor_wakeup(SENSOR_WAKEUP_OFF)
 , m_bad_accuracy(false)
 , m_accuracy(-1)
 , m_accuracy_cb(NULL)
index f56da67..fa0fb4c 100644 (file)
@@ -35,7 +35,6 @@ public:
        sensor_id_t m_sensor_id;
        int m_sensor_state;
        int m_sensor_option;
-       int m_sensor_wakeup;
        int m_bad_accuracy;
        int m_accuracy;
        sensor_accuracy_changed_cb_t m_accuracy_cb;
index b16e086..94a05b5 100644 (file)
@@ -312,18 +312,7 @@ bool sensord_change_event_maincontext(int handle, unsigned int event_type, GMain
  */
 bool sensord_set_option(int handle, int option);
 
-/**
- * @brief Change the wakeup mode of a connected sensor.
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @param[in] wakeup either one of SENSOR_WAKEUP_OFF and SENSOR_WAKEUP_ON.
- *                                  with SENSOR_WAKEUP_OFF, it stops to listening events when AP is asleep.
- *                                  with SENSOR_WAKEUP_ON, it continues to listening events even when AP is asleep.
- * @return true on success, otherwise false.
- */
-bool sensord_set_wakeup(int handle, int wakeup);
-
-/**
+/*
  * @brief Set the attribute to a connected sensor
  *
  * @param[in] handle a handle represensting a connected sensor.
index 068778b..536f164 100644 (file)
@@ -136,22 +136,6 @@ bool client_info_manager::set_option(int client_id, sensor_id_t sensor_id, int o
        return true;
 }
 
-bool client_info_manager::set_wakeup(int client_id, sensor_id_t sensor_id, int wakeup)
-{
-       AUTOLOCK(m_mutex);
-
-       auto it_record = m_clients.find(client_id);
-
-       if (it_record == m_clients.end()) {
-               _E("Client[%d] is not found", client_id);
-               return false;
-       }
-
-       if(!it_record->second.set_wakeup(sensor_id, wakeup))
-               return false;
-
-       return true;
-}
 
 bool client_info_manager::set_start(int client_id, sensor_id_t sensor_id, bool start)
 {
index 7a9dde6..e790534 100644 (file)
@@ -53,7 +53,6 @@ public:
        bool set_batch(int client_id, sensor_id_t sensor_id, unsigned int interval, unsigned int latency);
        bool get_batch(int client_id, sensor_id_t sensor_id, unsigned int &interval, unsigned int &latency);
        bool set_option(int client_id, sensor_id_t sensor_id, int option);
-       bool set_wakeup(int client_id, sensor_id_t sensor_id, int wakeup);
 
        bool set_start(int client_id, sensor_id_t sensor_id, bool start);
        bool is_started(int client_id, sensor_id_t sensor_id);
index c7ee8e1..58fde54 100644 (file)
@@ -88,20 +88,6 @@ bool client_sensor_record::set_option(sensor_id_t sensor_id, int option)
        return true;
 }
 
-bool client_sensor_record::set_wakeup(sensor_id_t sensor_id, int wakeup)
-{
-       auto it_usage = m_sensor_usages.find(sensor_id);
-
-       if (it_usage == m_sensor_usages.end()) {
-               sensor_usage usage;
-               usage.m_wakeup = wakeup;
-               m_sensor_usages.insert(pair<sensor_id_t, sensor_usage>(sensor_id, usage));
-       } else {
-               it_usage->second.m_wakeup = wakeup;
-       }
-
-       return true;
-}
 
 bool client_sensor_record::set_start(sensor_id_t sensor_id, bool start)
 {
index 9386507..defc3d9 100644 (file)
@@ -48,7 +48,6 @@ public:
        bool set_batch(sensor_id_t sensor_id, unsigned int interval, unsigned int latency);
        bool get_batch(sensor_id_t sensor_id, unsigned int &interval, unsigned int &latency);
        bool set_option(sensor_id_t sensor_id, int option);
-       bool set_wakeup(sensor_id_t sensor_id, int wakeup);
 
        bool set_start(sensor_id_t sensor_id, bool start);
        bool is_started(sensor_id_t sensor_id);
index 0423eab..b99ba0f 100644 (file)
@@ -82,7 +82,6 @@ void command_worker::init_cmd_handlers(void)
        m_cmd_handlers[CMD_REG]                                 = &command_worker::cmd_register_event;
        m_cmd_handlers[CMD_UNREG]                               = &command_worker::cmd_unregister_event;
        m_cmd_handlers[CMD_SET_OPTION]                  = &command_worker::cmd_set_option;
-       m_cmd_handlers[CMD_SET_WAKEUP]                  = &command_worker::cmd_set_wakeup;
        m_cmd_handlers[CMD_SET_BATCH]                   = &command_worker::cmd_set_batch;
        m_cmd_handlers[CMD_UNSET_BATCH]                 = &command_worker::cmd_unset_batch;
        m_cmd_handlers[CMD_GET_DATA]                    = &command_worker::cmd_get_data;
@@ -698,36 +697,6 @@ out:
        return true;
 }
 
-bool command_worker::cmd_set_wakeup(void *payload)
-{
-       cmd_set_wakeup_t *cmd;
-       long ret_value = OP_ERROR;
-
-       cmd = (cmd_set_wakeup_t*)payload;
-
-       if (!is_permission_allowed()) {
-               _E("Permission denied to set wakeup for client [%d], for sensor [0x%llx] with wakeup [%d] to client info manager",
-                       m_client_id, m_sensor_id, cmd->wakeup);
-               ret_value = OP_ERROR;
-               goto out;
-       }
-
-       if (!get_client_info_manager().set_wakeup(m_client_id, m_sensor_id, cmd->wakeup)) {
-               _E("Failed to set wakeup for client [%d], for sensor [0x%llx] with wakeup [%d] to client info manager",
-                       m_client_id, m_sensor_id, cmd->wakeup);
-               ret_value = OP_ERROR;
-               goto out;
-       }
-
-       ret_value = m_module->add_wakeup(m_client_id, cmd->wakeup);
-
-out:
-       if (!send_cmd_done(ret_value))
-               _E("Failed to send cmd_done to a client");
-
-       return true;
-}
-
 bool command_worker::cmd_get_data(void *payload)
 {
        const unsigned int GET_DATA_MIN_INTERVAL = 10;
index d03d4a3..c3ce538 100644 (file)
@@ -70,7 +70,6 @@ private:
        bool cmd_set_batch(void *payload);
        bool cmd_unset_batch(void *payload);
        bool cmd_set_option(void *payload);
-       bool cmd_set_wakeup(void *payload);
        bool cmd_get_data(void *payload);
        bool cmd_set_attribute_int(void *payload);
        bool cmd_set_attribute_str(void *payload);
index 83efec8..49858f4 100644 (file)
@@ -172,11 +172,6 @@ int physical_sensor::set_attribute(int32_t attribute, char *value, int value_len
        return OP_SUCCESS;
 }
 
-bool physical_sensor::set_wakeup(int wakeup)
-{
-       return false;
-}
-
 bool physical_sensor::on_start()
 {
        AUTOLOCK(m_mutex);
index a35edc8..7bad87d 100644 (file)
@@ -54,7 +54,6 @@ private:
        virtual bool set_batch_latency(unsigned long latency);
        virtual int set_attribute(int32_t attribute, int32_t value);
        virtual int set_attribute(int32_t attribute, char *value, int value_len);
-       virtual bool set_wakeup(int wakeup);
        virtual bool on_start(void);
        virtual bool on_stop(void);
        virtual bool get_sensor_info(sensor_info &info);
index 4fefeff..f339533 100644 (file)
@@ -266,61 +266,6 @@ unsigned int sensor_base::get_batch(int client_id)
        return m_sensor_info_list.get_batch(client_id);
 }
 
-bool sensor_base::add_wakeup(int client_id, int wakeup)
-{
-       int prev_wakeup, cur_wakeup;
-
-       AUTOLOCK(m_sensor_info_list_mutex);
-
-       prev_wakeup = m_sensor_info_list.is_wakeup_on();
-
-       if (!m_sensor_info_list.add_wakeup(client_id, wakeup))
-               return false;
-
-       cur_wakeup = m_sensor_info_list.is_wakeup_on();
-
-       if ((cur_wakeup == SENSOR_WAKEUP_ON) && (prev_wakeup < SENSOR_WAKEUP_ON)) {
-               _I("Wakeup for sensor[0x%llx] is changed from %d to %d by client[%d] adding wakeup",
-                       get_id(), prev_wakeup, cur_wakeup, client_id);
-               set_wakeup(SENSOR_WAKEUP_ON);
-       }
-
-       return true;
-}
-
-bool sensor_base::delete_wakeup(int client_id)
-{
-       int prev_wakeup, cur_wakeup;
-       AUTOLOCK(m_sensor_info_list_mutex);
-
-       prev_wakeup = m_sensor_info_list.is_wakeup_on();
-
-       if (!m_sensor_info_list.delete_wakeup(client_id))
-               return false;
-
-       cur_wakeup = m_sensor_info_list.is_wakeup_on();
-
-       if ((cur_wakeup < SENSOR_WAKEUP_ON) && (prev_wakeup == SENSOR_WAKEUP_ON)) {
-               _I("Wakeup for sensor[0x%llx] is changed from %d to %d by client[%d] deleting wakeup",
-                       get_id(), prev_wakeup, cur_wakeup, client_id);
-               set_wakeup(SENSOR_WAKEUP_OFF);
-       }
-
-       return true;
-}
-
-int sensor_base::get_wakeup(int client_id)
-{
-       AUTOLOCK(m_sensor_info_list_mutex);
-
-       return m_sensor_info_list.is_wakeup_on();
-}
-
-bool sensor_base::is_wakeup_supported(void)
-{
-       return false;
-}
-
 int sensor_base::get_permission(void)
 {
        return m_permission;
@@ -352,11 +297,6 @@ bool sensor_base::set_batch_latency(unsigned long latency)
        return false;
 }
 
-bool sensor_base::set_wakeup(int wakeup)
-{
-       return false;
-}
-
 bool sensor_base::on_start()
 {
        return false;
index 0260119..95ea6c5 100644 (file)
@@ -60,7 +60,7 @@ public:
        bool stop(void);
        bool is_started(void);
 
-       /* interval / batch / wakeup */
+       /* interval / batch */
        virtual bool add_interval(int client_id, unsigned int interval, bool is_processor);
        virtual bool delete_interval(int client_id, bool is_processor);
        unsigned int get_interval(int client_id, bool is_processor);
@@ -69,11 +69,6 @@ public:
        virtual bool delete_batch(int client_id);
        unsigned int get_batch(int client_id);
 
-       virtual bool add_wakeup(int client_id, int wakeup);
-       virtual bool delete_wakeup(int client_id);
-       int get_wakeup(int client_id);
-       bool is_wakeup_supported(void);
-
        bool push(sensor_event_t *event);
 
        /* permission(privilege) */
@@ -95,7 +90,6 @@ private:
 
        virtual bool set_interval(unsigned long interval);
        virtual bool set_batch_latency(unsigned long latency);
-       virtual bool set_wakeup(int wakeup);
 
        virtual bool on_start(void);
        virtual bool on_stop(void);
index 21e6f62..8cbc879 100644 (file)
@@ -33,12 +33,6 @@ batch_info::batch_info(int client_id, unsigned int latency)
        this->latency = latency;
 }
 
-wakeup_info::wakeup_info(int client_id, int wakeup)
-{
-       this->client_id = client_id;
-       this->wakeup = wakeup;
-}
-
 bool sensor_info_list::comp_interval_info(interval_info a, interval_info b)
 {
        return a.interval < b.interval;
@@ -77,20 +71,6 @@ batch_info_iterator sensor_info_list::find_if_batch_info(int client_id)
        return iter;
 }
 
-wakeup_info_iterator sensor_info_list::find_if_wakeup_info(int client_id)
-{
-       auto iter = m_wakeup_info_list.begin();
-
-       while (iter != m_wakeup_info_list.end()) {
-               if (iter->client_id == client_id)
-                       break;
-
-               ++iter;
-       }
-
-       return iter;
-}
-
 bool sensor_info_list::add_interval(int client_id, unsigned int interval, bool is_processor)
 {
        auto iter = find_if_interval_info(client_id, is_processor);
@@ -179,54 +159,3 @@ unsigned int sensor_info_list::get_max_batch(void)
        return iter->latency;
 }
 
-bool sensor_info_list::add_wakeup(int client_id, int wakeup)
-{
-       auto iter = find_if_wakeup_info(client_id);
-
-       if (iter != m_wakeup_info_list.end())
-               *iter = wakeup_info(client_id, wakeup);
-       else
-               m_wakeup_info_list.push_back(wakeup_info(client_id, wakeup));
-
-       return true;
-}
-
-bool sensor_info_list::delete_wakeup(int client_id)
-{
-       auto iter = find_if_wakeup_info(client_id);
-
-       if (iter == m_wakeup_info_list.end())
-               return false;
-
-       m_wakeup_info_list.erase(iter);
-
-       return true;
-}
-
-int sensor_info_list::get_wakeup(int client_id)
-{
-       auto iter = find_if_wakeup_info(client_id);
-
-       if (iter == m_wakeup_info_list.end())
-               return -1;
-
-       return iter->wakeup;
-}
-
-int sensor_info_list::is_wakeup_on(void)
-{
-       if (m_wakeup_info_list.empty())
-               return -1;
-
-       auto iter = m_wakeup_info_list.begin();
-
-       while (iter != m_wakeup_info_list.end()) {
-               if (iter->wakeup == true)
-                       break;
-
-               ++iter;
-       }
-
-       return iter->wakeup;
-}
-
index fc253aa..0edb0fa 100644 (file)
@@ -41,15 +41,6 @@ public:
 
 typedef std::list<batch_info>::iterator batch_info_iterator;
 
-class wakeup_info {
-public:
-       wakeup_info(int client_id, int wakeup);
-       int client_id;
-       int wakeup;
-};
-
-typedef std::list<wakeup_info>::iterator wakeup_info_iterator;
-
 class sensor_info_list {
 public:
        bool add_interval(int client_id, unsigned int interval, bool is_processor);
@@ -62,11 +53,6 @@ public:
        unsigned int get_batch(int client_id);
        unsigned int get_max_batch(void);
 
-       bool add_wakeup(int client_id, int wakeup);
-       bool delete_wakeup(int client_id);
-       int get_wakeup(int client_id);
-       int is_wakeup_on(void);
-
 private:
        static bool comp_interval_info(interval_info a, interval_info b);
        interval_info_iterator find_if_interval_info(int client_id, bool is_processor);
@@ -74,10 +60,7 @@ private:
        static bool comp_batch_info(batch_info a, batch_info b);
        batch_info_iterator find_if_batch_info(int client_id);
 
-       wakeup_info_iterator find_if_wakeup_info(int client_id);
-
        std::list<interval_info> m_interval_info_list;
        std::list<batch_info> m_batch_info_list;
-       std::list<wakeup_info> m_wakeup_info_list;
 };
 #endif /* _SENSOR_INFO_LIST_H_ */
index 8f4e758..4b6c881 100644 (file)
@@ -26,7 +26,6 @@ sensor_usage::sensor_usage()
 : m_interval(POLL_MAX_HZ_MS)
 , m_latency(0)
 , m_option(SENSOR_OPTION_DEFAULT)
-, m_wakeup(SENSOR_WAKEUP_OFF)
 , m_start(false)
 {
 
index f13018d..91c4571 100644 (file)
@@ -30,7 +30,6 @@ public:
        unsigned int m_interval;
        unsigned int m_latency;
        int m_option;
-       int m_wakeup;
        reg_event_vector m_reg_events;
        bool m_start;
 
index a0adbcc..a1d4363 100644 (file)
@@ -52,8 +52,6 @@ protected:
 private:
        virtual bool set_interval(unsigned long interval) = 0;
        virtual bool set_batch_latency(unsigned long latency) = 0;
-       virtual bool set_wakeup(int wakeup) = 0;
-
        virtual bool on_start(void) = 0;
        virtual bool on_stop(void) = 0;
 };
index bb67f70..0e2a5ac 100644 (file)
@@ -41,7 +41,6 @@ enum packet_type_t {
        CMD_REG,
        CMD_UNREG,
        CMD_SET_OPTION,
-       CMD_SET_WAKEUP,
        CMD_SET_BATCH,
        CMD_UNSET_BATCH,
        CMD_GET_DATA,
@@ -115,9 +114,6 @@ typedef struct {
        int option;
 } cmd_set_option_t;
 
-typedef struct {
-       int wakeup;
-} cmd_set_wakeup_t;
 
 typedef struct  {
        int attribute;
index 7ba2a89..40b95b8 100644 (file)
@@ -71,12 +71,6 @@ enum sensor_option_t {
 typedef enum sensor_option_t sensor_option_e;
 #endif
 
-enum sensor_wakeup_t {
-       SENSOR_WAKEUP_UNKNOWN = -1,
-       SENSOR_WAKEUP_OFF = 0,
-       SENSOR_WAKEUP_ON = 1,
-};
-
 enum poll_interval_t {
        POLL_100HZ_MS   = 10,
        POLL_50HZ_MS    = 20,