summaryrefslogtreecommitdiffstats
path: root/btif
diff options
context:
space:
mode:
authorGanesh Ganapathi Batta <ganeshg@broadcom.com>2012-05-17 14:19:22 -0700
committerMatthew Xie <mattx@google.com>2012-07-14 11:19:21 -0700
commit104a50ef31fdf9f378f7fb8d3c6466ff32bb0b72 (patch)
tree92c382a11b03972ed9f5bc3ea32d919d28fb6043 /btif
parent193262bd8e44e392a4bf2f3ac0705e6d3e101ee1 (diff)
downloadexternal_bluetooth_bluedroid-104a50ef31fdf9f378f7fb8d3c6466ff32bb0b72.zip
external_bluetooth_bluedroid-104a50ef31fdf9f378f7fb8d3c6466ff32bb0b72.tar.gz
external_bluetooth_bluedroid-104a50ef31fdf9f378f7fb8d3c6466ff32bb0b72.tar.bz2
Drop the automatic AVRCP Play command sent from the remote right after the call is terminated if the remote device is a non headset.
This change is to fix the interop issues with few carkits. Change-Id: I2e2fc51ed6bbf98f0e994a512588782791c6ea82
Diffstat (limited to 'btif')
-rwxr-xr-xbtif/src/btif_hf.c39
-rwxr-xr-x[-rw-r--r--]btif/src/btif_rc.c22
2 files changed, 61 insertions, 0 deletions
diff --git a/btif/src/btif_hf.c b/btif/src/btif_hf.c
index 2db01fd..5851efa 100755
--- a/btif/src/btif_hf.c
+++ b/btif/src/btif_hf.c
@@ -102,6 +102,8 @@
#define BTIF_HF_ID_1 0
+#define BTIF_HF_CALL_END_TIMEOUT 6
+
/************************************************************************************
** Local type definitions
************************************************************************************/
@@ -146,6 +148,7 @@ typedef struct _btif_hf_cb
tBTA_AG_PEER_FEAT peer_feat;
int num_active;
int num_held;
+ struct timespec call_end_timestamp;
bthf_call_state_t call_setup_state;
} btif_hf_cb_t;
@@ -481,6 +484,9 @@ static bt_status_t init( bthf_callbacks_t* callbacks )
* Internally, the HSP_SERVICE_ID shall also be enabled */
btif_enable_service(BTA_HFP_SERVICE_ID);
+ btif_hf_cb.call_end_timestamp.tv_sec = 0;
+ btif_hf_cb.call_end_timestamp.tv_nsec = 0;
+
return BT_STATUS_SUCCESS;
}
@@ -904,6 +910,13 @@ static bt_status_t phone_state_change(int num_active, int num_held, bthf_call_st
if (num_active == 0 && num_held == 0 && call_setup_state == BTHF_CALL_STATE_IDLE)
{
BTIF_TRACE_DEBUG1("%s: Phone on hook", __FUNCTION__);
+
+ /* record call termination timestamp if there was an active/held call or callsetup state > BTHF_CALL_STATE_IDLE */
+ if ((btif_hf_cb.call_setup_state != BTHF_CALL_STATE_IDLE ) || (btif_hf_cb.num_active) ||(btif_hf_cb.num_held))
+ {
+ BTIF_TRACE_DEBUG1("%s: Record call termination timestamp", __FUNCTION__);
+ clock_gettime(CLOCK_MONOTONIC, &btif_hf_cb.call_end_timestamp);
+ }
BTA_AgResult (BTA_AG_HANDLE_ALL, BTA_AG_END_CALL_RES, NULL);
/* if held call was present, reset that as well */
@@ -1064,6 +1077,32 @@ update_call_states:
return status;
}
+
+/*******************************************************************************
+**
+** Function btif_hf_call_terminated_recently
+**
+** Description Checks if a call has been terminated
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+BOOLEAN btif_hf_call_terminated_recently()
+{
+ struct timespec now;
+
+ clock_gettime(CLOCK_MONOTONIC, &now);
+ if (now.tv_sec < btif_hf_cb.call_end_timestamp.tv_sec + BTIF_HF_CALL_END_TIMEOUT)
+ {
+ return TRUE;
+ }
+ else
+ {
+ btif_hf_cb.call_end_timestamp.tv_sec = 0;
+ return FALSE;
+ }
+}
+
/*******************************************************************************
**
** Function cleanup
diff --git a/btif/src/btif_rc.c b/btif/src/btif_rc.c
index 7aab520..24133cc 100644..100755
--- a/btif/src/btif_rc.c
+++ b/btif/src/btif_rc.c
@@ -74,6 +74,10 @@
#error "AVRCP 1.3 is not supported on Bluedroid yet."
#endif
+/* cod value for Headsets */
+#define COD_AV_HEADSETS 0x0404
+
+
/*****************************************************************************
** Local type definitions
******************************************************************************/
@@ -127,6 +131,9 @@ static btif_rc_cb_t btif_rc_cb;
/*****************************************************************************
** Externs
******************************************************************************/
+extern BOOLEAN btif_hf_call_terminated_recently();
+extern BOOLEAN check_cod(const bt_bdaddr_t *remote_bdaddr, uint32_t cod);
+
/*****************************************************************************
** Functions
@@ -327,6 +334,21 @@ void handle_rc_passthrough_cmd ( tBTA_AV_REMOTE_CMD *p_remote_cmd)
pressed = 1;
}
+ /* If this is Play command (press or release) before processing, check the following
+ *a voice call has ended recently
+ * the remote device is not of type headset
+ * If the above conditions meet, drop the Play command
+ *This fix is to interop with certain carkits which sends an automatic PLAY commands right after call ends
+ */
+ if((p_remote_cmd->rc_id == BTA_AV_RC_PLAY )&&
+ (btif_hf_call_terminated_recently() == TRUE) &&
+ (check_cod( (const bt_bdaddr_t*)&(btif_rc_cb.rc_addr), COD_AV_HEADSETS) != TRUE))
+ {
+ BTIF_TRACE_DEBUG1("%s:Dropping the play command received right after call end",
+ __FUNCTION__);
+ return;
+ }
+
for (i = 0; key_map[i].name != NULL; i++) {
if (p_remote_cmd->rc_id == key_map[i].avrcp) {
BTIF_TRACE_DEBUG3("%s: %s %s", __FUNCTION__, key_map[i].name, status);