From a8714e14a650c1475394ad303e251cc009ce4272 Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Thu, 19 Nov 2015 12:39:19 +0100 Subject: [PATCH] hfp: ag terminates call --- src/hfp_ag.c | 14 +++++++++----- test/hfp/hfp_ag_client_test.c | 3 +++ test/hfp/test_sequences.c | 21 ++++++++++++++++++++- test/hfp/test_sequences.h | 7 +++++++ 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/hfp_ag.c b/src/hfp_ag.c index bc80a3218..5cac2551e 100644 --- a/src/hfp_ag.c +++ b/src/hfp_ag.c @@ -605,17 +605,22 @@ static int incoming_call_state_machine(hfp_connection_t * context){ if (context->state < HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED) return 0; // printf(" -> State machine: Incoming Call\n"); - int done = 0; hfp_ag_indicator_t * indicator; if (context->terminate_call){ printf(" -> State machine: Terminate Incoming Call\n"); - // TODO, reset flags + indicator = get_ag_indicator_for_name("call"); + if (!indicator) return 0; + + indicator->status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS; + hfp_ag_transfer_ag_indicators_status_cmd(context->rfcomm_cid, indicator); + context->terminate_call = 0; context->run_call_state_machine = 0; - return done; + return 1; } + int done = 0; switch (context->call_state){ case HFP_CALL_IDLE: //printf(" HFP_CALL_TRIGGER_AUDIO_CONNECTION \n"); @@ -685,7 +690,7 @@ static int incoming_call_state_machine(hfp_connection_t * context){ } return 0; case HFP_CALL_ACTIVE: - //printf(" HFP_CALL_ACTIVE \n"); + printf(" HFP_CALL_ACTIVE \n"); break; default: break; @@ -908,7 +913,6 @@ void hfp_ag_terminate_call(void){ linked_list_iterator_init(&it, hfp_get_connections()); while (linked_list_iterator_has_next(&it)){ hfp_connection_t * connection = (hfp_connection_t *)linked_list_iterator_next(&it); - if (connection->state != HFP_AUDIO_CONNECTION_ESTABLISHED) return; connection->terminate_call = 1; hfp_run_for_context(connection); } diff --git a/test/hfp/hfp_ag_client_test.c b/test/hfp/hfp_ag_client_test.c index 27119ecc7..09a301511 100644 --- a/test/hfp/hfp_ag_client_test.c +++ b/test/hfp/hfp_ag_client_test.c @@ -229,6 +229,9 @@ TEST(HFPClient, HFAnswerIncomingCallWithInBandRingTone){ simulate_test_sequence(alert_ic_setup(), alert_ic_setup_size()); CHECK_EQUAL(stop_ringing, 1); + + hfp_ag_terminate_call(); + simulate_test_sequence(terminate_ic_ag_setup(), terminate_ic_ag_setup_size()); } diff --git a/test/hfp/test_sequences.c b/test/hfp/test_sequences.c index 4f66cc1f4..d852d4fe5 100644 --- a/test/hfp/test_sequences.c +++ b/test/hfp/test_sequences.c @@ -181,7 +181,19 @@ const char * ic_alert_test1[] = { "NOP", "+CIEV:2,1", // call = 1 "NOP", - "+CIEV:3,0" + "+CIEV:3,0", +}; + +const char * ic_ag_terminates_call[] = { + // AG terminates call + "+CIEV:2,0" +}; + +const char * ic_hf_terminates_call[] = { + // HF terminates call + "AT+CHUP", + "OK" + "+CIEV:2,0" }; hfp_test_item_t ic_tests[] = { @@ -221,4 +233,11 @@ int default_ic_setup_size(){ return sizeof(ic_test1)/sizeof(char*);} char ** alert_ic_setup() { return (char **)ic_alert_test1;} int alert_ic_setup_size(){ return sizeof(ic_alert_test1)/sizeof(char*);} + + +char ** terminate_ic_ag_setup() { return (char **)ic_ag_terminates_call;} +int terminate_ic_ag_setup_size(){ return sizeof(ic_ag_terminates_call)/sizeof(char*);} + +char ** terminate_ic_hf_setup() { return (char **)ic_hf_terminates_call;} +int terminate_ic_hf_setup_size(){ return sizeof(ic_hf_terminates_call)/sizeof(char*);} \ No newline at end of file diff --git a/test/hfp/test_sequences.h b/test/hfp/test_sequences.h index 6b669759d..c4378a791 100644 --- a/test/hfp/test_sequences.h +++ b/test/hfp/test_sequences.h @@ -76,3 +76,10 @@ int default_ic_setup_size(); char ** alert_ic_setup(); int alert_ic_setup_size(); + +char ** terminate_ic_ag_setup(); +int terminate_ic_ag_setup_size(); + +char ** terminate_ic_hf_setup(); +int terminate_ic_hf_setup_size(); +