hfp_ag: inline wrapper around hfp_gsm_handler to help static analyzer

This commit is contained in:
Matthias Ringwald 2020-12-08 11:31:01 +01:00
parent df842b645f
commit f8737b81da
3 changed files with 65 additions and 69 deletions

View File

@ -1084,7 +1084,7 @@ static void hfp_ag_handle_reject_incoming_call(void){
return;
}
hfp_gsm_handle_event(HFP_AG_OUTGOING_CALL_REJECTED);
hfp_gsm_handler(HFP_AG_OUTGOING_CALL_REJECTED, 0, 0, NULL);
hfp_connection->call_state = HFP_CALL_IDLE;
hfp_connection->send_error = 1;
hfp_ag_run_for_context(hfp_connection);
@ -1102,8 +1102,9 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
switch (hfp_gsm_call_status()){
case HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS:
switch (hfp_gsm_callsetup_status()){
case HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS:
hfp_gsm_handle_event(HFP_AG_INCOMING_CALL);
case HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS: {
hfp_gsm_handler(HFP_AG_INCOMING_CALL, 0, 0, NULL);
}
hfp_ag_set_callsetup_indicator();
hfp_ag_trigger_incoming_call();
log_info("AG rings");
@ -1114,8 +1115,9 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
break;
case HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT:
switch (hfp_gsm_callsetup_status()){
case HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS:
hfp_gsm_handle_event(HFP_AG_INCOMING_CALL);
case HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS: {
hfp_gsm_handler(HFP_AG_INCOMING_CALL, 0, 0, NULL);
}
hfp_ag_set_callsetup_indicator();
hfp_ag_trigger_incoming_call();
log_info("AG call waiting");
@ -1132,8 +1134,9 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
switch (hfp_gsm_call_status()){
case HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS:
switch (hfp_gsm_callsetup_status()){
case HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS:
hfp_gsm_handle_event(HFP_AG_INCOMING_CALL_ACCEPTED_BY_AG);
case HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS: {
hfp_gsm_handler(HFP_AG_INCOMING_CALL_ACCEPTED_BY_AG, 0, 0, NULL);
}
hfp_ag_set_call_indicator();
hfp_ag_set_callsetup_indicator();
hfp_ag_ag_accept_call();
@ -1147,7 +1150,7 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
switch (hfp_gsm_callsetup_status()){
case HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS:
log_info("AG: current call is placed on hold, incoming call gets active");
hfp_gsm_handle_event(HFP_AG_INCOMING_CALL_ACCEPTED_BY_AG);
hfp_gsm_handler(HFP_AG_INCOMING_CALL_ACCEPTED_BY_AG, 0, 0, NULL);
hfp_ag_set_callsetup_indicator();
hfp_ag_set_callheld_indicator();
hfp_ag_transfer_callsetup_state();
@ -1168,7 +1171,7 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
switch (hfp_gsm_callheld_status()){
case HFP_CALLHELD_STATUS_CALL_ON_HOLD_OR_SWAPPED:
log_info("AG: joining held call with active call");
hfp_gsm_handle_event(HFP_AG_HELD_CALL_JOINED_BY_AG);
hfp_gsm_handler(HFP_AG_HELD_CALL_JOINED_BY_AG, 0, 0, NULL);
hfp_ag_set_callheld_indicator();
hfp_ag_transfer_callheld_state();
hfp_emit_simple_event(hfp_connection, HFP_SUBEVENT_CONFERENCE_CALL);
@ -1186,8 +1189,9 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
switch (hfp_gsm_call_status()){
case HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS:
switch (hfp_gsm_callsetup_status()){
case HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS:
hfp_gsm_handle_event(HFP_AG_INCOMING_CALL_ACCEPTED_BY_HF);
case HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS: {
hfp_gsm_handler(HFP_AG_INCOMING_CALL_ACCEPTED_BY_HF, 0, 0, NULL);
}
hfp_ag_set_callsetup_indicator();
hfp_ag_set_call_indicator();
hfp_ag_hf_accept_call(hfp_connection);
@ -1208,8 +1212,9 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
switch (hfp_gsm_call_status()){
case HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS:
switch (hfp_gsm_callsetup_status()){
case HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS:
hfp_gsm_handle_event(HFP_AG_RESPONSE_AND_HOLD_ACCEPT_INCOMING_CALL_BY_AG);
case HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS: {
hfp_gsm_handler(HFP_AG_RESPONSE_AND_HOLD_ACCEPT_INCOMING_CALL_BY_AG, 0, 0, NULL);
}
hfp_ag_response_and_hold_active = 1;
hfp_ag_response_and_hold_state = HFP_RESPONSE_AND_HOLD_INCOMING_ON_HOLD;
hfp_ag_send_response_and_hold_state(hfp_ag_response_and_hold_state);
@ -1232,8 +1237,9 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
switch (hfp_gsm_call_status()){
case HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS:
switch (hfp_gsm_callsetup_status()){
case HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS:
hfp_gsm_handle_event(HFP_AG_RESPONSE_AND_HOLD_ACCEPT_INCOMING_CALL_BY_HF);
case HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS: {
hfp_gsm_handler(HFP_AG_RESPONSE_AND_HOLD_ACCEPT_INCOMING_CALL_BY_HF, 0, 0, NULL);
}
hfp_ag_response_and_hold_active = 1;
hfp_ag_response_and_hold_state = HFP_RESPONSE_AND_HOLD_INCOMING_ON_HOLD;
hfp_ag_send_response_and_hold_state(hfp_ag_response_and_hold_state);
@ -1256,7 +1262,7 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
case HFP_AG_RESPONSE_AND_HOLD_ACCEPT_HELD_CALL_BY_HF:
if (!hfp_ag_response_and_hold_active) break;
if (hfp_ag_response_and_hold_state != HFP_RESPONSE_AND_HOLD_INCOMING_ON_HOLD) break;
hfp_gsm_handle_event(HFP_AG_RESPONSE_AND_HOLD_ACCEPT_HELD_CALL_BY_AG);
hfp_gsm_handler(HFP_AG_RESPONSE_AND_HOLD_ACCEPT_HELD_CALL_BY_AG, 0, 0, NULL);
hfp_ag_response_and_hold_active = 0;
hfp_ag_response_and_hold_state = HFP_RESPONSE_AND_HOLD_HELD_INCOMING_ACCEPTED;
hfp_ag_send_response_and_hold_state(hfp_ag_response_and_hold_state);
@ -1267,7 +1273,7 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
case HFP_AG_RESPONSE_AND_HOLD_REJECT_HELD_CALL_BY_HF:
if (!hfp_ag_response_and_hold_active) break;
if (hfp_ag_response_and_hold_state != HFP_RESPONSE_AND_HOLD_INCOMING_ON_HOLD) break;
hfp_gsm_handle_event(HFP_AG_RESPONSE_AND_HOLD_REJECT_HELD_CALL_BY_AG);
hfp_gsm_handler(HFP_AG_RESPONSE_AND_HOLD_REJECT_HELD_CALL_BY_AG, 0, 0, NULL);
hfp_ag_response_and_hold_active = 0;
hfp_ag_response_and_hold_state = HFP_RESPONSE_AND_HOLD_HELD_INCOMING_REJECTED;
hfp_ag_send_response_and_hold_state(hfp_ag_response_and_hold_state);
@ -1280,16 +1286,18 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
switch (hfp_gsm_call_status()){
case HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS:
switch (hfp_gsm_callsetup_status()){
case HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS:
hfp_gsm_handle_event(HFP_AG_TERMINATE_CALL_BY_HF);
case HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS: {
hfp_gsm_handler(HFP_AG_TERMINATE_CALL_BY_HF, 0, 0, NULL);
}
hfp_ag_set_callsetup_indicator();
hfp_ag_transfer_callsetup_state();
hfp_ag_trigger_reject_call();
log_info("HF Rejected Incoming call, AG terminate call");
break;
case HFP_CALLSETUP_STATUS_OUTGOING_CALL_SETUP_IN_DIALING_STATE:
case HFP_CALLSETUP_STATUS_OUTGOING_CALL_SETUP_IN_ALERTING_STATE:
hfp_gsm_handle_event(HFP_AG_TERMINATE_CALL_BY_HF);
case HFP_CALLSETUP_STATUS_OUTGOING_CALL_SETUP_IN_ALERTING_STATE: {
hfp_gsm_handler(HFP_AG_TERMINATE_CALL_BY_HF, 0, 0, NULL);
}
hfp_ag_set_callsetup_indicator();
hfp_ag_transfer_callsetup_state();
log_info("AG terminate outgoing call process");
@ -1298,8 +1306,9 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
break;
}
break;
case HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT:
hfp_gsm_handle_event(HFP_AG_TERMINATE_CALL_BY_HF);
case HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT: {
hfp_gsm_handler(HFP_AG_TERMINATE_CALL_BY_HF, 0, 0, NULL);
}
hfp_ag_set_call_indicator();
hfp_ag_transfer_call_state();
hfp_connection->call_state = HFP_CALL_IDLE;
@ -1315,8 +1324,9 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
switch (hfp_gsm_call_status()){
case HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS:
switch (hfp_gsm_callsetup_status()){
case HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS:
hfp_gsm_handle_event(HFP_AG_TERMINATE_CALL_BY_AG);
case HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS: {
hfp_gsm_handler(HFP_AG_TERMINATE_CALL_BY_AG, 0, 0, NULL);
}
hfp_ag_set_callsetup_indicator();
hfp_ag_trigger_reject_call();
log_info("AG Rejected Incoming call, AG terminate call");
@ -1325,8 +1335,9 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
break;
}
break;
case HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT:
hfp_gsm_handle_event(HFP_AG_TERMINATE_CALL_BY_AG);
case HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT: {
hfp_gsm_handler(HFP_AG_TERMINATE_CALL_BY_AG, 0, 0, NULL);
}
hfp_ag_set_callsetup_indicator();
hfp_ag_set_call_indicator();
hfp_ag_trigger_terminate_call();
@ -1352,18 +1363,18 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
default:
break;
}
hfp_gsm_handle_event(HFP_AG_CALL_DROPPED);
hfp_gsm_handler(HFP_AG_CALL_DROPPED, 0, 0, NULL);
hfp_ag_set_callsetup_indicator();
hfp_ag_transfer_callsetup_state();
hfp_ag_trigger_terminate_call();
break;
case HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT:
if (hfp_ag_response_and_hold_active) {
hfp_gsm_handle_event(HFP_AG_CALL_DROPPED);
hfp_gsm_handler(HFP_AG_CALL_DROPPED, 0, 0, NULL);
hfp_ag_response_and_hold_state = HFP_RESPONSE_AND_HOLD_HELD_INCOMING_REJECTED;
hfp_ag_send_response_and_hold_state(hfp_ag_response_and_hold_state);
}
hfp_gsm_handle_event(HFP_AG_CALL_DROPPED);
hfp_gsm_handler(HFP_AG_CALL_DROPPED, 0, 0, NULL);
hfp_ag_set_callsetup_indicator();
hfp_ag_set_call_indicator();
hfp_ag_trigger_terminate_call();
@ -1381,7 +1392,7 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
hfp_ag_run_for_context(hfp_connection);
break;
}
hfp_gsm_handle_event_with_call_number(HFP_AG_OUTGOING_CALL_INITIATED, (const char *) &hfp_connection->line_buffer[3]);
hfp_gsm_handler(HFP_AG_OUTGOING_CALL_INITIATED, 0, 0, (const char *) &hfp_connection->line_buffer[3]);
hfp_connection->call_state = HFP_CALL_OUTGOING_INITIATED;
@ -1396,7 +1407,7 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
break;
}
hfp_gsm_handle_event(HFP_AG_OUTGOING_REDIAL_INITIATED);
hfp_gsm_handler(HFP_AG_OUTGOING_REDIAL_INITIATED, 0, 0, NULL);
hfp_connection->call_state = HFP_CALL_OUTGOING_INITIATED;
log_info("Redial last number");
@ -1427,7 +1438,7 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
// trigger callsetup to be
int put_call_on_hold = hfp_gsm_call_status() == HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT;
hfp_gsm_handle_event(HFP_AG_OUTGOING_CALL_ACCEPTED);
hfp_gsm_handler(HFP_AG_OUTGOING_CALL_ACCEPTED, 0, 0, NULL);
hfp_ag_set_callsetup_indicator();
indicator_index = get_ag_indicator_index_for_name("callsetup");
@ -1452,7 +1463,7 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
break;
}
hfp_gsm_handle_event(HFP_AG_OUTGOING_CALL_RINGING);
hfp_gsm_handler(HFP_AG_OUTGOING_CALL_RINGING, 0, 0, NULL);
hfp_connection->call_state = HFP_CALL_OUTGOING_RINGING;
hfp_ag_set_callsetup_indicator();
hfp_ag_transfer_callsetup_state();
@ -1470,7 +1481,7 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
}
int CALLHELD_STATUS_CALL_ON_HOLD_AND_NO_ACTIVE_CALLS = hfp_gsm_callheld_status() == HFP_CALLHELD_STATUS_CALL_ON_HOLD_AND_NO_ACTIVE_CALLS;
hfp_gsm_handle_event(HFP_AG_OUTGOING_CALL_ESTABLISHED);
hfp_gsm_handler(HFP_AG_OUTGOING_CALL_ESTABLISHED, 0, 0, NULL);
hfp_connection->call_state = HFP_CALL_ACTIVE;
hfp_ag_set_callsetup_indicator();
hfp_ag_set_call_indicator();
@ -1483,8 +1494,9 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
break;
}
case HFP_AG_CALL_HOLD_USER_BUSY:
hfp_gsm_handle_event(HFP_AG_CALL_HOLD_USER_BUSY);
case HFP_AG_CALL_HOLD_USER_BUSY: {
hfp_gsm_handler(HFP_AG_CALL_HOLD_USER_BUSY, 0, 0, NULL);
}
hfp_ag_set_callsetup_indicator();
hfp_connection->ag_indicators_status_update_bitmap = store_bit(hfp_connection->ag_indicators_status_update_bitmap, callsetup_indicator_index, 1);
hfp_connection->call_state = HFP_CALL_ACTIVE;
@ -1497,7 +1509,8 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
// Releases all active calls (if any exist) and accepts the other (held or waiting) call.
if (call_held || call_setup_in_progress){
hfp_gsm_handle_event_with_call_index(HFP_AG_CALL_HOLD_RELEASE_ACTIVE_ACCEPT_HELD_OR_WAITING_CALL, hfp_connection->call_index);
hfp_gsm_handler(HFP_AG_CALL_HOLD_RELEASE_ACTIVE_ACCEPT_HELD_OR_WAITING_CALL, hfp_connection->call_index,
0, NULL);
}
@ -1521,7 +1534,8 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
// Places all active calls (if any exist) on hold and accepts the other (held or waiting) call.
// only update if callsetup changed
int call_setup_in_progress = hfp_gsm_callsetup_status() != HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
hfp_gsm_handle_event_with_call_index(HFP_AG_CALL_HOLD_PARK_ACTIVE_ACCEPT_HELD_OR_WAITING_CALL, hfp_connection->call_index);
hfp_gsm_handler(HFP_AG_CALL_HOLD_PARK_ACTIVE_ACCEPT_HELD_OR_WAITING_CALL, hfp_connection->call_index, 0,
NULL);
if (call_setup_in_progress){
log_info("AG: Call on Hold, Accept new call");
@ -1542,7 +1556,7 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
// Adds a held call to the conversation.
if (hfp_gsm_callheld_status() != HFP_CALLHELD_STATUS_NO_CALLS_HELD){
log_info("AG: Join 3-way-call");
hfp_gsm_handle_event(HFP_AG_CALL_HOLD_ADD_HELD_CALL);
hfp_gsm_handler(HFP_AG_CALL_HOLD_ADD_HELD_CALL, 0, 0, NULL);
hfp_ag_set_callheld_indicator();
hfp_connection->ag_indicators_status_update_bitmap = store_bit(hfp_connection->ag_indicators_status_update_bitmap, callheld_indicator_index, 1);
hfp_emit_simple_event(hfp_connection, HFP_SUBEVENT_CONFERENCE_CALL);
@ -1551,7 +1565,9 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * hfp_con
break;
case HFP_AG_CALL_HOLD_EXIT_AND_JOIN_CALLS:
// Connects the two calls and disconnects the subscriber from both calls (Explicit Call Transfer)
hfp_gsm_handle_event(HFP_AG_CALL_HOLD_EXIT_AND_JOIN_CALLS);
{
hfp_gsm_handler(HFP_AG_CALL_HOLD_EXIT_AND_JOIN_CALLS, 0, 0, NULL);
}
log_info("AG: Transfer call -> Connect two calls and disconnect");
hfp_ag_set_call_indicator();
hfp_ag_set_callheld_indicator();
@ -2189,7 +2205,7 @@ void hfp_ag_incoming_call(void){
* @brief number is stored.
*/
void hfp_ag_set_clip(uint8_t type, const char * number){
hfp_gsm_handle_event_with_clip(HFP_AG_SET_CLIP, type, number);
hfp_gsm_handler(HFP_AG_SET_CLIP, 0, type, number);
}
void hfp_ag_call_dropped(void){

View File

@ -71,7 +71,6 @@ static uint8_t clip_type;
static char clip_number[HFP_GSM_MAX_CALL_NUMBER_SIZE];
static char last_dialed_number[HFP_GSM_MAX_CALL_NUMBER_SIZE];
static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t type, const char * number);
static inline int get_number_active_calls(void);
static void set_callsetup_status(hfp_callsetup_status_t status){
@ -363,23 +362,7 @@ int hfp_gsm_call_possible(void){
return get_number_none_calls() > 0;
}
void hfp_gsm_handle_event(hfp_ag_call_event_t event){
hfp_gsm_handler(event, 0, 0, NULL);
}
void hfp_gsm_handle_event_with_clip(hfp_ag_call_event_t event, uint8_t type, const char * number){
hfp_gsm_handler(event, 0, type, number);
}
void hfp_gsm_handle_event_with_call_index(hfp_ag_call_event_t event, uint8_t index){
hfp_gsm_handler(event, index, 0, NULL);
}
void hfp_gsm_handle_event_with_call_number(hfp_ag_call_event_t event, const char * number){
hfp_gsm_handler(event, 0, 0, number);
}
static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t type, const char * number){
void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t type, const char * number){
int next_free_slot = get_next_free_slot();
int current_call_index = get_active_call_index();
int initiated_call_index = get_initiated_call_index();

View File

@ -84,10 +84,7 @@ char * hfp_gsm_clip_number(void);
void hfp_gsm_init(void);
void hfp_gsm_handle_event_with_clip(hfp_ag_call_event_t event, uint8_t type, const char * number);
void hfp_gsm_handle_event_with_call_index(hfp_ag_call_event_t event, uint8_t index);
void hfp_gsm_handle_event_with_call_number(hfp_ag_call_event_t event, const char * number);
void hfp_gsm_handle_event(hfp_ag_call_event_t event);
void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t type, const char * number);
/* API_END */