OSDN Git Service

Update call state before opening SCO.
authorMallikarjuna GB <gbmalli@codeaurora.org>
Fri, 28 Nov 2014 04:51:15 +0000 (10:21 +0530)
committerAndre Eisenbach <eisenbach@google.com>
Thu, 4 Jun 2015 17:33:30 +0000 (10:33 -0700)
This change makes sure to update the current
call state before opening SCO connection when
incoming call is answered. Some car kits are
strict in checking this sequence and go in
bad state if not done this way.

Change-Id: Ie744dc26c02d897eaf016ee73022bfc2a0db067e

bta/ag/bta_ag_cmd.c

index e592404..a0564d9 100755 (executable)
@@ -1488,28 +1488,22 @@ void bta_ag_hfp_result(tBTA_AG_SCB *p_scb, tBTA_AG_API_RESULT *p_result)
             /* stop ring timer */
             bta_sys_stop_timer(&p_scb->act_timer);
 
-            /* if sco not opened and we need to open it, open sco first
-            ** then send indicators
+            /* if sco not opened and we need to open it, send indicators first
+            ** then  open sco.
             */
-            if (p_result->data.audio_handle == bta_ag_scb_to_idx(p_scb) &&
-                !bta_ag_sco_is_open(p_scb) && !(p_scb->features & BTA_AG_FEAT_NOSCO))
-            {
-                p_scb->post_sco = BTA_AG_POST_SCO_CALL_CONN;
-                bta_ag_sco_open(p_scb, (tBTA_AG_DATA *) p_result);
-            }
-            /* else if sco open and we need to close it, close sco first
-            ** then send indicators
-            */
-            else if (p_result->data.audio_handle == BTA_AG_HANDLE_NONE &&
-                     bta_ag_sco_is_open(p_scb) && !(p_scb->features & BTA_AG_FEAT_NOSCO))
-            {
-                p_scb->post_sco = BTA_AG_POST_SCO_CALL_CONN;
-                bta_ag_sco_close(p_scb, (tBTA_AG_DATA *) p_result);
-            }
-            /* else send indicators now */
-            else
+            bta_ag_send_call_inds(p_scb, p_result->result);
+
+            if (!(p_scb->features & BTA_AG_FEAT_NOSCO))
             {
-                bta_ag_send_call_inds(p_scb, p_result->result);
+                if (p_result->data.audio_handle == bta_ag_scb_to_idx(p_scb))
+                {
+                    bta_ag_sco_open(p_scb, (tBTA_AG_DATA *) p_result);
+                }
+                else if ((p_result->data.audio_handle == BTA_AG_HANDLE_NONE) &&
+                        bta_ag_sco_is_open(p_scb))
+                {
+                    bta_ag_sco_close(p_scb, (tBTA_AG_DATA *) p_result);
+                }
             }
             break;