static int ss_flag = 0;
static history_item_s *data_obj = NULL;
-static int listener_hsp =0;
-static int bt_hsp=0;
-static int bt_connected_hsp=0;
-static int bt_scan_hsp=0;
-static int bt_flag =0;
-static int wifi_flag =0;
-static int wifi_hsp=0;
-static int wifi_scan_hsp=0;
-static int wifi_connected_hsp=0;
-static int display_hsp=0;
-static int gps_hsp=0;
-static int charging_hsp=0;
+static int listener_hsp = 0;
+static int bt_hsp = 0;
+static int bt_connected_hsp = 0;
+static int bt_scan_hsp = 0;
+static int bt_discovery_state = 0;
+static int bt_flag = 0;
+static int wifi_flag = 0;
+static int wifi_hsp = 0;
+static int wifi_scan_hsp = 0;
+static int wifi_connected_hsp = 0;
+static int display_hsp = 0;
+static int gps_hsp = 0;
+static int charging_hsp = 0;
static event_pool events_buf[10];
static int buff_count = 0;
static pthread_cond_t fill = PTHREAD_COND_INITIALIZER;
int battery_level;
ret_val = device_battery_get_percent(&battery_level);
- if(ret_val != BATTERY_MONITOR_ERROR_NONE)
- {
+ if (ret_val != BATTERY_MONITOR_ERROR_NONE) {
_ERR("Failed to get battery percentage (%d)", ret_val);
return -1;
}
device_battery_status_e battery_status;
ret_val = device_battery_get_status(&battery_status);
- if(ret_val != BATTERY_MONITOR_ERROR_NONE)
- {
+ if (ret_val != BATTERY_MONITOR_ERROR_NONE) {
_ERR("Failed to get battery status (%d)", ret_val);
return -1;
}
device_battery_health_e health;
BD_BHLT_IDX bm_health;
ret_val = device_battery_get_health(&health);
- if(ret_val != BATTERY_MONITOR_ERROR_NONE)
- {
+ if (ret_val != BATTERY_MONITOR_ERROR_NONE) {
_ERR("Failed to get battery health (%d)", ret_val);
return -1;
}
device_battery_power_source_e source;
ret_val = device_battery_get_power_source(&source);
- if(ret_val != BATTERY_MONITOR_ERROR_NONE)
- {
+ if (ret_val != BATTERY_MONITOR_ERROR_NONE) {
_ERR("Failed to get battery percentage (%d)", ret_val);
return -1;
}
- BD_BPLT_IDX bm_plugtype =BD_BPLT_NONE;
+ BD_BPLT_IDX bm_plugtype = BD_BPLT_NONE;
if (source == DEVICE_BATTERY_POWER_SOURCE_AC)
bm_plugtype = BD_BPLT_AC;
else if (source == DEVICE_BATTERY_POWER_SOURCE_USB)
ENTER;
device_battery_property_e property;
- int val,ret;
+ int val, ret;
/* get the battery voltage*/
property = DEVICE_BATTERY_PROPERTY_VOLTAGE_NOW;
ret = device_battery_get_property(property, &val);
if (ret != BATTERY_MONITOR_ERROR_NONE) {
- _ERR("Failed to get battery voltage (%d)", ret); //LCOV_EXCL_LINE Logs
+ _ERR("Failed to get battery voltage (%d)", ret);
return ret;
}
ts->battery_voltage = val;
property = DEVICE_BATTERY_PROPERTY_TEMPERATURE;
ret = device_battery_get_property(property, &val);
if (ret != BATTERY_MONITOR_ERROR_NONE) {
- _ERR("Failed to get battery temperature (%d)", ret); //LCOV_EXCL_LINE Logs
+ _ERR("Failed to get battery temperature (%d)", ret);
return ret;
}
ts->battery_temperature = val;
{
ENTER;
- _INFO("state: %s",(adapter_state == BT_ADAPTER_ENABLED) ?"ENABLED" : "DISABLED");
+ _INFO("state: %s", (adapter_state == BT_ADAPTER_ENABLED) ? "ENABLED" : "DISABLED");
int bt_state ;
- if(adapter_state == BT_ADAPTER_ENABLED)
- bt_state =1;
+ if (adapter_state == BT_ADAPTER_ENABLED)
+ bt_state = 1;
else
- bt_state=0;
+ bt_state = 0;
_INFO("__bm_bt_adapter_state_changed_cb bt_state = %d ", bt_state);
- if(data_obj)
- {
- if(adapter_state == BT_ADAPTER_ENABLED)
- {
+ if (data_obj) {
+ if (adapter_state == BT_ADAPTER_ENABLED) {
data_obj->event_code = ET_NONE;
data_obj->event_code |= ET_ACTIVE;
data_obj->event_code |= ET_FLAG_START;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
+ if (data_obj->event_tag) {
listener_hsp++;
bt_hsp = listener_hsp;
_INFO("event Tag creation succeeded \n");
data_obj->event_tag->sp_idx = bt_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
return;
}
data_obj->state_2 |= ST2_BLUETOOTH_ON_FLAG;
- }
- else
- {
+ } else {
data_obj->event_code = ET_NONE;
data_obj->event_code |= ET_ACTIVE;
data_obj->event_code |= ET_FLAG_FINISH;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
+ if (data_obj->event_tag) {
_INFO("event Tag creation succeeded \n");
data_obj->event_tag->sp_idx = bt_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
return ;
}
}
EXIT;
- return ;
+ return;
_INFO("__bt_adapter_state_changed_cb");
_INFO(" discovery_state = %d", discovery_state);
- if(data_obj)
- {
+ if (data_obj) {
switch (discovery_state) {
case BT_ADAPTER_DEVICE_DISCOVERY_STARTED:
data_obj->event_code = ET_NONE;
data_obj->event_code |= ET_FLAG_START;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
- if(!bt_flag)
- {
+ if (data_obj->event_tag) {
+ if (!bt_flag) {
listener_hsp++;
bt_scan_hsp = listener_hsp;
- bt_flag =1;
+ bt_flag = 1;
}
_INFO("event Tag creation succeeded \n");
data_obj->event_tag->sp_idx = bt_scan_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
return ;
}
data_obj->event_code |= ET_FLAG_FINISH;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
+ if (data_obj->event_tag) {
_INFO("event Tag creation succeeded \n");
data_obj->event_tag->sp_idx = bt_scan_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
return ;
}
data_obj->state_2 &= ~(ST2_BLUETOOTH_SCAN_FLAG);
- bt_flag =0;
+ bt_flag = 0;
break;
default:
return;
_INFO("__bt_device_connection_state_changed_cb [%d]", connected);
if (!connected)
- {
_INFO("bt is disconnected");
- }
- if(data_obj)
- {
- if(connected)
- {
+ if (data_obj) {
+ if (connected) {
data_obj->event_code = ET_NONE;
data_obj->event_code |= ET_CONNECTIVITY_CHANGED ;
data_obj->event_code |= ET_FLAG_START;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
+ if (data_obj->event_tag) {
listener_hsp++;
bt_connected_hsp = listener_hsp;
_INFO("event Tag creation succeeded \n");
data_obj->event_tag->sp_idx = bt_connected_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
- return ;
+ return;
}
- }
- else
- {
+ } else {
data_obj->event_code = ET_NONE;
data_obj->event_code |= ET_CONNECTIVITY_CHANGED;
data_obj->event_code |= ET_FLAG_FINISH;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
+ if (data_obj->event_tag) {
_INFO("event Tag creation succeeded \n");
data_obj->event_tag->sp_idx = bt_connected_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
- return ;
+ return;
}
}
}
else
_INFO(", state : Deactivated\n");
- if(data_obj)
- {
- if(state == WIFI_MANAGER_DEVICE_STATE_ACTIVATED)
- {
+ if (data_obj) {
+ if (state == WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
data_obj->event_code = ET_NONE;
data_obj->event_code |= ET_FLAG_START;
data_obj->event_code |= ET_CONNECTIVITY_CHANGED;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
+ if (data_obj->event_tag) {
listener_hsp++;
wifi_hsp = listener_hsp;
_INFO("event Tag creation succeeded \n");
data_obj->event_tag->sp_idx = wifi_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
return ;
}
data_obj->state_2 |= ST2_WIFI_ON_FLAG;
- }
- else
- {
+ } else {
data_obj->event_code = ET_NONE;
data_obj->event_code |= ET_FLAG_FINISH;
data_obj->event_code |= ET_CONNECTIVITY_CHANGED;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
+ if (data_obj->event_tag) {
_INFO("event Tag creation succeeded \n");
data_obj->event_tag->sp_idx = wifi_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
return ;
}
_INFO("Wifi Scan changed, scan state : %d\n", state);
- if(data_obj)
- {
- if(state == WIFI_MANAGER_SCAN_STATE_SCANNING)
- {
+ if (data_obj) {
+ if (state == WIFI_MANAGER_SCAN_STATE_SCANNING) {
data_obj->event_code = ET_NONE;
data_obj->event_code |= ET_FLAG_START;
data_obj->event_code |= ET_CONNECTIVITY_CHANGED;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
- if(!wifi_flag)
- {
+ if (data_obj->event_tag) {
+ if (!wifi_flag) {
listener_hsp++;
wifi_scan_hsp = listener_hsp;
- wifi_flag =1;
+ wifi_flag = 1;
}
_INFO("event Tag creation succeeded \n");
data_obj->event_tag->sp_idx = wifi_scan_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
return ;
}
data_obj->state_1 |= ST1_WIFI_SCAN_FLAG;
- }
- else
- {
+ } else {
data_obj->event_code = ET_NONE;
data_obj->event_code |= ET_FLAG_FINISH;
data_obj->event_code |= ET_CONNECTIVITY_CHANGED;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
+ if (data_obj->event_tag) {
_INFO("event Tag creation succeeded \n");
data_obj->event_tag->sp_idx = wifi_scan_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
return ;
}
data_obj->state_1 &= ~(ST1_WIFI_SCAN_FLAG);
- wifi_flag =0;
+ wifi_flag = 0;
}
}
_INFO("Wifi Connection changed, connection state : %d\n", state);
- if(data_obj)
- {
+ if (data_obj) {
switch (state) {
case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
data_obj->event_code = ET_NONE;
data_obj->event_code |= ET_FLAG_START;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
+ if (data_obj->event_tag) {
_INFO("event Tag creation succeeded \n");
listener_hsp++;
wifi_connected_hsp = listener_hsp;
data_obj->event_tag->sp_idx = wifi_connected_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
return ;
}
data_obj->event_code |= ET_FLAG_FINISH;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
+ if (data_obj->event_tag) {
_INFO("event Tag creation succeeded \n");
data_obj->event_tag->sp_idx = wifi_connected_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
return ;
}
data_obj->event_code |= ET_FLAG_START;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
+ if (data_obj->event_tag) {
listener_hsp++;
display_hsp = listener_hsp;
_INFO("event Tag creation succeeded \n");
data_obj->event_tag->sp_idx = display_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
return ;
}
data_obj->event_code = ET_NONE;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
+ if (data_obj->event_tag) {
_INFO("event Tag creation succeeded \n");
data_obj->event_tag->sp_idx = display_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
return ;
}
data_obj->event_code |= ET_FLAG_FINISH;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
+ if (data_obj->event_tag) {
_INFO("event Tag creation succeeded \n");
data_obj->event_tag->sp_idx = display_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
return ;
}
{
ENTER;
- _INFO(" device brightness changed =%d ",brightness_level);
- if(data_obj)
- {
+ _INFO(" device brightness changed =%d ", brightness_level);
+ if (data_obj) {
data_obj->state_1 &= ~brightness_val;
brightness_val = brightness_level;
data_obj->state_1 |= brightness_val;
{
ENTER;
- _INFO(" device battery_capacity changed =%d ",charging_level);
- if(data_obj)
- {
+ _INFO(" device battery_capacity changed =%d ", charging_level);
+ if (data_obj) {
data_obj->event_code = ET_NONE;
data_obj->event_tag = NULL;
}
{
ENTER;
- _INFO(" device charging_status changed =%d ",charging);
- if(data_obj)
- {
- if(charging)
- {
+ _INFO(" device charging_status changed =%d ", charging);
+ if (data_obj) {
+ if (charging) {
data_obj->event_code = ET_NONE;
data_obj->event_code |= ET_FLAG_START;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
+ if (data_obj->event_tag) {
listener_hsp++;
charging_hsp = listener_hsp;
_INFO("event Tag creation succeeded \n");
data_obj->event_tag->sp_idx = charging_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
return;
}
data_obj->state_2 |= ST2_CHARGING_FLAG;
- }
- else
- {
+ } else {
data_obj->event_code = ET_NONE;
data_obj->event_code |= ET_FLAG_FINISH;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
+ if (data_obj->event_tag) {
_INFO("event Tag creation succeeded \n");
data_obj->event_tag->sp_idx = charging_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
return ;
}
{
ENTER;
- _INFO(" device signal_strength changed =%d ",ss);
- if(data_obj)
- {
+ _INFO(" device signal_strength changed =%d ", ss);
+ if (data_obj) {
data_obj->state_1 &= ~ss_val << ST1_PHONE_SIGNAL_STRENGTH_SHIFT;
ss_val = ss;
data_obj->state_1 |= ss_val << ST1_PHONE_SIGNAL_STRENGTH_SHIFT;
{
ENTER;
- _INFO(" maps location changed =%d ",gps);
- if(data_obj)
- {
- if(gps)
- {
+ _INFO(" maps location changed =%d ", gps);
+ if (data_obj) {
+ if (gps) {
data_obj->event_code = ET_NONE;
data_obj->event_code |= ET_ACTIVE;
data_obj->event_code |= ET_FLAG_START;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
+ if (data_obj->event_tag) {
listener_hsp++;
gps_hsp = listener_hsp;
_INFO("event Tag creation succeeded \n");
data_obj->event_tag->sp_idx = gps_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
return;
}
data_obj->state_1 |= ST1_GPS_ON_FLAG;
- }
- else
- {
+ } else {
data_obj->event_code = ET_NONE;
data_obj->event_code |= ET_ACTIVE;
data_obj->event_code |= ET_FLAG_FINISH;
data_obj->event_tag = NULL;
data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s));
- if(data_obj->event_tag)
- {
+ if (data_obj->event_tag) {
_INFO("event Tag creation succeeded \n");
data_obj->event_tag->sp_idx = gps_hsp;
- }
- else
- {
+ } else {
_ERR(" data_obj->event_tag object creation fails ");
return ;
}
-static void bm_create_event_data(int type,int val)
+static void bm_create_event_data(int type, int val)
{
ENTER;
- if(!data_obj)
+ if (!data_obj)
return;
- switch(type) {
+ switch (type) {
case LISTEN_BT_STATE:
fill_bt_adapter_state_changed_data(val);
break;
data_obj->time_s = ((long long)tv.tv_sec * 1000) + ((long long)tv.tv_usec / 1000);
data_obj->battery_level = bm_battery_level_listener();
- if(data_obj->battery_level < 0)
- {
+ if (data_obj->battery_level < 0) {
_ERR("Failed to get ts->battery_level = %d ", data_obj->battery_level);
return;
}
data_obj->battery_status = bm_battery_status_listener();
- if(data_obj->battery_status < 0)
- {
+ if (data_obj->battery_status < 0) {
_ERR("Failed to get ts->battery_status = %d ", data_obj->battery_status);
return;
}
data_obj->battery_health = bm_battery_health_listener();
- if(data_obj->battery_health < 0)
- {
+ if (data_obj->battery_health < 0) {
_ERR("Failed to get ts->battery_health = %d ", data_obj->battery_health);
return;
}
data_obj->battery_plugtype = bm_battery_plugtype_listener();
- if(data_obj->battery_plugtype < 0)
- {
- _ERR("Failed to get ts->battery_plugtype = %d ", data_obj->battery_plugtype);
- return;
- }
+ if (data_obj->battery_plugtype < 0)
+ _WARN("Failed to get ts->battery_plugtype = %d ", data_obj->battery_plugtype);
- _INFO("battery_level = %d , battery_status = %d , battery_health = %d , battery_plugtype = %d ", data_obj->battery_level , data_obj->battery_status ,data_obj->battery_health, data_obj->battery_plugtype);
+ _INFO("battery_level = %d , battery_status = %d , battery_health = %d , battery_plugtype = %d ", data_obj->battery_level , data_obj->battery_status , data_obj->battery_health, data_obj->battery_plugtype);
int ret = bm_battery_voltage_temperature_charge_listener(data_obj);
- if(ret != BATTERY_MONITOR_ERROR_NONE)
- {
+ if (ret != BATTERY_MONITOR_ERROR_NONE) {
_ERR("bm_battery_voltage_temperature_charge_listener failed ");
return;
- }
- else
- _INFO("battery_voltage = %d ,battery_temperature = %d ,battery_charge = %d ", data_obj->battery_voltage , data_obj->battery_temperature ,data_obj->battery_charge);
+ } else
+ _INFO("battery_voltage = %d ,battery_temperature = %d ,battery_charge = %d ", data_obj->battery_voltage , data_obj->battery_temperature , data_obj->battery_charge);
- if(data_obj->event_tag){
+ if (data_obj->event_tag) {
data_obj->event_tag->uid = 1000 ;
data_obj->event_tag->string_info = g_string_sized_new(30);
- if(!data_obj->event_tag->string_info)
- {
+ if (!data_obj->event_tag->string_info) {
_ERR("memory allocation failed ");
return;
}
g_string_append(data_obj->event_tag->string_info, "Tizen");
_DBG("Data Value of listener event uid : %d ", data_obj->event_tag->uid);
- _DBG("Data Value of listener event string : %s , sp index =%d", data_obj->event_tag->string_info->str,data_obj->event_tag->sp_idx);
+ _DBG("Data Value of listener event string : %s , sp index =%d", data_obj->event_tag->string_info->str, data_obj->event_tag->sp_idx);
}
data_obj->wakelock_tag = NULL;
data_obj->wakereason_tag = NULL;
- if(bd_store_history_item(data_obj) !=BATTERY_MONITOR_ERROR_NONE)
- {
+ if (bd_store_history_item(data_obj) != BATTERY_MONITOR_ERROR_NONE) {
_ERR("Failed to store history items ");
return;
}
{
ENTER;
event_pool *event = (event_pool*) data;
- if(event == NULL)
+ if (event == NULL)
return NULL;
pthread_mutex_lock(&battery_lister_mutex);
ENTER;
_INFO("__bt_adapter_state_changed_cb");
_INFO("result: %d", result);
- _INFO("state: %s",(adapter_state == BT_ADAPTER_ENABLED) ?"ENABLED" : "DISABLED");
+ _INFO("state: %s", (adapter_state == BT_ADAPTER_ENABLED) ? "ENABLED" : "DISABLED");
int bt_state ;
- if(adapter_state == BT_ADAPTER_ENABLED)
- bt_state =1;
+ if (adapter_state == BT_ADAPTER_ENABLED)
+ bt_state = 1;
else
- bt_state=0;
+ bt_state = 0;
_INFO("__bm_bt_adapter_state_changed_cb bt_state = %d ", bt_state);
_INFO("buff_count: %d and fill_ptr = %d", buff_count , fill_ptr);
event_pool *bt_event = (event_pool *)calloc(1, sizeof(event_pool));
- if(!bt_event)
- {
+ if (!bt_event) {
_ERR("Failed to allocated memory ");
return;
}
bt_event->val = bt_state;
pthread_t producer ;
- if(pthread_create(&producer, NULL, event_producer, bt_event))
- {
+ if (pthread_create(&producer, NULL, event_producer, bt_event)) {
_ERR("Failed to pthread_create.");
return;
}
_INFO("address [%s]", conn_info->remote_address);
_INFO("link type [%d]", conn_info->link);
if (!connected)
- {
_INFO("disconnection reason [%d]", conn_info->disconn_reason);
- }
event_pool *bt_event = (event_pool *)calloc(1, sizeof(event_pool));
- if(!bt_event)
- {
+ if (!bt_event) {
_ERR("Failed to allocated memory ");
return;
}
bt_event->val = connected;
pthread_t producer ;
- if(pthread_create(&producer, NULL, event_producer, bt_event))
- {
+ if (pthread_create(&producer, NULL, event_producer, bt_event)) {
_ERR("Failed to pthread_create.");
return;
}
bt_adapter_device_discovery_info_s *discovery_info,
void *user_data)
{
-
ENTER;
_INFO("__bt_adapter_state_changed_cb");
_INFO("result: %d , discovery_state = %d", result, discovery_state);
- if(discovery_state > 1)
- {
+ if (discovery_state > 1) {
_INFO(" This state will be handled later");
return;
}
+ if (bt_discovery_state == discovery_state) {
+ _INFO(" state is same as last state, didnt changed");
+ return;
+ } else {
+ bt_discovery_state = discovery_state;
+ }
event_pool *bt_event = (event_pool *)calloc(1, sizeof(event_pool));
- if(!bt_event)
- {
+ if (!bt_event) {
_ERR("Failed to allocated memory ");
return;
}
bt_event->type = LISTEN_BT_SCAN_STATE;
bt_event->val = discovery_state;
pthread_t producer ;
- if(pthread_create(&producer, NULL, event_producer, bt_event))
- {
+ if (pthread_create(&producer, NULL, event_producer, bt_event)) {
_ERR("Failed to pthread_create.");
return;
}
_INFO(", state : Deactivated\n");
event_pool *wifi_event = (event_pool *)calloc(1, sizeof(event_pool));
- if(!wifi_event)
- {
+ if (!wifi_event) {
_ERR("Failed to allocated memory ");
return;
}
wifi_event->val = state;
pthread_t producer ;
- if(pthread_create(&producer, NULL, event_producer, wifi_event))
- {
+ if (pthread_create(&producer, NULL, event_producer, wifi_event)) {
_ERR("Failed to pthread_create.");
return;
}
_INFO("Wifi Scan changed, scan state : %d\n", state);
event_pool *wifi_event = (event_pool *)calloc(1, sizeof(event_pool));
- if(!wifi_event)
- {
+ if (!wifi_event) {
_ERR("Failed to allocated memory ");
return;
}
wifi_event->val = state;
pthread_t producer ;
- if(pthread_create(&producer, NULL, event_producer, wifi_event))
- {
+ if (pthread_create(&producer, NULL, event_producer, wifi_event)) {
_ERR("Failed to pthread_create.");
return;
}
ENTER;
_INFO("Wifi Connection changed, new connection state : %d\n", state);
- if(state == -1 || state == 1 || state == 2)
- {
- _ERR("These connection states are not related ");
+ if (state == -1 || state == 1 || state == 2) {
+ _WARN("These connection states are not related ");
return;
}
event_pool *wifi_event = (event_pool *)calloc(1, sizeof(event_pool));
- if(!wifi_event)
- {
+ if (!wifi_event) {
_ERR("Failed to allocated memory ");
return;
}
wifi_event->val = state;
pthread_t producer ;
- if(pthread_create(&producer, NULL, event_producer, wifi_event))
- {
+ if (pthread_create(&producer, NULL, event_producer, wifi_event)) {
_ERR("Failed to pthread_create.");
return;
}
display_state_e state = (display_state_e)value;
event_pool *device_event = (event_pool *)calloc(1, sizeof(event_pool));
- if(!device_event)
- {
+ if (!device_event) {
_ERR("Failed to allocated memory ");
return;
}
device_event->val = state;
pthread_t producer ;
- if(pthread_create(&producer, NULL, event_producer, device_event))
- {
+ if (pthread_create(&producer, NULL, event_producer, device_event)) {
_ERR("Failed to pthread_create.");
return;
}
{
ENTER;
_INFO("device brightness changed succeeded\n");
- int brightness_level =0;
+ int brightness_level = 0;
vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness_level);
int flag;
- if(brightness_level >0 && brightness_level <=10)
- {
+ if (brightness_level > 0 && brightness_level <= 10) {
flag = 0;
- if(brightness_flag == flag)
+ if (brightness_flag == flag)
return;
else
brightness_flag = flag;
- }
- else if(brightness_level >10 && brightness_level <=25)
- {
+ } else if (brightness_level > 10 && brightness_level <= 25) {
flag = 1;
- if(brightness_flag == flag)
+ if (brightness_flag == flag)
return;
else
brightness_flag = flag;
- }
- else if(brightness_level >25 && brightness_level <=50)
- {
+ } else if (brightness_level > 25 && brightness_level <= 50) {
flag = 2;
- if(brightness_flag == flag)
+ if (brightness_flag == flag)
return;
else
brightness_flag = flag;
- }
- else if(brightness_level >50 && brightness_level <=75)
- {
+ } else if (brightness_level > 50 && brightness_level <= 75) {
flag = 3;
- if(brightness_flag == flag)
+ if (brightness_flag == flag)
return;
else
brightness_flag = flag;
- }
- else if(brightness_level >75 && brightness_level <=100)
- {
+ } else if (brightness_level > 75 && brightness_level <= 100) {
flag = 4;
- if(brightness_flag == flag)
+ if (brightness_flag == flag)
return;
else
brightness_flag = flag;
}
- _INFO(" device brightness changed =%d ",brightness_level);
+ _INFO(" device brightness changed =%d ", brightness_level);
event_pool *display_event = (event_pool *)calloc(1, sizeof(event_pool));
- if(!display_event)
- {
+ if (!display_event) {
_ERR("Failed to allocated memory ");
return;
}
pthread_t producer ;
- if(pthread_create(&producer, NULL, event_producer, display_event))
- {
+ if (pthread_create(&producer, NULL, event_producer, display_event)) {
_ERR("Failed to pthread_create.");
return;
}
{
ENTER;
_INFO("device battery_capacity changed succeeded\n");
- int charging =0;
+ int charging = 0;
vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, &charging);
- _INFO(" device battery_capacity changed =%d ",charging);
+ _INFO(" device battery_capacity changed =%d ", charging);
event_pool *charging_event = (event_pool *)calloc(1, sizeof(event_pool));
- if(!charging_event)
- {
+ if (!charging_event) {
_ERR("Failed to allocated memory ");
return;
}
pthread_t producer ;
- if(pthread_create(&producer, NULL, event_producer, charging_event))
- {
+ if (pthread_create(&producer, NULL, event_producer, charging_event)) {
_ERR("Failed to pthread_create.");
return;
}
{
ENTER;
_INFO("device charging_status changed succeeded\n");
- int charging =0;
+ int charging = 0;
vconf_get_int(VCONFKEY_SYSMAN_CHARGER_STATUS, &charging);
- _INFO(" device charging_status changed =%d ",charging);
+ _INFO(" device charging_status changed =%d ", charging);
event_pool *charging_event = (event_pool *)calloc(1, sizeof(event_pool));
- if(!charging_event)
- {
+ if (!charging_event) {
_ERR("Failed to allocated memory ");
return;
}
pthread_t producer ;
- if(pthread_create(&producer, NULL, event_producer, charging_event))
- {
+ if (pthread_create(&producer, NULL, event_producer, charging_event)) {
_ERR("Failed to pthread_create.");
return;
}
{
ENTER;
_INFO("device location changed succeeded\n");
- int charging =0;
+ int charging = 0;
vconf_get_int(VCONFKEY_LOCATION_ENABLED, &charging);
- _INFO(" device location changed =%d ",charging);
+ _INFO(" device location changed =%d ", charging);
event_pool *location_event = (event_pool *)calloc(1, sizeof(event_pool));
- if(!location_event)
- {
+ if (!location_event) {
_ERR("Failed to allocated memory ");
return;
}
pthread_t producer ;
- if(pthread_create(&producer, NULL, event_producer, location_event))
- {
+ if (pthread_create(&producer, NULL, event_producer, location_event)) {
_ERR("Failed to pthread_create.");
return;
}
struct tel_noti_network_signal_strength *noti = data;
int sig_strength = noti->dbm;
- _INFO(" device signal strength changed =%d ",sig_strength);
+ _INFO(" device signal strength changed =%d ", sig_strength);
int flag;
- if(sig_strength >0 && sig_strength <=12)
- {
+ if (sig_strength >= 0 && sig_strength <= 12) {
flag = 0;
- if(ss_flag == flag)
+ if (ss_flag == flag)
return;
else
ss_flag = flag;
- }
- else if(sig_strength >12 && sig_strength <=25)
- {
+ } else if (sig_strength > 12 && sig_strength <= 25) {
flag = 1;
- if(ss_flag == flag)
+ if (ss_flag == flag)
return;
else
ss_flag = flag;
- }
- else if(sig_strength >25 && sig_strength <=37)
- {
+ } else if (sig_strength > 25 && sig_strength <= 37) {
flag = 2;
- if(ss_flag == flag)
+ if (ss_flag == flag)
return;
else
ss_flag = flag;
- }
- else if(sig_strength >37 && sig_strength <=50)
- {
+ } else if (sig_strength > 37 && sig_strength <= 50) {
flag = 3;
- if(ss_flag == flag)
+ if (ss_flag == flag)
return;
else
ss_flag = flag;
- }
- else if(sig_strength >50 && sig_strength <=62)
- {
+ } else if (sig_strength > 50 && sig_strength <= 62) {
flag = 4;
- if(ss_flag == flag)
+ if (ss_flag == flag)
return;
else
ss_flag = flag;
- }
- else if(sig_strength >62 && sig_strength <=75)
- {
+ } else if (sig_strength > 62 && sig_strength <= 75) {
flag = 5;
- if(ss_flag == flag)
+ if (ss_flag == flag)
return;
else
ss_flag = flag;
- }
- else if(sig_strength >75 && sig_strength <=87)
- {
+ } else if (sig_strength > 75 && sig_strength <= 87) {
flag = 6;
- if(ss_flag == flag)
+ if (ss_flag == flag)
return;
else
ss_flag = flag;
- }
- else if(sig_strength >87 && sig_strength <=100)
- {
+ } else if (sig_strength > 87 && sig_strength <= 100) {
flag = 7;
- if(ss_flag == flag)
+ if (ss_flag == flag)
return;
else
ss_flag = flag;
}
event_pool *signal_event = (event_pool *)calloc(1, sizeof(event_pool));
- if(!signal_event)
- {
+ if (!signal_event) {
_ERR("Failed to allocated memory ");
return;
}
pthread_t producer ;
- if(pthread_create(&producer, NULL, event_producer, signal_event))
- {
+ if (pthread_create(&producer, NULL, event_producer, signal_event)) {
_ERR("Failed to pthread_create.");
return;
}
int ret = 0;
ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS, __bm_charging_status_change, NULL);
if (ret != 0) {
- _ERR("failed to register a cb key:%s err:%d","VCONFKEY_SYSMAN_CHARGER_STATUS", ret);
+ _ERR("failed to register a cb key:%s err:%d", "VCONFKEY_SYSMAN_CHARGER_STATUS", ret);
return 1;
}
int ret = 0;
ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, __bm_battery_capacity_change, NULL);
if (ret != 0) {
- _ERR("failed to register a cb key:%s err:%d","VCONFKEY_SYSMAN_BATTERY_CAPACITY", ret);
+ _ERR("failed to register a cb key:%s err:%d", "VCONFKEY_SYSMAN_BATTERY_CAPACITY", ret);
return 1;
}
EXIT;
return 0;
-
}
int ret = 0;
ret = vconf_notify_key_changed(VCONFKEY_LOCATION_ENABLED, __bm_location_change, NULL);
if (ret != 0) {
- _ERR("failed to register a cb key:%s err:%d","VCONFKEY_LOCATION_ENABLED", ret);
+ _ERR("failed to register a cb key:%s err:%d", "VCONFKEY_LOCATION_ENABLED", ret);
return 1;
}
EXIT;
return 0;
-
}
EXIT;
return 0;
-
}
ENTER;
/* Screen callbacks */
handle = tel_init(NULL);
- if(handle)
- {
- int ret = tel_register_noti_event(handle,TAPI_NOTI_NETWORK_SIGNALSTRENGTH, __bm_noti_signal_strength, NULL);
+ if (handle) {
+ int ret = tel_register_noti_event(handle, TAPI_NOTI_NETWORK_SIGNALSTRENGTH, __bm_noti_signal_strength, NULL);
if (ret != BATTERY_MONITOR_ERROR_NONE) {
_ERR("device_add_callback failed: %s", get_error_message(ret));
return 1;
EXIT;
return 0;
-
}
int ret = 0;
ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, __bm_display_brightness_change, NULL);
if (ret != 0) {
- _ERR("failed to register a cb key:%s err:%d","VCONFKEY_SETAPPL_LCD_BRIGHTNESS", ret);
+ _ERR("failed to register a cb key:%s err:%d", "VCONFKEY_SETAPPL_LCD_BRIGHTNESS", ret);
return 1;
}
/* Wifi callbacks */
int rv = wifi_manager_initialize(&wifi);
- if (rv == WIFI_MANAGER_ERROR_NONE)
- {
+ if (rv == WIFI_MANAGER_ERROR_NONE) {
int ret = wifi_manager_set_device_state_changed_cb(wifi, __bm_wifi_device_state_callback, NULL);
- if (ret == WIFI_MANAGER_ERROR_NONE) {
- _INFO("wifi_manager_set_device_state_changed_cb success : [%p]\n",__bm_wifi_device_state_callback);
- }
+ if (ret == WIFI_MANAGER_ERROR_NONE)
+ _INFO("wifi_manager_set_device_state_changed_cb success : [%p]\n", __bm_wifi_device_state_callback);
else
- {
_ERR("wifi_manager_set_device_state_changed_cb failed");
- }
ret = wifi_manager_set_scan_state_changed_cb(wifi, __bm_wifi_scan_changed_callback, NULL);
- if (ret == WIFI_MANAGER_ERROR_NONE) {
+ if (ret == WIFI_MANAGER_ERROR_NONE)
_INFO("wifi_manager_set_scan_state_changed_cb success\n");
- } else {
+ else
_ERR("wifi_manager_set_scan_state_changed_cb failed");
- }
ret = wifi_manager_set_connection_state_changed_cb(wifi, __bm_wifi_connection_state_changed_callback, NULL);
- if (ret == WIFI_MANAGER_ERROR_NONE) {
+ if (ret == WIFI_MANAGER_ERROR_NONE)
_INFO("wifi_manager_set_connection_state_changed_cb success\n");
- } else {
+ else
_ERR("wifi_manager_set_scan_state_changed_cb failed");
- }
} else {
_ERR(" Wifi init failed \n");
return 1;
if (rv == BT_ERROR_NONE) {
int ret = bt_device_set_connection_state_changed_cb(__bm_bt_device_connection_state_changed_cb, NULL);
- _INFO("bt_device_set_connection_state_changed_cb ret =%d \n",ret);
+ _INFO("bt_device_set_connection_state_changed_cb ret =%d \n", ret);
ret = bt_adapter_set_state_changed_cb(__bm_bt_adapter_state_changed_cb, NULL);
_INFO("bt_adapter_set_state_changed_cb ret =%d \n", ret);
{
ENTER;
- while(1)
- {
+ while (1) {
pthread_mutex_lock(&battery_lister_mutex);
while (buff_count == 0)
pthread_cond_wait(&fill, &battery_lister_mutex);
bm_create_event_data(events_buf[use_ptr].type, events_buf[use_ptr].val);
- _INFO("type: %d and val = %d", events_buf[use_ptr].type,events_buf[use_ptr].val);
- _INFO("buff_count: %d and fill_ptr = %d , use_ptr = %d", buff_count,fill_ptr,use_ptr);
+ _INFO("type: %d and val = %d", events_buf[use_ptr].type, events_buf[use_ptr].val);
+ _INFO("buff_count: %d and fill_ptr = %d , use_ptr = %d", buff_count, fill_ptr, use_ptr);
use_ptr = (use_ptr + 1) % MAX_BUFF;
buff_count--;
ENTER;
pthread_t consumer;
- if(pthread_create(&consumer, NULL, event_consumer, NULL))
- {
+ if (pthread_create(&consumer, NULL, event_consumer, NULL)) {
_ERR("Failed to pthread_create.");
return BATTERY_MONITOR_ERROR_NOT_SUPPORTED;
}
- if(data_obj != NULL)
- {
- _ERR(" History data object already exits");
+ if (data_obj != NULL) {
+ _WARN(" History data object already exits");
return BATTERY_MONITOR_ERROR_NONE;
}
data_obj = (history_item_s *)calloc(1, sizeof(history_item_s));
- if(data_obj)
- {
+ if (data_obj) {
data_obj->state_1 = 0;
data_obj->state_2 = 0;
data_obj->event_code = ET_NONE;
data_obj->event_tag = NULL;
- }
- else
- {
+ } else {
_ERR(" history_item_s data object creation fails ");
return BATTERY_MONITOR_ERROR_OUT_OF_MEMORY;
}
/* Initialize Hash Table */
- if(!bm_initialize_history_data_obj()) {
+ if (!bm_initialize_history_data_obj()) {
_INFO("bm_initialize_history_data_obj succeeded \n");
- } else {
+ } else {
_ERR("bm_initialize_history_data_obj failed \n");
return BATTERY_MONITOR_ERROR_OUT_OF_MEMORY;
}
/* Wifi callbacks */
- if(!bm_wifi_subscribe_listeners())
+ if (!bm_wifi_subscribe_listeners())
_INFO("Wifi listeners succeeded to subscribed\n");
else
_ERR("Wifi listeners failed to subscribed\n");
/* BlueTooth callbacks */
- if(!bm_bluetooth_subscribe_listeners())
+ if (!bm_bluetooth_subscribe_listeners())
_INFO("bluetooth listeners succeeded to subscribed\n");
else
_ERR("bluetooth listeners failed to subscribed\n");
/* Screen wakeup callbacks */
- if(!bm_screen_subscribe_listeners())
+ if (!bm_screen_subscribe_listeners())
_INFO("Display listeners succeeded to subscribed\n");
else
_ERR("Display listeners failed to subscribed\n");
/* Brightness change callbacks */
- if(!bm_display_brightness_listeners())
+ if (!bm_display_brightness_listeners())
_INFO("Brightness listeners succeeded to subscribed\n");
else
_ERR("Brightness listeners failed to subscribed\n");
/* battery_capacity change callbacks */
- if(!bm_battery_capacity_listeners())
+ if (!bm_battery_capacity_listeners())
_INFO("battery_capacity listeners succeeded to subscribed\n");
else
_ERR("battery_capacity listeners failed to subscribed\n");
/* battery charging change callbacks */
- if(!bm_charging_status_listeners())
+ if (!bm_charging_status_listeners())
_INFO("battery charging listeners succeeded to subscribed\n");
else
_ERR("battery charging listeners failed to subscribed\n");
/* GPS change callbacks */
- if(!bm_location_listeners())
+ if (!bm_location_listeners())
_INFO("location listeners succeeded to subscribed\n");
else
_ERR("location listeners failed to subscribed\n");
/* Signal strength callbacks */
- if(!bm_signal_strength_listeners())
+ if (!bm_signal_strength_listeners())
_INFO("Signal strength listeners succeeded to subscribed\n");
else
_ERR("Signal strength listeners failed to subscribed\n");
if (wifi_manager_unset_connection_state_changed_cb(wifi) != WIFI_MANAGER_ERROR_NONE)
_ERR("wifi_manager_unset_connection_state_changed_cb() failed.\n");
else
- _ERR("wifi_manager_unset_connection_state_changed_cb() success.\n");
+ _INFO("wifi_manager_unset_connection_state_changed_cb() success.\n");
if (wifi_manager_deinitialize(wifi) != WIFI_MANAGER_ERROR_NONE)
_ERR("wifi_manager_deinitialize() failed.\n");
else
- _ERR("wifi_manager_deinitialize() success.\n");
+ _INFO("wifi_manager_deinitialize() success.\n");
/* Bluetooth */
if (bt_device_unset_connection_state_changed_cb() != BT_ERROR_NONE)
_ERR("bt_device_unset_connection_state_changed_cb() failed.\n");
else
- _ERR("bt_device_unset_connection_state_changed_cb() success.\n");
+ _INFO("bt_device_unset_connection_state_changed_cb() success.\n");
/* unset bluetooth adapter changed state event callback*/
if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE)
_ERR("bt_adapter_unset_state_changed_cb() failed.\n");
else
- _ERR("bt_adapter_unset_state_changed_cb() success.\n");
+ _INFO("bt_adapter_unset_state_changed_cb() success.\n");
/* deinit bluetooth api*/
if (bt_deinitialize() != BT_ERROR_NONE)
_ERR("bt_deinitialize() failed.\n");
else
- _ERR("bt_deinitialize() success.\n");
+ _INFO("bt_deinitialize() success.\n");
//Brightness
if (vconf_ignore_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, __bm_display_brightness_change) < 0)
- {
_ERR("failed to de-register vconf callback");
- }
//Battery capacity
if (vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, __bm_battery_capacity_change) < 0)
- {
_ERR("failed to de-register vconf callback");
- }
//Battery charging
if (vconf_ignore_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS, __bm_charging_status_change) < 0)
- {
_ERR("failed to de-register vconf callback");
- }
- if(handle)
- {
- int ret = tel_deregister_noti_event(handle,TAPI_NOTI_NETWORK_SIGNALSTRENGTH);
+ if (handle) {
+ int ret = tel_deregister_noti_event(handle, TAPI_NOTI_NETWORK_SIGNALSTRENGTH);
if (ret != BATTERY_MONITOR_ERROR_NONE) {
_ERR("tel_deregister_noti_event failed: %s", get_error_message(ret));
return 1;
tel_deinit(handle);
}
- if(data_obj)
- {
+ if (data_obj)
BM_FREE(data_obj);
- }
EXIT;
return BATTERY_MONITOR_ERROR_NONE;
}
-
-
-
-
-
-
-