sensor_rep prev_rep, cur_rep;
prev_rep.active = false;
- prev_rep.option = SENSOR_OPTION_DEFAULT;
+ prev_rep.pause_policy = SENSORD_PAUSE_ALL;
prev_rep.interval = 0;
sensor_client_info::get_instance().get_sensor_rep(*it_sensor, cur_rep);
get_events_diff(prev_rep.event_types, cur_rep.event_types, add_event_types, del_event_types);
if (cur_rep.active) {
- if (prev_rep.option != cur_rep.option) {
- if (!cmd_channel->cmd_set_option(cur_rep.option)) {
- _E("Sending cmd_set_option(%d, %s, %d) failed for %s", client_id, get_sensor_name(sensor_id), cur_rep.option, get_client_name());
+ if (prev_rep.pause_policy != cur_rep.pause_policy) {
+ if (!cmd_channel->cmd_set_pause_policy(cur_rep.pause_policy)) {
+ _E("Sending cmd_set_pause_policy(%d, %s, %d) failed for %s", client_id, get_sensor_name(sensor_id), cur_rep.pause_policy, get_client_name());
return false;
}
}
sensor_id_t sensor_id;
sensor_rep prev_rep, cur_rep;
bool ret;
- int prev_state, prev_option;
+ int prev_state, prev_pause;
int pause;
AUTOLOCK(lock);
}
sensor_client_info::get_instance().get_sensor_rep(sensor_id, prev_rep);
- sensor_client_info::get_instance().get_sensor_params(handle, prev_state, prev_option);
+ sensor_client_info::get_instance().get_sensor_params(handle, prev_state, prev_pause);
sensor_client_info::get_instance().set_sensor_params(handle, SENSOR_STATE_STARTED, pause);
sensor_client_info::get_instance().get_sensor_rep(sensor_id, cur_rep);
ret = change_sensor_rep(sensor_id, prev_rep, cur_rep);
if (!ret)
- sensor_client_info::get_instance().set_sensor_params(handle, prev_state, prev_option);
+ sensor_client_info::get_instance().set_sensor_params(handle, prev_state, prev_pause);
return ret;
}
sensor_id_t sensor_id;
int sensor_state;
bool ret;
- int prev_state, prev_option;
+ int prev_state, prev_pause;
sensor_rep prev_rep, cur_rep;
_I("%s stops sensor %s[%d]", get_client_name(), get_sensor_name(sensor_id), handle);
sensor_client_info::get_instance().get_sensor_rep(sensor_id, prev_rep);
- sensor_client_info::get_instance().get_sensor_params(handle, prev_state, prev_option);
+ sensor_client_info::get_instance().get_sensor_params(handle, prev_state, prev_pause);
sensor_client_info::get_instance().set_sensor_state(handle, SENSOR_STATE_STOPPED);
sensor_client_info::get_instance().get_sensor_rep(sensor_id, cur_rep);
ret = change_sensor_rep(sensor_id, prev_rep, cur_rep);
if (!ret)
- sensor_client_info::get_instance().set_sensor_params(handle, prev_state, prev_option);
+ sensor_client_info::get_instance().set_sensor_params(handle, prev_state, prev_pause);
return ret;
}
else if (!(pause & g_power_save_state) && (sensor_state == SENSOR_STATE_PAUSED))
sensor_client_info::get_instance().set_sensor_state(handle, SENSOR_STATE_STARTED);
}
- sensor_client_info::get_instance().set_sensor_option(handle, pause);
+ sensor_client_info::get_instance().set_sensor_pause_policy(handle, pause);
sensor_client_info::get_instance().get_sensor_rep(sensor_id, cur_rep);
ret = change_sensor_rep(sensor_id, prev_rep, cur_rep);
if (!ret)
- sensor_client_info::get_instance().set_sensor_option(handle, prev_pause);
+ sensor_client_info::get_instance().set_sensor_pause_policy(handle, prev_pause);
return (ret ? OP_SUCCESS : OP_ERROR);
}
if ((count != 1) && (count % log_per_count != 0))
return;
- _D("%s receives %s[%d][state: %d, option: %d, count: %d]", get_client_name(),
+ _D("%s receives %s[%d][state: %d, pause policy: %d, count: %d]", get_client_name(),
get_sensor_name(info.m_sensor_id), info.m_handle,
- info.m_sensor_state, info.m_sensor_option, count);
+ info.m_sensor_state, info.m_pause_policy, count);
}
/*
return true;
}
-bool command_channel::cmd_set_option(int option)
+bool command_channel::cmd_set_pause_policy(int pause_policy)
{
cpacket *packet;
- cmd_set_option_t *cmd_set_option;
+ cmd_set_pause_policy_t *cmd_set_pause_policy;
cmd_done_t *cmd_done;
- packet = new(std::nothrow) cpacket(sizeof(cmd_set_option_t));
+ packet = new(std::nothrow) cpacket(sizeof(cmd_set_pause_policy_t));
retvm_if(!packet, false, "Failed to allocate memory");
- packet->set_cmd(CMD_SET_OPTION);
+ packet->set_cmd(CMD_SET_PAUSE_POLICY);
- cmd_set_option = (cmd_set_option_t*)packet->data();
- cmd_set_option->option = option;
+ cmd_set_pause_policy = (cmd_set_pause_policy_t*)packet->data();
+ cmd_set_pause_policy->pause_policy = pause_policy;
- _I("%s send cmd_set_option(client_id=%d, %s, option=%d)",
- get_client_name(), m_client_id, get_sensor_name(m_sensor_id), option);
+ _I("%s send cmd_set_pause_policy(client_id=%d, %s, pause_policy=%d)",
+ get_client_name(), m_client_id, get_sensor_name(m_sensor_id), pause_policy);
if (!command_handler(packet, (void **)&cmd_done)) {
- _E("Client %s failed to send/receive command for sensor[%s] with client_id [%d], option[%d]",
- get_client_name(), get_sensor_name(m_sensor_id), m_client_id, option);
+ _E("Client %s failed to send/receive command for sensor[%s] with client_id [%d], pause_policy[%d]",
+ get_client_name(), get_sensor_name(m_sensor_id), m_client_id, pause_policy);
delete packet;
return false;
}
if (cmd_done->value < 0) {
- _E("Client %s got error[%d] from server for sensor[%s] with client_id [%d], option[%d]",
- get_client_name(), cmd_done->value, get_sensor_name(m_sensor_id), m_client_id, option);
+ _E("Client %s got error[%d] from server for sensor[%s] with client_id [%d], pause_policy[%d]",
+ get_client_name(), cmd_done->value, get_sensor_name(m_sensor_id), m_client_id, pause_policy);
delete[] (char *)cmd_done;
delete packet;
bool cmd_byebye(void);
bool cmd_start(void);
bool cmd_stop(void);
- bool cmd_set_option(int option);
+ bool cmd_set_pause_policy(int pause_policy);
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);
handle_info.m_sensor_id = sensor;
handle_info.m_sensor_state = SENSOR_STATE_STOPPED;
- handle_info.m_sensor_option = SENSOR_OPTION_DEFAULT;
+ handle_info.m_pause_policy = SENSORD_PAUSE_ALL;
handle_info.m_handle = handle;
handle_info.m_accuracy = -1;
handle_info.m_accuracy_cb = NULL;
return true;
}
-bool sensor_client_info::set_sensor_params(int handle, int sensor_state, int sensor_option)
+bool sensor_client_info::set_sensor_params(int handle, int sensor_state, int pause_policy)
{
AUTOLOCK(m_handle_info_lock);
}
it_handle->second.m_sensor_state = sensor_state;
- it_handle->second.m_sensor_option = sensor_option;
+ it_handle->second.m_pause_policy = pause_policy;
return true;
}
-bool sensor_client_info::get_sensor_params(int handle, int &sensor_state, int &sensor_option)
+bool sensor_client_info::get_sensor_params(int handle, int &sensor_state, int &pause_policy)
{
AUTOLOCK(m_handle_info_lock);
}
sensor_state = it_handle->second.m_sensor_state;
- sensor_option = it_handle->second.m_sensor_option;
+ pause_policy = it_handle->second.m_pause_policy;
return true;
}
return true;
}
-bool sensor_client_info::set_sensor_option(int handle, int sensor_option)
+bool sensor_client_info::set_sensor_pause_policy(int handle, int pause_policy)
{
AUTOLOCK(m_handle_info_lock);
return false;
}
- it_handle->second.m_sensor_option = sensor_option;
+ it_handle->second.m_pause_policy = pause_policy;
return true;
}
const unsigned int INVALID_BATCH_VALUE = std::numeric_limits<unsigned int>::max();
rep.active = is_sensor_active(sensor);
- rep.option = get_active_option(sensor);
+ rep.pause_policy = get_active_pause_policy(sensor);
if (!get_active_batch(sensor, rep.interval, rep.latency)) {
rep.interval = INVALID_BATCH_VALUE;
rep.latency = INVALID_BATCH_VALUE;
return true;
}
-unsigned int sensor_client_info::get_active_option(sensor_id_t sensor)
+unsigned int sensor_client_info::get_active_pause_policy(sensor_id_t sensor)
{
- int active_option = SENSOR_OPTION_DEFAULT;
+ int active_pause = SENSORD_PAUSE_ALL;
bool active_sensor_found = false;
- int option;
+ int pause;
AUTOLOCK(m_handle_info_lock);
if ((it_handle->second.m_sensor_id == sensor) &&
(it_handle->second.m_sensor_state == SENSOR_STATE_STARTED)) {
active_sensor_found = true;
- option = it_handle->second.m_sensor_option;
- active_option = (option > active_option) ? option : active_option;
+ pause = it_handle->second.m_pause_policy;
+ active_pause = (pause < active_pause) ? pause: active_pause;
}
++it_handle;
if (!active_sensor_found)
_D("Active sensor[%#llx] is not found for client %s", sensor, get_client_name());
- return active_option;
+ return active_pause;
}
bool sensor_client_info::get_sensor_id(int handle, sensor_id_t &sensor)
typedef struct sensor_rep {
bool active;
- int option;
+ int pause_policy;
unsigned int interval;
unsigned int latency;
event_type_vector event_types;
bool register_accuracy_cb(int handle, sensor_accuracy_changed_cb_t cb, void* user_data);
bool unregister_accuracy_cb(int handle);
- bool set_sensor_params(int handle, int sensor_state, int sensor_option);
- bool get_sensor_params(int handle, int &sensor_state, int &sensor_option);
+ bool set_sensor_params(int handle, int sensor_state, int sensor_pause_policy);
+ bool get_sensor_params(int handle, int &sensor_state, int &sensor_pause_policy);
bool set_sensor_state(int handle, int sensor_state);
- bool set_sensor_option(int handle, int sensor_option);
+ bool set_sensor_pause_policy(int handle, int pause_policy);
bool set_event_batch(int handle, unsigned int event_type, unsigned int interval, unsigned int latency);
bool set_accuracy(int handle, int accuracy);
bool set_bad_accuracy(int handle, int bad_accuracy);
void get_sensor_rep(sensor_id_t sensor, sensor_rep& rep);
bool get_active_batch(sensor_id_t sensor, unsigned int &interval, unsigned int &latency);
- unsigned int get_active_option(sensor_id_t sensor_id);
+ unsigned int get_active_pause_policy(sensor_id_t sensor_id);
void get_active_event_types(sensor_id_t sensor_id, event_type_vector &active_event_types);
bool get_sensor_id(int handle, sensor_id_t &sensor_id);
if ((it_handle->second.m_sensor_state == SENSOR_STATE_STARTED) &&
power_save_state &&
- !(it_handle->second.m_sensor_option & power_save_state)) {
+ (it_handle->second.m_pause_policy & power_save_state)) {
m_client_info.set_sensor_state(it_handle->first, SENSOR_STATE_PAUSED);
_I("%s's %s[%d] is paused", get_client_name(), get_sensor_name(sensor), it_handle->first);
} else if ((it_handle->second.m_sensor_state == SENSOR_STATE_PAUSED) &&
- (!power_save_state || (it_handle->second.m_sensor_option & power_save_state))) {
+ (!power_save_state || !(it_handle->second.m_pause_policy & power_save_state))) {
m_client_info.set_sensor_state(it_handle->first, SENSOR_STATE_STARTED);
_I("%s's %s[%d] is resumed", get_client_name(), get_sensor_name(sensor), it_handle->first);
}
: m_handle(0)
, m_sensor_id(UNKNOWN_SENSOR)
, m_sensor_state(SENSOR_STATE_UNKNOWN)
-, m_sensor_option(SENSOR_OPTION_DEFAULT)
+, m_pause_policy(SENSORD_PAUSE_ALL)
, m_bad_accuracy(false)
, m_accuracy(-1)
, m_accuracy_cb(NULL)
int m_handle;
sensor_id_t m_sensor_id;
int m_sensor_state;
- int m_sensor_option;
+ int m_pause_policy;
int m_bad_accuracy;
int m_accuracy;
sensor_accuracy_changed_cb_t m_accuracy_cb;
return it_record->second.get_batch(sensor_id, interval, latency);
}
-bool client_info_manager::set_option(int client_id, sensor_id_t sensor_id, int option)
+bool client_info_manager::set_pause_policy(int client_id, sensor_id_t sensor_id, int pause_policy)
{
AUTOLOCK(m_mutex);
return false;
}
- if (!it_record->second.set_option(sensor_id, option))
+ if (!it_record->second.set_pause_policy(sensor_id, pause_policy))
return false;
return true;
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_pause_policy(int client_id, sensor_id_t sensor_id, int pause_policy);
bool set_start(int client_id, sensor_id_t sensor_id, bool start);
bool is_started(int client_id, sensor_id_t sensor_id);
return true;
}
-bool client_sensor_record::set_option(sensor_id_t sensor_id, int option)
+bool client_sensor_record::set_pause_policy(sensor_id_t sensor_id, int pause_policy)
{
auto it_usage = m_sensor_usages.find(sensor_id);
if (it_usage == m_sensor_usages.end()) {
sensor_usage usage;
- usage.m_option = option;
+ usage.m_pause_policy = pause_policy;
m_sensor_usages.insert(pair<sensor_id_t, sensor_usage>(sensor_id, usage));
} else {
- it_usage->second.m_option = option;
+ it_usage->second.m_pause_policy = pause_policy;
}
return true;
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_pause_policy(sensor_id_t sensor_id, int pause_policy);
bool set_start(sensor_id_t sensor_id, bool start);
bool is_started(sensor_id_t sensor_id);
m_cmd_handlers[CMD_STOP] = &command_worker::cmd_stop;
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_PAUSE_POLICY] = &command_worker::cmd_set_pause_policy;
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;
return true;
}
-bool command_worker::cmd_set_option(void *payload)
+bool command_worker::cmd_set_pause_policy(void *payload)
{
- cmd_set_option_t *cmd;
+ cmd_set_pause_policy_t *cmd;
long ret_value = OP_ERROR;
- cmd = (cmd_set_option_t*)payload;
+ cmd = (cmd_set_pause_policy_t*)payload;
if (!is_permission_allowed()) {
- _E("Permission denied to set interval for client [%d], for sensor [%#llx] with option [%d] to client info manager",
- m_client_id, m_sensor_id, cmd->option);
+ _E("Permission denied to set interval for client [%d], for sensor [%#llx] with pause_policy [%d] to client info manager",
+ m_client_id, m_sensor_id, cmd->pause_policy);
ret_value = OP_ERROR;
goto out;
}
- if (!get_client_info_manager().set_option(m_client_id, m_sensor_id, cmd->option)) {
- _E("Failed to set option for client [%d], for sensor [%#llx] with option [%d] to client info manager",
- m_client_id, m_sensor_id, cmd->option);
+ if (!get_client_info_manager().set_pause_policy(m_client_id, m_sensor_id, cmd->pause_policy)) {
+ _E("Failed to set pause_policy for client [%d], for sensor [%#llx] with pause_policy [%d] to client info manager",
+ m_client_id, m_sensor_id, cmd->pause_policy);
ret_value = OP_ERROR;
goto out;
}
bool cmd_unregister_event(void *payload);
bool cmd_set_batch(void *payload);
bool cmd_unset_batch(void *payload);
- bool cmd_set_option(void *payload);
+ bool cmd_set_pause_policy(void *payload);
bool cmd_get_data(void *payload);
bool cmd_set_attribute_int(void *payload);
bool cmd_set_attribute_str(void *payload);
sensor_usage::sensor_usage()
: m_interval(POLL_1HZ_MS)
, m_latency(0)
-, m_option(SENSOR_OPTION_DEFAULT)
+, m_pause_policy(SENSORD_PAUSE_ALL)
, m_start(false)
{
}
public:
unsigned int m_interval;
unsigned int m_latency;
- int m_option;
+ int m_pause_policy;
reg_event_vector m_reg_events;
bool m_start;
CMD_STOP,
CMD_REG,
CMD_UNREG,
- CMD_SET_OPTION,
+ CMD_SET_PAUSE_POLICY,
CMD_SET_BATCH,
CMD_UNSET_BATCH,
CMD_GET_DATA,
} cmd_unset_batch_t;
typedef struct {
- int option;
-} cmd_set_option_t;
+ int pause_policy;
+} cmd_set_pause_policy_t;
typedef struct {
int attribute;