diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/battery_dump/bm_listeners.c | 247 |
1 files changed, 128 insertions, 119 deletions
diff --git a/src/battery_dump/bm_listeners.c b/src/battery_dump/bm_listeners.c index 723d886..d390fe7 100644 --- a/src/battery_dump/bm_listeners.c +++ b/src/battery_dump/bm_listeners.c @@ -71,11 +71,10 @@ static void bd_get_app_id_from_table(gint pid, char **app_id) *app_id = strdup((char *)orig_app_id); } else { _ERR("pid not available in map"); - goto END; + return; } _DBG("retrieved app_id[%s] for pid[%d]", *app_id, pid); -END: return; } @@ -83,19 +82,19 @@ static void bd_insert_app_id_into_table(gint pid, char *appid) { if (appid == NULL) { _ERR("invalid appid"); - goto END; + return; } /* redundant keys are not required */ if (g_hash_table_contains(pid_map, &pid) == true) { _DBG("key[%d] already present, no insertion required", pid); - goto END; + return; } gint* lpid = g_new0(gint, 1); if (lpid == NULL) { _ERR("failed to allocate memory"); - goto END; + return; } *lpid = pid; @@ -104,7 +103,7 @@ static void bd_insert_app_id_into_table(gint pid, char *appid) if (g_hash_table_insert(pid_map, lpid, strdup(appid)) == false) _WARN("key already available, replacing old value"); -END: + return; } @@ -112,13 +111,12 @@ static void bd_remove_app_id_from_table(gint pid) { if (g_hash_table_contains(pid_map, &pid) != true) { _DBG("key[%d] not present in list", pid); - goto END; + return; } g_hash_table_remove(pid_map, &pid); _DBG("removed key[%d] from table", pid); -END: return; } @@ -127,12 +125,15 @@ static int bd_listener_set_appId_info(char *app_id) ENTER; data_obj->event_tag->uid = 1000; + data_obj->event_tag->string_info = g_string_sized_new(7); if (!data_obj->event_tag->string_info) { _ERR("memory allocation failed "); return 1; } + g_string_append_printf(data_obj->event_tag->string_info, "%s", app_id); + EXIT; return 0; } @@ -185,14 +186,14 @@ static int bd_listener_set_battery_info() else data_obj->battery_plugtype = BD_BPLT_NONE; - _INFO("battery_level = %d, battery_status = %d, battery_health = %d, \ + _DBG("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); data_obj->battery_temperature = info.temperature; data_obj->battery_voltage = info.voltage_now; - _INFO("battery_voltage = %d, battery_temperature = %d", \ + _DBG("battery_voltage = %d, battery_temperature = %d", \ data_obj->battery_voltage, data_obj->battery_temperature); } else { _ERR("Failed to get battery info (%d)", ret); @@ -207,15 +208,14 @@ static void bd_listener_set_bt_adapter_state_change_data(int adapter_state) ENTER; static int bt_hsp = 0; + int bt_state = -1; - _WARN("state: %s", (adapter_state == BT_ADAPTER_ENABLED) ? "ENABLED" : "DISABLED"); - int bt_state; if (adapter_state == BT_ADAPTER_ENABLED) bt_state = 1; else bt_state = 0; - _INFO("__bm_bt_adapter_state_changed_cb bt_state = %d ", bt_state); + _INFO("bt_state = %d ", bt_state); if (data_obj) { if (adapter_state == BT_ADAPTER_ENABLED) { @@ -225,9 +225,8 @@ static void bd_listener_set_bt_adapter_state_change_data(int adapter_state) data_obj->event_tag = NULL; data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s)); if (data_obj->event_tag) { - listener_hsp++; - bt_hsp = listener_hsp; - _INFO("event Tag creation succeeded \n"); + bt_hsp = ++listener_hsp; + _DBG("event Tag creation succeeded \n"); data_obj->event_tag->sp_idx = bt_hsp; } else { _ERR(" data_obj->event_tag object creation fails "); @@ -241,7 +240,7 @@ static void bd_listener_set_bt_adapter_state_change_data(int adapter_state) data_obj->event_tag = NULL; data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s)); if (data_obj->event_tag) { - _INFO("event Tag creation succeeded \n"); + _DBG("event Tag creation succeeded \n"); data_obj->event_tag->sp_idx = bt_hsp; } else { _ERR(" data_obj->event_tag object creation fails "); @@ -259,7 +258,7 @@ static void bd_listener_set_bt_device_discovery_state_change_data(int discovery_ { ENTER; - _WARN(" discovery_state = %d", discovery_state); + _INFO("discovery_state = %d", discovery_state); static int bt_scan_hsp = 0, bt_flag = 0; @@ -273,11 +272,10 @@ static void bd_listener_set_bt_device_discovery_state_change_data(int discovery_ data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s)); if (data_obj->event_tag) { if (!bt_flag) { - listener_hsp++; - bt_scan_hsp = listener_hsp; + bt_scan_hsp = ++listener_hsp; bt_flag = 1; } - _INFO("event Tag creation succeeded \n"); + _DBG("event Tag creation succeeded \n"); data_obj->event_tag->sp_idx = bt_scan_hsp; } else { _ERR(" data_obj->event_tag object creation fails "); @@ -292,7 +290,7 @@ static void bd_listener_set_bt_device_discovery_state_change_data(int discovery_ data_obj->event_tag = NULL; data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s)); if (data_obj->event_tag) { - _INFO("event Tag creation succeeded \n"); + _DBG("event Tag creation succeeded \n"); data_obj->event_tag->sp_idx = bt_scan_hsp; } else { _ERR(" data_obj->event_tag object creation fails "); @@ -314,9 +312,10 @@ static void bd_listener_set_bt_device_connection_state_change_data(int connected { ENTER; - _WARN("__bt_device_connection_state_changed_cb [%d]", connected); + _INFO("connection state = %d", connected); + if (!connected) - _INFO("bt is disconnected"); + _DBG("bt is disconnected"); static int bt_connected_hsp = 0; @@ -328,9 +327,8 @@ static void bd_listener_set_bt_device_connection_state_change_data(int connected data_obj->event_tag = NULL; data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s)); if (data_obj->event_tag) { - listener_hsp++; - bt_connected_hsp = listener_hsp; - _INFO("event Tag creation succeeded \n"); + bt_connected_hsp = ++listener_hsp; + _DBG("event Tag creation succeeded \n"); data_obj->event_tag->sp_idx = bt_connected_hsp; } else { _ERR(" data_obj->event_tag object creation fails "); @@ -343,7 +341,7 @@ static void bd_listener_set_bt_device_connection_state_change_data(int connected data_obj->event_tag = NULL; data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s)); if (data_obj->event_tag) { - _INFO("event Tag creation succeeded \n"); + _DBG("event Tag creation succeeded \n"); data_obj->event_tag->sp_idx = bt_connected_hsp; } else { _ERR(" data_obj->event_tag object creation fails "); @@ -360,12 +358,7 @@ static void bd_listener_set_wifi_device_state_data(int state) { ENTER; - _WARN(" Wifi Device state changed callback"); - - if (state == WIFI_MANAGER_DEVICE_STATE_ACTIVATED) - _INFO(", state : Activated\n"); - else - _INFO(", state : Deactivated\n"); + (state == WIFI_MANAGER_DEVICE_STATE_ACTIVATED) ? _INFO("Activated") : _INFO("Deactivated"); static int wifi_hsp = 0; @@ -377,9 +370,8 @@ static void bd_listener_set_wifi_device_state_data(int state) data_obj->event_tag = NULL; data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s)); if (data_obj->event_tag) { - listener_hsp++; - wifi_hsp = listener_hsp; - _INFO("event Tag creation succeeded \n"); + wifi_hsp = ++listener_hsp; + _DBG("event Tag creation succeeded \n"); data_obj->event_tag->sp_idx = wifi_hsp; } else { _ERR(" data_obj->event_tag object creation fails "); @@ -393,7 +385,7 @@ static void bd_listener_set_wifi_device_state_data(int state) data_obj->event_tag = NULL; data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s)); if (data_obj->event_tag) { - _INFO("event Tag creation succeeded \n"); + _DBG("event Tag creation succeeded \n"); data_obj->event_tag->sp_idx = wifi_hsp; } else { _ERR(" data_obj->event_tag object creation fails "); @@ -411,7 +403,7 @@ static void bd_listener_set_wifi_scan_change_data(int state) { ENTER; - _WARN("Wifi Scan changed, scan state : %d\n", state); + _INFO("scan state = %d", state); static int wifi_flag = 0, wifi_scan_hsp = 0; @@ -424,11 +416,10 @@ static void bd_listener_set_wifi_scan_change_data(int state) data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s)); if (data_obj->event_tag) { if (!wifi_flag) { - listener_hsp++; - wifi_scan_hsp = listener_hsp; + wifi_scan_hsp = ++listener_hsp; wifi_flag = 1; } - _INFO("event Tag creation succeeded \n"); + _DBG("event Tag creation succeeded \n"); data_obj->event_tag->sp_idx = wifi_scan_hsp; } else { _ERR(" data_obj->event_tag object creation fails "); @@ -442,7 +433,7 @@ static void bd_listener_set_wifi_scan_change_data(int state) data_obj->event_tag = NULL; data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s)); if (data_obj->event_tag) { - _INFO("event Tag creation succeeded \n"); + _DBG("event Tag creation succeeded \n"); data_obj->event_tag->sp_idx = wifi_scan_hsp; } else { _ERR(" data_obj->event_tag object creation fails "); @@ -461,7 +452,7 @@ static void bd_listener_set_wifi_connection_state_change_data(int state) { ENTER; - _WARN("Wifi Connection changed, connection state : %d\n", state); + _INFO("connection state = %d", state); static int wifi_connected_hsp = 0; @@ -474,9 +465,8 @@ static void bd_listener_set_wifi_connection_state_change_data(int state) data_obj->event_tag = NULL; data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s)); if (data_obj->event_tag) { - _INFO("event Tag creation succeeded \n"); - listener_hsp++; - wifi_connected_hsp = listener_hsp; + _DBG("event Tag creation succeeded \n"); + wifi_connected_hsp = ++listener_hsp; data_obj->event_tag->sp_idx = wifi_connected_hsp; } else { _ERR(" data_obj->event_tag object creation fails "); @@ -490,7 +480,7 @@ static void bd_listener_set_wifi_connection_state_change_data(int state) data_obj->event_tag = NULL; data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s)); if (data_obj->event_tag) { - _INFO("event Tag creation succeeded \n"); + _DBG("event Tag creation succeeded \n"); data_obj->event_tag->sp_idx = wifi_connected_hsp; } else { _ERR(" data_obj->event_tag object creation fails "); @@ -509,22 +499,22 @@ static void bd_listener_set_wifi_connection_state_change_data(int state) static void bd_listener_set_device_display_change_data(int value) { ENTER; - _WARN("device state changed succeeded\n"); + + _INFO("device display state = %d", value); static int display_hsp = 0; switch (value) { case DISPLAY_STATE_NORMAL: - _INFO("Display on"); + _DBG("Display on"); data_obj->event_code = ET_NONE; data_obj->event_code |= ET_SCREEN_WAKE_UP; 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) { - listener_hsp++; - display_hsp = listener_hsp; - _INFO("event Tag creation succeeded \n"); + display_hsp = ++listener_hsp; + _DBG("event Tag creation succeeded \n"); data_obj->event_tag->sp_idx = display_hsp; } else { _ERR(" data_obj->event_tag object creation fails "); @@ -534,20 +524,20 @@ static void bd_listener_set_device_display_change_data(int value) data_obj->state_1 &= ~(ST1_SCREEN_DOZE_FLAG); break; case DISPLAY_STATE_SCREEN_DIM: - _INFO("Display dim"); + _DBG("Display dim"); data_obj->event_code = ET_NONE; data_obj->event_tag = NULL; data_obj->state_1 |= ST1_SCREEN_DOZE_FLAG; break; case DISPLAY_STATE_SCREEN_OFF: - _INFO("Display off"); + _DBG("Display off"); data_obj->event_code = ET_NONE; data_obj->event_code |= ET_SCREEN_WAKE_UP; 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) { - _INFO("event Tag creation succeeded \n"); + _DBG("event Tag creation succeeded \n"); data_obj->event_tag->sp_idx = display_hsp; } else { _ERR(" data_obj->event_tag object creation fails "); @@ -566,7 +556,7 @@ static void bd_listener_set_display_brightness_change_data(int brightness_level) { ENTER; - _WARN(" device brightness changed =%d ", brightness_level); + _INFO("brightness change = %d", brightness_level); static int brightness_val = 0; @@ -586,7 +576,8 @@ static void bd_listener_set_battery_capacity_change_data(int charging_level) { ENTER; - _WARN(" device battery_capacity changed =%d ", charging_level); + _INFO("capacity change = %d", charging_level); + if (data_obj) { data_obj->event_code = ET_NONE; data_obj->event_tag = NULL; @@ -600,7 +591,8 @@ static void bd_listener_set_charging_status_change_data(int charging) { ENTER; - _INFO(" device charging_status changed =%d ", charging); + _INFO("charging status = %d", charging); + if (data_obj) { if (charging) { data_obj->event_code = ET_NONE; @@ -621,7 +613,7 @@ static void bd_listener_set_signal_strength_change_data(int ss) { ENTER; - _WARN(" device signal_strength changed =%d ", ss); + _INFO("signal strength change = %d", ss); static int ss_val = 0; @@ -641,7 +633,7 @@ static void bd_listener_set_sleep_wakeup_change_data(int val) { ENTER; - _WARN(" sleep/wake up changed =%d ", val); + _INFO("sleep wakeup change = %d", val); static int wakeup_hsp = 0; @@ -651,9 +643,8 @@ static void bd_listener_set_sleep_wakeup_change_data(int val) data_obj->wakereason_tag = NULL; data_obj->wakereason_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s)); if (data_obj->wakereason_tag) { - listener_hsp++; - wakeup_hsp = listener_hsp; - _INFO("Wakereason Tag creation succeeded \n"); + wakeup_hsp = ++listener_hsp; + _DBG("Wakereason Tag creation succeeded \n"); data_obj->wakereason_tag->sp_idx = wakeup_hsp; data_obj->wakereason_tag->uid = 1000; data_obj->wakereason_tag->string_info = g_string_sized_new(10); @@ -674,7 +665,7 @@ static void bd_listener_set_sleep_wakeup_change_data(int val) data_obj->wakereason_tag = NULL; data_obj->wakereason_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s)); if (data_obj->wakereason_tag) { - _INFO("Wakereason Tag creation succeeded \n"); + _DBG("Wakereason Tag creation succeeded \n"); data_obj->wakereason_tag->sp_idx = wakeup_hsp; data_obj->wakereason_tag->uid = 1000; data_obj->wakereason_tag->string_info = g_string_sized_new(10); @@ -699,7 +690,7 @@ static void bd_listener_set_location_change_data(int gps) { ENTER; - _WARN(" maps location changed =%d ", gps); + _INFO("location change = %d", gps); static int gps_hsp = 0; @@ -711,9 +702,8 @@ static void bd_listener_set_location_change_data(int gps) data_obj->event_tag = NULL; data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s)); if (data_obj->event_tag) { - listener_hsp++; - gps_hsp = listener_hsp; - _INFO("event Tag creation succeeded \n"); + gps_hsp = ++listener_hsp; + _DBG("event Tag creation succeeded \n"); data_obj->event_tag->sp_idx = gps_hsp; } else { _ERR(" data_obj->event_tag object creation fails "); @@ -727,7 +717,7 @@ static void bd_listener_set_location_change_data(int gps) data_obj->event_tag = NULL; data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s)); if (data_obj->event_tag) { - _INFO("event Tag creation succeeded \n"); + _DBG("event Tag creation succeeded \n"); data_obj->event_tag->sp_idx = gps_hsp; } else { _ERR(" data_obj->event_tag object creation fails "); @@ -745,7 +735,7 @@ static int bd_listener_set_power_lock_unlock_change_data(int lock) { ENTER; - _WARN(" fill_powerlock_change changed =%d ", lock); + _INFO("lock change = %d", lock); static int prev_wakeup = 0; @@ -764,9 +754,8 @@ static int bd_listener_set_power_lock_unlock_change_data(int lock) data_obj->event_tag = NULL; data_obj->wakelock_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s)); if (data_obj->wakelock_tag) { - listener_hsp++; - lock_hsp = listener_hsp; - _INFO("wakelock Tag creation succeeded \n"); + lock_hsp = ++listener_hsp; + _DBG("wakelock Tag creation succeeded \n"); data_obj->wakelock_tag->sp_idx = lock_hsp; data_obj->wakelock_tag->uid = 1000; data_obj->wakelock_tag->string_info = g_string_sized_new(10); @@ -800,12 +789,12 @@ static int bd_listener_set_app_status_change_data(int val, char *app_id) return 1; } + _INFO(" App status change - app[%s], val[%d]", app_id, val); + void *prv_data = NULL, *prv_app_id = NULL; int error_code = 0; static int app_hsp = 0; - _DBG(" App status change - app[%s], val[%d]", app_id, val); - if (data_obj) { if (val == 1) { /* foreground */ data_obj->event_code = ET_NONE; @@ -817,7 +806,7 @@ static int bd_listener_set_app_status_change_data(int val, char *app_id) if (data_obj->event_tag) { app_hsp = ++listener_hsp; - _INFO("event Tag creation succeeded \n"); + _DBG("event Tag creation succeeded \n"); data_obj->event_tag->sp_idx = app_hsp; @@ -848,7 +837,7 @@ static int bd_listener_set_app_status_change_data(int val, char *app_id) info->hsp_info = app_hsp; info->app_state = val; - _INFO("inserting in table - [%s]", app_id); + _DBG("inserting in table - [%s]", app_id); g_hash_table_insert(app_list, app_id, info); @@ -905,7 +894,7 @@ static int bd_listener_set_app_status_change_data(int val, char *app_id) goto out; } } else { - _INFO("application not available in list "); + _DBG("application not available in list "); error_code = 1; goto out; } @@ -924,7 +913,7 @@ static void bd_listener_set_modem_power_state_change_data(int state) { ENTER; - _WARN("fill_modem_power_state_change - state[%d]", state); + _INFO("modem state = %d", state); static int modem_hsp = 0; @@ -936,8 +925,7 @@ static void bd_listener_set_modem_power_state_change_data(int state) data_obj->event_tag = (history_tag_s *)calloc(1, sizeof(history_tag_s)); if (data_obj->event_tag) { - listener_hsp++; - modem_hsp = listener_hsp; + modem_hsp = ++listener_hsp; data_obj->event_tag->sp_idx = modem_hsp; _DBG("ON event tag - success"); } else { @@ -975,9 +963,12 @@ static void bd_listener_set_modem_power_state_change_data(int state) static void bd_listener_create_event_data(int type, int val, char *app) { ENTER; + if (!data_obj) return; + _INFO("create event = type[%d], val[%d], app[%s]", type, val, app); + static int prev_battery_level = 0; switch (type) { @@ -1074,6 +1065,7 @@ static void bd_listener_create_event_data(int type, int val, char *app) g_string_append_printf(data_obj->event_tag->string_info, "%s", "Tizen"); } + if (data_obj->event_tag) { _DBG("Data Value of listener event uid : %d ", data_obj->event_tag->uid); _DBG("Data Value of listener event string : %s sp index = %d", @@ -1123,8 +1115,8 @@ void* bd_listener_event_consumer() bd_listener_create_event_data(events_buf[use_ptr].type, events_buf[use_ptr].val, events_buf[use_ptr].app); - _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); + _DBG("type: %d and val = %d", events_buf[use_ptr].type, events_buf[use_ptr].val); + _DBG("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--; @@ -1186,7 +1178,7 @@ void* bd_listener_event_producer(void *data) events_buf[fill_ptr].val = event->val; events_buf[fill_ptr].app = event->app; - _INFO("type: %d and val = %d", events_buf[fill_ptr].type , events_buf[fill_ptr].val); + _DBG("type: %d and val = %d", events_buf[fill_ptr].type , events_buf[fill_ptr].val); fill_ptr = (fill_ptr + 1) % MAX_BUFF; @@ -1205,7 +1197,7 @@ void* bd_listener_event_producer(void *data) goto END; } - _INFO("event_producer success - type[%d], val[%d]", event->type, event->val); + _DBG("event_producer success - type[%d], val[%d]", event->type, event->val); END: BM_FREE(event); @@ -1254,9 +1246,7 @@ void _bd_listener_bt_adapter_state_change_cb(int result, bt_adapter_state_e adap { ENTER; - _INFO("__bt_adapter_state_changed_cb - result[%d]", result); - - _INFO("state: %s", (adapter_state == BT_ADAPTER_ENABLED) ? "ENABLED" : "DISABLED"); + _INFO("result[%d], state[%s]", result, (adapter_state == BT_ADAPTER_ENABLED) ? "ENABLED" : "DISABLED"); char* app_id = NULL; static int bt_adaptor = 0; @@ -1269,9 +1259,7 @@ void _bd_listener_bt_adapter_state_change_cb(int result, bt_adapter_state_e adap else bt_adaptor = bt_state; - _INFO("__bm_bt_adapter_state_changed_cb bt_state = %d ", bt_state); - - _INFO("buff_count: %d and fill_ptr = %d", buff_count , fill_ptr); + _DBG("bt_state-%d, buff_count-%d, fill_ptr-%d", bt_state, buff_count , fill_ptr); /* get app_id */ bd_get_focussed_app_id(&app_id); @@ -1301,7 +1289,7 @@ void _bd_listener_bt_device_connection_state_change_cb(bool connected, bt_device char *app_id = NULL; if (!connected) - _INFO("disconnection reason [%d]", conn_info->disconn_reason); + _DBG("disconnection reason [%d]", conn_info->disconn_reason); /* get app_id */ bd_get_focussed_app_id(&app_id); @@ -1329,19 +1317,18 @@ static void _bd_listener_bt_device_discovery_state_change_cb(int result, { ENTER; - _INFO("__bt_adapter_state_changed_cb"); _INFO("result: %d , discovery_state = %d", result, discovery_state); char *app_id = NULL; static int bt_discovery_state = 1; if (discovery_state > 1) { - _INFO(" This state will be handled later"); + _DBG(" This state will be handled later"); return; } if (bt_discovery_state == discovery_state) { - _INFO(" state is same as last state, didnt changed"); + _DBG(" state is same as last state, didnt changed"); return; } else { bt_discovery_state = discovery_state; @@ -1375,9 +1362,9 @@ static void _bd_listener_wifi_device_state_callback(wifi_manager_device_state_e char* app_id = NULL; if (state == WIFI_MANAGER_DEVICE_STATE_ACTIVATED) - _INFO(", state : Activated\n"); + _DBG(", state : Activated\n"); else - _INFO(", state : Deactivated\n"); + _DBG(", state : Deactivated\n"); /* get app_id */ bd_get_focussed_app_id(&app_id); @@ -1435,7 +1422,7 @@ static void _bd_listener_wifi_connection_state_change_callback(wifi_manager_conn char* app_id = NULL; if (state == -1 || state == 1 || state == 2) { - _WARN("These connection states are not related "); + _DBG("These connection states are not related "); return; } @@ -1461,6 +1448,7 @@ static void _bd_listener_wifi_connection_state_change_callback(wifi_manager_conn static void _bd_listener_device_display_change(device_callback_e type, void *value, void *user_data) { ENTER; + _INFO("device state changed succeeded\n"); if (type != DEVICE_CALLBACK_DISPLAY_STATE) @@ -1490,6 +1478,7 @@ static void _bd_listener_device_display_change(device_callback_e type, void *val static void _bd_listener_display_brightness_change(keynode_t *key, void* data) { ENTER; + _INFO("device brightness changed succeeded"); int flag, brightness_level = 0; @@ -1529,7 +1518,7 @@ static void _bd_listener_display_brightness_change(keynode_t *key, void* data) brightness_flag = flag; } - _INFO(" device brightness changed =%d ", brightness_level); + _DBG(" device brightness changed =%d ", brightness_level); /* get event object */ event_pool *event = bd_listener_get_event_obj(LISTEN_BRIGHTNESS_CHANGE, brightness_flag, NULL); @@ -1555,7 +1544,7 @@ static void _bd_listener_battery_capacity_change(keynode_t *key, void* data) vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, &charging); - _INFO(" device battery_capacity changed =%d ", charging); + _DBG(" device battery_capacity changed =%d ", charging); /* get event object */ event_pool *event = bd_listener_get_event_obj(LISTEN_BATTERY_CAPACITY_CHANGE, charging, NULL); @@ -1575,13 +1564,11 @@ static void _bd_listener_charging_status_change(keynode_t *key, void* data) { ENTER; - _INFO("device charging_status changed succeeded\n"); - 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); /* get event object */ event_pool *event = bd_listener_get_event_obj(LISTEN_CHARGING_STATUS_CHANGE, charging, NULL); @@ -1600,7 +1587,6 @@ static void _bd_listener_charging_status_change(keynode_t *key, void* data) static void _bd_listener_location_change(keynode_t *key, void* data) { ENTER; - _INFO("device location changed succeeded\n"); char* app_id = NULL; static int location_flag = 0; @@ -2067,21 +2053,21 @@ static int bd_subscribe_wifi_listeners() if (rv == WIFI_MANAGER_ERROR_NONE) { int ret = wifi_manager_set_device_state_changed_cb(wifi, _bd_listener_wifi_device_state_callback, NULL); if (ret != WIFI_MANAGER_ERROR_NONE) - _ERR("wifi_manager_set_device_state_changed_cb failed"); + _ERR("wifi_manager_set_device_state_changed_cb failed, ret = %d", ret); ret = wifi_manager_set_scan_state_changed_cb(wifi, _bd_listener_wifi_scan_change_callback, NULL); if (ret != WIFI_MANAGER_ERROR_NONE) - _ERR("wifi_manager_set_scan_state_changed_cb failed"); + _ERR("wifi_manager_set_scan_state_changed_cb failed, ret = %d", ret); ret = wifi_manager_set_connection_state_changed_cb(wifi, _bd_listener_wifi_connection_state_change_callback, NULL); if (ret != WIFI_MANAGER_ERROR_NONE) - _ERR("wifi_manager_set_scan_state_changed_cb failed"); + _ERR("wifi_manager_set_scan_state_changed_cb failed, ret = %d", ret); } else { _ERR(" Wifi init failed \n"); return 1; } - _INFO("Wifi init succeeded\n"); + _DBG("Wifi init succeeded\n"); EXIT; return 0; @@ -2096,20 +2082,22 @@ static int bd_subscribe_bluetooth_listeners() if (rv == BT_ERROR_NONE) { int ret = bt_device_set_connection_state_changed_cb(_bd_listener_bt_device_connection_state_change_cb, NULL); - _INFO("bt_device_set_connection_state_changed_cb ret =%d \n", ret); + if (ret != BT_ERROR_NONE) + _ERR("bt_device_set_connection_state_changed_cb failure, ret = %d", ret); ret = bt_adapter_set_state_changed_cb(_bd_listener_bt_adapter_state_change_cb, NULL); - _INFO("bt_adapter_set_state_changed_cb ret =%d \n", ret); + if (ret != BT_ERROR_NONE) + _ERR("bt_adapter_set_state_changed_cb failure, ret = %d", ret); ret = bt_adapter_set_device_discovery_state_changed_cb(_bd_listener_bt_device_discovery_state_change_cb, NULL); - _INFO("bt_adapter_set_device_discovery_state_changed_cb ret =%d \n", ret); - + if (ret != BT_ERROR_NONE) + _ERR("bt_adapter_set_device_discovery_state_changed_cb, ret = %d", ret); } else { _ERR(" bluetooth init failed \n"); return 1; } - _INFO("bluetooth init succeeded\n"); + _DBG("bluetooth init succeeded\n"); EXIT; return 0; } @@ -2260,7 +2248,7 @@ static int bd_initialize_data_items() return BATTERY_MONITOR_ERROR_OUT_OF_MEMORY; } } else { - _INFO("data object is available"); + _DBG("data object is available"); } if (bd_listener_set_battery_info() != DEVICE_ERROR_NONE) { @@ -2283,6 +2271,8 @@ int bd_initialize_listeners(void) { ENTER; + _INFO("initializing listeners"); + listener_hsp = -1; /* initialize data items */ @@ -2353,7 +2343,7 @@ int bd_deinitialize_listeners() { ENTER; - _INFO("de-initializing History listeners"); + _INFO("de-initializing listeners"); /* unset the callbacks related to wifi */ if (wifi_manager_unset_connection_state_changed_cb(wifi) != WIFI_MANAGER_ERROR_NONE) @@ -2407,13 +2397,32 @@ int bd_deinitialize_listeners() if (pthread_attr_destroy(&attr) != 0) _ERR("pthread_attr_destroy failed"); - if (app_list) + /* free all pointers used */ + if (app_list) { g_hash_table_destroy(app_list); + app_list = NULL; + } - if (pid_map) + if (pid_map) { g_hash_table_destroy(pid_map); + pid_map = NULL; + } + + if (data_obj != NULL && data_obj->event_tag != NULL) { + BM_FREE(data_obj->event_tag->string_info); + BM_FREE(data_obj->event_tag); + } + + if (data_obj != NULL && data_obj->wakelock_tag != NULL) { + BM_FREE(data_obj->wakelock_tag->string_info); + BM_FREE(data_obj->wakelock_tag); + } + + if (data_obj != NULL && data_obj->wakereason_tag != NULL) { + BM_FREE(data_obj->wakereason_tag->string_info); + BM_FREE(data_obj->wakereason_tag); + } - /* TODO - check about internal struct members */ BM_FREE(data_obj); EXIT; |