Coding rules related fixes incorporated 86/227386/3
authorkamaljeet chauhan <kamal.jc@samsung.com>
Wed, 11 Mar 2020 13:00:06 +0000 (18:30 +0530)
committerkamaljeet chauhan <kamal.jc@samsung.com>
Fri, 13 Mar 2020 06:14:38 +0000 (11:44 +0530)
Change-Id: Ic2767ffea72412318b0f35c1a6a3b91818d0f304
Signed-off-by: kamaljeet chauhan <kamal.jc@samsung.com>
include/bm_listeners.h
src/battery_dump/bm_listeners.c

index cc9b1b1..e37bf14 100644 (file)
@@ -48,7 +48,7 @@ int bd_initialize_listeners(void);
 
 int bd_deinitialize_listeners();
 
-typedef struct _event_pool{
+typedef struct _event_pool {
        int type;
        int val;
 } event_pool;
index b7e8411..b77ad95 100644 (file)
@@ -35,18 +35,19 @@ static int ss_val = 0;
 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;
@@ -66,8 +67,7 @@ static int bm_battery_level_listener()
 
        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;
        }
@@ -86,8 +86,7 @@ static int bm_battery_status_listener()
 
        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;
        }
@@ -119,8 +118,7 @@ static int bm_battery_health_listener()
        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;
        }
@@ -153,14 +151,13 @@ static int bm_battery_plugtype_listener()
 
        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)
@@ -179,14 +176,14 @@ static int bm_battery_voltage_temperature_charge_listener(history_item_s *ts)
        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;
@@ -196,7 +193,7 @@ static int bm_battery_voltage_temperature_charge_listener(history_item_s *ts)
                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;
@@ -222,54 +219,44 @@ static void fill_bt_adapter_state_changed_data(int adapter_state)
 {
        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 ;
                        }
@@ -279,7 +266,7 @@ static void fill_bt_adapter_state_changed_data(int adapter_state)
        }
 
        EXIT;
-       return ;
+       return;
 
 
 
@@ -296,8 +283,7 @@ static void fill_bt_device_discovery_state_changed_data(int discovery_state)
        _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;
@@ -305,19 +291,15 @@ static void fill_bt_device_discovery_state_changed_data(int discovery_state)
                        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 ;
                        }
@@ -330,18 +312,15 @@ static void fill_bt_device_discovery_state_changed_data(int discovery_state)
                        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;
@@ -362,49 +341,37 @@ static void fill_bt_device_connection_state_changed_data(int connected)
 
        _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;
                        }
                }
        }
@@ -424,43 +391,33 @@ static void fill_wifi_device_state_data(int state)
        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 ;
                        }
@@ -482,52 +439,41 @@ static void fill_wifi_scan_changed_data(int state)
 
        _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;
                }
        }
 
@@ -541,8 +487,7 @@ static void fill_wifi_connection_state_changed_data(int state)
 
        _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;
@@ -550,15 +495,12 @@ static void fill_wifi_connection_state_changed_data(int state)
                        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 ;
                        }
@@ -569,13 +511,10 @@ static void fill_wifi_connection_state_changed_data(int state)
                        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 ;
                        }
@@ -606,15 +545,12 @@ static void fill_device_display_change(int value)
                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 ;
                }
@@ -626,13 +562,10 @@ static void fill_device_display_change(int value)
                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 ;
                }
@@ -645,13 +578,10 @@ static void fill_device_display_change(int value)
                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 ;
                }
