From c3aa28eb96782e966d3b044eb9edeeedaa95bd39 Mon Sep 17 00:00:00 2001 From: Anubhav Gupta Date: Thu, 13 Mar 2014 19:16:29 +0530 Subject: [PATCH] Reject second AVRCP connection. This change rejects the RC connection from second device if the DUT is already connected to RC of first device. This addresses the problem of improper closure of Uinput device on disconnection of Avrcp to make sure Avrcp passthrough commands work as desired. Change-Id: If2e39cd90575baffd0e4442b8e7cd2a91eebdf56 --- btif/src/btif_rc.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/btif/src/btif_rc.c b/btif/src/btif_rc.c index 5a88321be..365f0fc62 100644 --- a/btif/src/btif_rc.c +++ b/btif/src/btif_rc.c @@ -423,6 +423,19 @@ void handle_rc_connect (tBTA_AV_RC_OPEN *p_rc_open) if(p_rc_open->status == BTA_AV_SUCCESS) { + //check if already some RC is connected + if (btif_rc_cb.rc_connected) + { + BTIF_TRACE_ERROR("Got RC OPEN in connected state, Connected RC: %d \ + and Current RC: %d", btif_rc_cb.rc_handle,p_rc_open->rc_handle ); + if ((btif_rc_cb.rc_handle != p_rc_open->rc_handle) + && (bdcmp(btif_rc_cb.rc_addr, p_rc_open->peer_addr))) + { + BTIF_TRACE_DEBUG("Got RC connected for some other handle"); + BTA_AvCloseRc(p_rc_open->rc_handle); + return; + } + } memcpy(btif_rc_cb.rc_addr, p_rc_open->peer_addr, sizeof(BD_ADDR)); btif_rc_cb.rc_features = p_rc_open->peer_features; btif_rc_cb.rc_vol_label=MAX_LABEL; @@ -471,6 +484,12 @@ void handle_rc_disconnect (tBTA_AV_RC_CLOSE *p_rc_close) tBTA_AV_FEAT features; #endif BTIF_TRACE_DEBUG("%s: rc_handle: %d", __FUNCTION__, p_rc_close->rc_handle); + if ((p_rc_close->rc_handle != btif_rc_cb.rc_handle) + && (bdcmp(btif_rc_cb.rc_addr, p_rc_close->peer_addr))) + { + BTIF_TRACE_ERROR("Got disconnect of unknown device"); + return; + } btif_rc_cb.rc_handle = 0; btif_rc_cb.rc_connected = FALSE; -- 2.11.0