Skip to content

Commit 4d7617c

Browse files
expliyhhyson710
authored andcommitted
bt:fix call state is not changed when reject call
bug: v/66080 fix call state is not changed when reject call Signed-off-by: JerryWang<wanghaichao1@xiaomi.com>
1 parent a1f16c1 commit 4d7617c

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

service/profiles/hfp_ag/hfp_ag_tele_phone_service.c

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,26 +110,34 @@ static void update_call_state(tapi_call_info* call)
110110
{
111111
uint8_t active_call_nums = get_nums_of_call_state(CALL_STATUS_ACTIVE);
112112
uint8_t held_call_nums = get_nums_of_call_state(CALL_STATUS_HELD);
113+
hfp_ag_call_state_t state;
113114

114-
BT_LOGD("%s,state: %d", __func__, call->state);
115-
if (!call)
115+
if (!call) {
116+
BT_LOGD("%s:call is NULL", __func__);
116117
return;
118+
}
119+
state = call->state;
120+
if (call->state == CALL_STATUS_DISCONNECTED) {
121+
state = HFP_AG_CALL_STATE_DISCONNECTED;
122+
}
123+
BT_LOGD("%s,state: %d", __func__, state);
117124

118-
switch (call->state) {
119-
case CALL_STATUS_INCOMING:
120-
case CALL_STATUS_WAITING:
125+
switch (state) {
126+
case HFP_AG_CALL_STATE_INCOMING:
127+
case HFP_AG_CALL_STATE_WAITING:
121128
call->is_incoming = true;
122129
break;
123-
case CALL_STATUS_DIALING:
124-
case CALL_STATUS_ALERTING:
125-
case CALL_STATUS_DISCONNECTED:
130+
case HFP_AG_CALL_STATE_DIALING:
131+
case HFP_AG_CALL_STATE_ALERTING:
132+
case HFP_AG_CALL_STATE_IDLE:
133+
case HFP_AG_CALL_STATE_DISCONNECTED:
126134
call->is_incoming = false;
127135
break;
128136
default:
129137
break;
130138
}
131139

132-
phone_state_change(active_call_nums, held_call_nums, call->state,
140+
phone_state_change(active_call_nums, held_call_nums, state,
133141
NULL, HFP_CALL_ADDRTYPE_UNKNOWN, call->lineIdentification);
134142
}
135143

@@ -231,16 +239,19 @@ static void call_state_changed(tapi_call_info call_info)
231239

232240
BT_LOGD("%s\n", __func__);
233241

242+
dump_call(&call_info);
243+
234244
if (exist_call != NULL)
235245
bt_list_remove(g_current_calls, exist_call);
236246

247+
if (bt_list_is_empty(g_current_calls) && call_info.state == CALL_STATUS_DISCONNECTED) {
248+
update_call_state(&call_info);
249+
}
250+
237251
if (call_info.state != CALL_STATUS_DISCONNECTED) {
238252
call = (tapi_call_info*)calloc(1, sizeof(tapi_call_info));
239253
memcpy(call, &call_info, sizeof(tapi_call_info));
240254
bt_list_add_tail(g_current_calls, call);
241-
}
242-
if (call != NULL) {
243-
dump_call(call);
244255
update_call_state(call);
245256
}
246257
}
@@ -262,7 +273,7 @@ static tapi_call_info* get_call_by_state(uint8_t call_state)
262273

263274
static void dial_number_callback(tapi_async_result* ar)
264275
{
265-
uint8_t result = ar->status == 0? HFP_ATCMD_RESULT_OK : HFP_ATCMD_RESULT_ERROR;
276+
uint8_t result = ar->status == 0 ? HFP_ATCMD_RESULT_OK : HFP_ATCMD_RESULT_ERROR;
266277

267278
BT_LOGD("Dial result:%d", ar->status);
268279
hfp_ag_dial_result(result);
@@ -642,4 +653,4 @@ char* tele_service_get_operator(void)
642653
return "";
643654

644655
return g_operator_name;
645-
}
656+
}

0 commit comments

Comments
 (0)