@@ -671,9 +601,8 @@ static void fill_display_brightness_change(int brightness_level)
 {
        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;
@@ -689,9 +618,8 @@ static void fill_battery_capacity_change(int charging_level)
 {
        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;
        }
@@ -705,43 +633,33 @@ static void fill_charging_status_change(int charging)
 {
        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 ;
                        }
@@ -760,9 +678,8 @@ static void fill_signal_strength_change(int ss)
 {
        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;
@@ -780,45 +697,35 @@ static void fill_location_change(int gps)
 {
        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 ;
                        }
@@ -833,14 +740,14 @@ static void fill_location_change(int gps)
 
 
 
-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;
@@ -890,63 +797,53 @@ static void bm_create_event_data(int type,int val)
        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;
        }
@@ -962,7 +859,7 @@ void* event_producer(void *data)
 {
        ENTER;
        event_pool *event = (event_pool*) data;
-       if(event == NULL)
+       if (event == NULL)
                return NULL;
 
        pthread_mutex_lock(&battery_lister_mutex);
@@ -994,19 +891,18 @@ void __bm_bt_adapter_state_changed_cb(int result,
        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;
        }
@@ -1014,8 +910,7 @@ void __bm_bt_adapter_state_changed_cb(int result,
        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;
        }
@@ -1036,14 +931,11 @@ void __bm_bt_device_connection_state_changed_cb(bool connected,
        _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;
        }
@@ -1051,8 +943,7 @@ void __bm_bt_device_connection_state_changed_cb(bool connected,
        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;
        }
@@ -1070,27 +961,29 @@ static void __bm_bt_device_discovery_state_changed_cb(
        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;
        }
@@ -1112,8 +1005,7 @@ static void __bm_wifi_device_state_callback(wifi_manager_device_state_e state, v
                _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;
        }
@@ -1121,8 +1013,7 @@ static void __bm_wifi_device_state_callback(wifi_manager_device_state_e state, v
        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;
        }
@@ -1143,8 +1034,7 @@ static void __bm_wifi_scan_changed_callback(wifi_manager_scan_state_e state, voi
        _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;
        }
@@ -1152,8 +1042,7 @@ static void __bm_wifi_scan_changed_callback(wifi_manager_scan_state_e state, voi
        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;
        }
@@ -1168,15 +1057,13 @@ static void __bm_wifi_connection_state_changed_callback(wifi_manager_connection_
        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;
        }
@@ -1184,8 +1071,7 @@ static void __bm_wifi_connection_state_changed_callback(wifi_manager_connection_
        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;
        }
@@ -1206,8 +1092,7 @@ static void __bm_device_display_change(device_callback_e type, void *value, void
        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;
        }
@@ -1215,8 +1100,7 @@ static void __bm_device_display_change(device_callback_e type, void *value, void
        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;
        }
@@ -1230,57 +1114,47 @@ static void __bm_display_brightness_change(keynode_t *key, void* data)
 {
        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;
        }
@@ -1289,8 +1163,7 @@ static void __bm_display_brightness_change(keynode_t *key, void* data)
 
 
        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;
        }
@@ -1305,14 +1178,13 @@ static void __bm_battery_capacity_change(keynode_t *key, void* data)
 {
        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;
        }
@@ -1321,8 +1193,7 @@ static void __bm_battery_capacity_change(keynode_t *key, void* data)
 
 
        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;
        }
@@ -1336,14 +1207,13 @@ static void __bm_charging_status_change(keynode_t *key, void* data)
 {
        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;
        }
@@ -1352,8 +1222,7 @@ static void __bm_charging_status_change(keynode_t *key, void* data)
 
 
        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;
        }
@@ -1368,14 +1237,13 @@ static void __bm_location_change(keynode_t *key, void* data)
 {
        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;
        }
@@ -1384,8 +1252,7 @@ static void __bm_location_change(keynode_t *key, void* data)
 
 
        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;
        }
@@ -1404,77 +1271,61 @@ static void __bm_noti_signal_strength(TapiHandle *handle, const char *noti_id, v
        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;
        }
@@ -1483,8 +1334,7 @@ static void __bm_noti_signal_strength(TapiHandle *handle, const char *noti_id, v
 
 
        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;
        }
@@ -1503,7 +1353,7 @@ static int  bm_charging_status_listeners()
        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;
        }
 
@@ -1522,13 +1372,12 @@ static int  bm_battery_capacity_listeners()
        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;
-
 }
 
 
@@ -1541,13 +1390,12 @@ static int  bm_location_listeners()
        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;
-
 }
 
 
@@ -1564,7 +1412,6 @@ static int  bm_screen_subscribe_listeners()
 
        EXIT;
        return 0;
-
 }
 
 
@@ -1574,9 +1421,8 @@ static int  bm_signal_strength_listeners()
        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;
@@ -1585,7 +1431,6 @@ static int  bm_signal_strength_listeners()
 
        EXIT;
        return 0;
-
 }
 
 
@@ -1598,7 +1443,7 @@ static int  bm_display_brightness_listeners()
        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;
        }
 
@@ -1616,30 +1461,24 @@ static int  bm_wifi_subscribe_listeners()
 
        /*      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;
@@ -1662,7 +1501,7 @@ static int  bm_bluetooth_subscribe_listeners()
 
        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);
@@ -1688,16 +1527,15 @@ void* event_consumer()
 {
        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--;
@@ -1715,27 +1553,22 @@ static int bm_initialize_history_data_obj()
        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;
        }
@@ -1755,9 +1588,9 @@ int bd_initialize_listeners(void)
 
 
        /* 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;
        }
@@ -1765,7 +1598,7 @@ int bd_initialize_listeners(void)
 
 
        /*  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");
@@ -1774,47 +1607,47 @@ int bd_initialize_listeners(void)
 
        /*  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");
@@ -1837,12 +1670,12 @@ int bd_deinitialize_listeners()
        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 */
@@ -1851,42 +1684,35 @@ int bd_deinitialize_listeners()
        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;
@@ -1894,10 +1720,8 @@ int bd_deinitialize_listeners()
                tel_deinit(handle);
        }
 
-       if(data_obj)
-       {
+       if (data_obj)
                BM_FREE(data_obj);
-       }
 
        EXIT;
        return BATTERY_MONITOR_ERROR_NONE;
@@ -1905,10 +1729,3 @@ int bd_deinitialize_listeners()
 }
 
 
-
-
-
-
-
-
-