TWSP-HFP: update BVRA state to both earbuds (2/2)

 - When VR is initiated/ended from earbud, response OK/ERROR to
   the requesting earbud, and send +BVRA to the other earbud while
   response OK.
 - When VR is initiated/ended from phone UI, send +BVRA to both
   earbuds.

Change-Id: Ifc5479a98d36421bc340b780db4a324ca709f7a5
CRs-Fixed: 2478343
diff --git a/system_bt_ext/btif/include/btif_twsp_hf.h b/system_bt_ext/btif/include/btif_twsp_hf.h
index 0b11ca9..2c9c7c4 100644
--- a/system_bt_ext/btif/include/btif_twsp_hf.h
+++ b/system_bt_ext/btif/include/btif_twsp_hf.h
@@ -47,5 +47,7 @@
 
 int btif_hf_get_other_connected_twsp_index(int idx);
 
+void btif_hf_twsp_send_bvra_update(int idx, tBTA_AG_RES_DATA* ag_res);
+
 }  // namespace headset
 }  // namespace bluetooth
diff --git a/system_bt_ext/btif/src/btif_twsp_hf.cc b/system_bt_ext/btif/src/btif_twsp_hf.cc
index 52ab07d..029df6d 100644
--- a/system_bt_ext/btif/src/btif_twsp_hf.cc
+++ b/system_bt_ext/btif/src/btif_twsp_hf.cc
@@ -123,6 +123,24 @@
     return btif_max_hf_clients;
 }
 
+/*******************************************************************************
+**
+** Function         btif_hf_twsp_send_bvra_update
+**
+** Description      Send BVRA update for connected TWS+ peer earbud
+**
+** Returns          void
+**
+*******************************************************************************/
+
+void btif_hf_twsp_send_bvra_update(int current_index, tBTA_AG_RES_DATA* ag_res) {
+    int peer_eb_idx = btif_hf_get_other_connected_twsp_index(current_index);
+    if ((peer_eb_idx >= 0) && (peer_eb_idx < BTA_AG_MAX_NUM_CLIENTS) &&
+        (btif_hf_cb[peer_eb_idx].peer_feat & BTA_AG_PEER_FEAT_VREC)) {
+        BTIF_TRACE_DEBUG("%s: Send BVRA update for peer earbud, idx: %d", __func__, peer_eb_idx);
+        BTA_AgResult(btif_hf_cb[peer_eb_idx].handle, BTA_AG_BVRA_RES, ag_res);
+    }
+}
 
 }  // namespace headset
 }  // namespace bluetooth