From 66144f0e74a423c3ae4bd3df65e919cc29fdc1e3 Mon Sep 17 00:00:00 2001 From: Radoslaw Czerski Date: Wed, 26 Oct 2016 19:19:07 +0200 Subject: [PATCH] modules/processing/call: Status overridden fix. Even if any call was available for first SIM, it was overridden in case of call list was empty for second SIM. Change-Id: I75828df3737929484e765073f5b49b3351bdb99c Signed-off-by: Radoslaw Czerski --- src/modules/processing/call.c | 72 ++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/src/modules/processing/call.c b/src/modules/processing/call.c index fdb7c95..e29d7b0 100644 --- a/src/modules/processing/call.c +++ b/src/modules/processing/call.c @@ -36,10 +36,16 @@ #define MINICONTROL_VOICE_NAME "[voicecall-quickpanel]" #define MINICONTROL_VIDEO_NAME "[videocall-quickpanel]" +typedef enum { + STATUS_SET, + FAILED, + LIST_EMPTY +}call_status_t; + static int register_call_module(void *data); static int unregister_call_module(void); static void indicator_call_change_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data); -static int check_calls_status(int handle_no, void *data); +static call_status_t check_calls_status(telephony_h handle, void *data); enum { CALL_UI_STATUS_NONE = 0, @@ -194,54 +200,41 @@ static void indicator_call_change_cb(telephony_h handle, telephony_noti_e noti_i } } -static int check_calls_status(int handle_no, void *data) +static call_status_t check_calls_status(telephony_h handle, void *data) { int ret = OK; - int ret_val = OK; telephony_call_h *call_list; unsigned int call_cnt = 0; - if ((handle_no < 0) || (handle_no >= list.count)) { - _E("Invalid handle number: %d", handle_no); - return FAIL; - } - - ret = telephony_call_get_call_list(list.handle[handle_no], &call_cnt, &call_list); - if (ret != TELEPHONY_ERROR_NONE) { - _E("telephony_call_get_call_list failed : %s", get_error_message(ret)); - return FAIL; - } + ret = telephony_call_get_call_list(handle, &call_cnt, &call_list); + retvm_if(ret != TELEPHONY_ERROR_NONE, FAILED, "telephony_call_get_call_list failed : %s", get_error_message(ret)); if (call_cnt == 0) { hide_image_icon(); - _D("No calls available"); - ret_val = FAIL; - } else { - for (int i = 0; i < call_cnt; i++) { - telephony_call_status_e status; - - ret = telephony_call_get_status(call_list[i], &status); - - if (ret != TELEPHONY_ERROR_NONE) { - _E("telephony_call_get_status failed : %s", get_error_message(ret)); + _D("List is empty."); + return LIST_EMPTY; + } + for (int i = 0; i < call_cnt; i++) { + telephony_call_status_e status; - ret_val = FAIL; - continue; - } - indicator_call_change_cb(NULL, convert_call_status(status), NULL, data); + ret = telephony_call_get_status(call_list[i], &status); + if (ret != TELEPHONY_ERROR_NONE) { + _E("telephony_call_get_status failed : %s", get_error_message(ret)); + continue; } + indicator_call_change_cb(NULL, convert_call_status(status), NULL, data); + telephony_call_release_call_list(call_cnt, &call_list); + return STATUS_SET; } telephony_call_release_call_list(call_cnt, &call_list); - - return ret_val; + return FAILED; } static int register_call_module(void *data) { int ret = OK; - int ret_val = OK; retv_if(!data, FAIL); set_app_state(data); @@ -253,18 +246,22 @@ static int register_call_module(void *data) for (int i = TELEPHONY_NOTI_VOICE_CALL_STATUS_IDLE; i <= TELEPHONY_NOTI_VIDEO_CALL_STATUS_INCOMING; i++) { ret = telephony_set_noti_cb(list.handle[j], i, indicator_call_change_cb, data); if (ret != TELEPHONY_ERROR_NONE) { - _E("telephony_set_noti_cb failed : %s", get_error_message(ret)); + _E("telephony_set_noti_cb failed[%d]: %s", ret , get_error_message(ret)); _E("i: %d", i); - ret_val = FAIL; + unregister_call_module(); + return FAIL; } } - ret = check_calls_status(j, data); - ret_val = (ret != OK) ? FAIL : ret_val; + call_status_t ret = check_calls_status(list.handle[j], data); + if (ret == STATUS_SET) { + break; + } else if (ret == FAILED) { + unregister_call_module(); + return FAIL; + } } - register_bt_state(data); - - return ret_val; + return OK; } static int unregister_call_module(void) @@ -293,4 +290,3 @@ static int unregister_call_module(void) return ret_val; } -/* End of file */ -- 2.7.4