diff options
author | Ayan Ghosh <abghosh@codeaurora.org> | 2014-07-25 17:51:32 +0530 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:21:46 -0600 |
commit | eceafe97c9a07a5bf4e5f84cadaad3b731c38d21 (patch) | |
tree | daa810c800a3e34ae6c812f51b5d279aeac2fd23 /stack/avrc/avrc_api.c | |
parent | 0887ba37967b83b0264f9f336f5f3d8074daf761 (diff) | |
download | android_system_bt-eceafe97c9a07a5bf4e5f84cadaad3b731c38d21.tar.gz android_system_bt-eceafe97c9a07a5bf4e5f84cadaad3b731c38d21.tar.bz2 android_system_bt-eceafe97c9a07a5bf4e5f84cadaad3b731c38d21.zip |
AVRCP 1.5 Implementation.
AVRCP 1.5 Implementation
Change-Id: Ia35dc4344b05584cf5ab3b463815c9e6297d24ab
Proper check to ensure attributes are populated properly
Incorporated proper check to ensure if memory is allocated properly
then all requested attributes are populated in response from DUT.
CRs-Fixed: 753309
Change-Id: Iead549635cd2059bc8cf33585a5d87ae023149d4
Reset Browsing Bit if carkit is blacklisted
- Reset Browsing bit if carkit is blacklisted for avrcp 1.5.
- Not to send 1.3+ specific supported events if carkit is blacklisted.
CRs-Fixed: 762470
Change-Id: I32ac80c0549b2b89dd2522dbb0dea89d255d33dc
Free Browse packet
Free Borwse packet in AVRC layer once the same is
copied to BTA for further processing.
CRs-Fixed: 785286
Change-Id: I8037a649cff5a1e527c28ba36999a1bed34d315a
BTIF-AV: Use valid memory for AVRCP message
After the context switch to BTIF for META message processing
the buffer allocated for tAVRC_MSG will be freed, hence allocate
the required memory and free that after handling the META
message.
Conflicts:
stack/avrc/avrc_api.c
Crs-Fixed: 651506
Change-Id: Icbf61776a6fb63fac1555bf25d3700beccf2b67a
Diffstat (limited to 'stack/avrc/avrc_api.c')
-rwxr-xr-x | stack/avrc/avrc_api.c | 385 |
1 files changed, 201 insertions, 184 deletions
diff --git a/stack/avrc/avrc_api.c b/stack/avrc/avrc_api.c index 1b874dc8c..359d910ec 100755 --- a/stack/avrc/avrc_api.c +++ b/stack/avrc/avrc_api.c @@ -150,7 +150,7 @@ static void avrc_prep_end_frag(UINT8 handle) UINT8 *p_data, *p_orig_data; UINT8 rsp_type; - AVRC_TRACE_DEBUG ("avrc_prep_end_frag" ); + AVRC_TRACE_DEBUG("avrc_prep_end_frag" ); p_fcb = &avrc_cb.fcb[handle]; /* The response type of the end fragment should be the same as the the PDU of "End Fragment @@ -226,7 +226,7 @@ static void avrc_send_continue_frag(UINT8 handle, UINT8 label) p_pkt = p_fcb->p_fmsg; p_fcb->p_fmsg = NULL; p_fcb->frag_enabled = FALSE; - AVRC_TRACE_ERROR ("AVRC_MsgReq no buffers for fragmentation - send internal error" ); + AVRC_TRACE_ERROR("AVRC_MsgReq no buffers for fragmentation - send internal error" ); p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset; *p_data++ = AVRC_PDU_REQUEST_CONTINUATION_RSP; *p_data++ = 0; @@ -274,7 +274,7 @@ static BT_HDR * avrc_proc_vendor_command(UINT8 handle, UINT8 label, if (pkt_type != AVRC_PKT_SINGLE) { /* reject - commands can only be in single packets at AVRCP level */ - AVRC_TRACE_ERROR ("commands must be in single packet pdu:0x%x", *p_data ); + AVRC_TRACE_ERROR("commands must be in single packet pdu:0x%x", *p_data ); /* use the current GKI buffer to send the reject */ status = AVRC_STS_BAD_CMD; } @@ -390,7 +390,7 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_ p_data += AVRC_VENDOR_HDR_SIZE; pkt_type = *(p_data + 1) & AVRC_PKT_TYPE_MASK; - AVRC_TRACE_DEBUG ("pkt_type %d", pkt_type ); + AVRC_TRACE_DEBUG("pkt_type %d", pkt_type ); p_rcb = &avrc_cb.rcb[handle]; if (p_msg->company_id == AVRC_CO_METADATA) { @@ -433,7 +433,7 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_ { /* Unable to allocate buffer for fragmented avrc message. Reuse START buffer for reassembly (re-assembled message may fit into ACL buf) */ - AVRC_TRACE_DEBUG ("Unable to allocate buffer for fragmented avrc message, \ + AVRC_TRACE_DEBUG("Unable to allocate buffer for fragmented avrc message, \ reusing START buffer for reassembly"); p_rcb->rasm_offset = p_pkt->offset; p_rcb->p_rmsg = p_pkt; @@ -447,7 +447,7 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_ { /* Received a CONTINUE/END, but no corresponding START (or previous fragmented response was dropped) */ - AVRC_TRACE_DEBUG ("Received a CONTINUE/END without no corresponding START \ + AVRC_TRACE_DEBUG("Received a CONTINUE/END without no corresponding START \ (or previous fragmented response was dropped)"); drop_code = 5; GKI_freebuf(p_pkt); @@ -551,6 +551,7 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr, UINT8 opcode; tAVRC_MSG msg; UINT8 *p_data; + UINT8 *browse_length; UINT8 *p_begin; BOOLEAN drop = FALSE; BOOLEAN do_free = TRUE; @@ -585,111 +586,100 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr, p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset; memset(&msg, 0, sizeof(tAVRC_MSG) ); + /* layer_specific value use to distinguish + * Browsing and control channel PDU ID. + * AVCT_DATA_BROWSE to be used for browsing + * channel + */ + AVRC_TRACE_DEBUG("layer_specific %x",p_pkt->layer_specific); + if (p_pkt->layer_specific != AVCT_DATA_BROWSE) { - msg.hdr.ctype = p_data[0] & AVRC_CTYPE_MASK; - AVRC_TRACE_DEBUG("avrc_msg_cback handle:%d, ctype:%d, offset:%d, len: %d", - handle, msg.hdr.ctype, p_pkt->offset, p_pkt->len); - msg.hdr.subunit_type = (p_data[1] & AVRC_SUBTYPE_MASK) >> AVRC_SUBTYPE_SHIFT; - msg.hdr.subunit_id = p_data[1] & AVRC_SUBID_MASK; - opcode = p_data[2]; - } - - if ( ((avrc_cb.ccb[handle].control & AVRC_CT_TARGET) && (cr == AVCT_CMD)) || - ((avrc_cb.ccb[handle].control & AVRC_CT_CONTROL) && (cr == AVCT_RSP)) ) - { - - switch(opcode) { - case AVRC_OP_UNIT_INFO: - if (cr == AVCT_CMD) - { - /* send the response to the peer */ - p_rsp = avrc_copy_packet(p_pkt, AVRC_OP_UNIT_INFO_RSP_LEN); - p_rsp_data = avrc_get_data_ptr(p_rsp); - *p_rsp_data = AVRC_RSP_IMPL_STBL; - /* check & set the offset. set response code, set subunit_type & subunit_id, - set AVRC_OP_UNIT_INFO */ - /* 3 bytes: ctype, subunit*, opcode */ - p_rsp_data += AVRC_AVC_HDR_SIZE; - *p_rsp_data++ = 7; - /* Panel subunit & id=0 */ - *p_rsp_data++ = (AVRC_SUB_PANEL << AVRC_SUBTYPE_SHIFT); - AVRC_CO_ID_TO_BE_STREAM(p_rsp_data, avrc_cb.ccb[handle].company_id); - p_rsp->len = (UINT16) (p_rsp_data - (UINT8 *)(p_rsp + 1) - p_rsp->offset); - cr = AVCT_RSP; -#if (BT_USE_TRACES == TRUE) - p_drop_msg = "auto respond"; -#endif - } - else - { - /* parse response */ - p_data += 4; /* 3 bytes: ctype, subunit*, opcode + octet 3 (is 7)*/ - msg.unit.unit_type = (*p_data & AVRC_SUBTYPE_MASK) >> AVRC_SUBTYPE_SHIFT; - msg.unit.unit = *p_data & AVRC_SUBID_MASK; - p_data++; - AVRC_BE_STREAM_TO_CO_ID(msg.unit.company_id, p_data); - } - break; + msg.hdr.ctype = p_data[0] & AVRC_CTYPE_MASK; + AVRC_TRACE_DEBUG("avrc_msg_cback handle:%d, ctype:%d, offset:%d, len: %d", + handle, msg.hdr.ctype, p_pkt->offset, p_pkt->len); + msg.hdr.subunit_type = (p_data[1] & AVRC_SUBTYPE_MASK) >> AVRC_SUBTYPE_SHIFT; + msg.hdr.subunit_id = p_data[1] & AVRC_SUBID_MASK; + opcode = p_data[2]; + } - case AVRC_OP_SUB_INFO: - if (cr == AVCT_CMD) + if ( ((avrc_cb.ccb[handle].control & AVRC_CT_TARGET) && (cr == AVCT_CMD)) || + ((avrc_cb.ccb[handle].control & AVRC_CT_CONTROL) && (cr == AVCT_RSP)) ) + { + switch(opcode) { - /* send the response to the peer */ - p_rsp = avrc_copy_packet(p_pkt, AVRC_OP_SUB_UNIT_INFO_RSP_LEN); - p_rsp_data = avrc_get_data_ptr(p_rsp); - *p_rsp_data = AVRC_RSP_IMPL_STBL; - /* check & set the offset. set response code, set (subunit_type & subunit_id), - set AVRC_OP_SUB_INFO, set (page & extention code) */ - p_rsp_data += 4; - /* Panel subunit & id=0 */ - *p_rsp_data++ = (AVRC_SUB_PANEL << AVRC_SUBTYPE_SHIFT); - memset(p_rsp_data, AVRC_CMD_OPRND_PAD, AVRC_SUBRSP_OPRND_BYTES); - p_rsp_data += AVRC_SUBRSP_OPRND_BYTES; - p_rsp->len = (UINT16) (p_rsp_data - (UINT8 *)(p_rsp + 1) - p_rsp->offset); - cr = AVCT_RSP; + case AVRC_OP_UNIT_INFO: + if (cr == AVCT_CMD) + { + /* send the response to the peer */ + p_rsp = avrc_copy_packet(p_pkt, AVRC_OP_UNIT_INFO_RSP_LEN); + p_rsp_data = avrc_get_data_ptr(p_rsp); + *p_rsp_data = AVRC_RSP_IMPL_STBL; + /* check & set the offset. set response code, set subunit_type & subunit_id, + set AVRC_OP_UNIT_INFO */ + /* 3 bytes: ctype, subunit*, opcode */ + p_rsp_data += AVRC_AVC_HDR_SIZE; + *p_rsp_data++ = 7; + /* Panel subunit & id=0 */ + *p_rsp_data++ = (AVRC_SUB_PANEL << AVRC_SUBTYPE_SHIFT); + AVRC_CO_ID_TO_BE_STREAM(p_rsp_data, avrc_cb.ccb[handle].company_id); + p_rsp->len = (UINT16) (p_rsp_data - (UINT8 *)(p_rsp + 1) - p_rsp->offset); + cr = AVCT_RSP; #if (BT_USE_TRACES == TRUE) - p_drop_msg = "auto responded"; + p_drop_msg = "auto respond"; #endif - } - else - { - /* parse response */ - p_data += AVRC_AVC_HDR_SIZE; /* 3 bytes: ctype, subunit*, opcode */ - msg.sub.page = (*p_data++ >> AVRC_SUB_PAGE_SHIFT) & AVRC_SUB_PAGE_MASK; - xx = 0; - while (*p_data != AVRC_CMD_OPRND_PAD && xx<AVRC_SUB_TYPE_LEN) + } + else { - msg.sub.subunit_type[xx] = *p_data++ >> AVRC_SUBTYPE_SHIFT; - if (msg.sub.subunit_type[xx] == AVRC_SUB_PANEL) - msg.sub.panel = TRUE; - xx++; + /* parse response */ + p_data += 4; /* 3 bytes: ctype, subunit*, opcode + octet 3 (is 7)*/ + msg.unit.unit_type = (*p_data & AVRC_SUBTYPE_MASK) >> AVRC_SUBTYPE_SHIFT; + msg.unit.unit = *p_data & AVRC_SUBID_MASK; + p_data++; + AVRC_BE_STREAM_TO_CO_ID(msg.unit.company_id, p_data); } - } - break; + break; - case AVRC_OP_VENDOR: - p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset; - p_begin = p_data; - if (p_pkt->len < AVRC_VENDOR_HDR_SIZE) /* 6 = ctype, subunit*, opcode & CO_ID */ - { + case AVRC_OP_SUB_INFO: if (cr == AVCT_CMD) - reject = TRUE; + { + /* send the response to the peer */ + p_rsp = avrc_copy_packet(p_pkt, AVRC_OP_SUB_UNIT_INFO_RSP_LEN); + p_rsp_data = avrc_get_data_ptr(p_rsp); + *p_rsp_data = AVRC_RSP_IMPL_STBL; + /* check & set the offset. set response code, set (subunit_type & subunit_id), + set AVRC_OP_SUB_INFO, set (page & extention code) */ + p_rsp_data += 4; + /* Panel subunit & id=0 */ + *p_rsp_data++ = (AVRC_SUB_PANEL << AVRC_SUBTYPE_SHIFT); + memset(p_rsp_data, AVRC_CMD_OPRND_PAD, AVRC_SUBRSP_OPRND_BYTES); + p_rsp_data += AVRC_SUBRSP_OPRND_BYTES; + p_rsp->len = (UINT16) (p_rsp_data - (UINT8 *)(p_rsp + 1) - p_rsp->offset); + cr = AVCT_RSP; +#if (BT_USE_TRACES == TRUE) + p_drop_msg = "auto responded"; +#endif + } else - drop = TRUE; + { + /* parse response */ + p_data += AVRC_AVC_HDR_SIZE; /* 3 bytes: ctype, subunit*, opcode */ + msg.sub.page = (*p_data++ >> AVRC_SUB_PAGE_SHIFT) & AVRC_SUB_PAGE_MASK; + xx = 0; + while (*p_data != AVRC_CMD_OPRND_PAD && xx<AVRC_SUB_TYPE_LEN) + { + msg.sub.subunit_type[xx] = *p_data++ >> AVRC_SUBTYPE_SHIFT; + if (msg.sub.subunit_type[xx] == AVRC_SUB_PANEL) + msg.sub.panel = TRUE; + xx++; + } + } break; - } - p_data += AVRC_AVC_HDR_SIZE; /* skip the first 3 bytes: ctype, subunit*, opcode */ - AVRC_BE_STREAM_TO_CO_ID(p_msg->company_id, p_data); - p_msg->p_vendor_data = p_data; - p_msg->vendor_len = p_pkt->len - (p_data - p_begin); -#if (AVRC_METADATA_INCLUDED == TRUE) - UINT8 drop_code = 0; - if (p_msg->company_id == AVRC_CO_METADATA) - { - /* Validate length for metadata message */ - if (p_pkt->len < (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE)) + case AVRC_OP_VENDOR: + p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset; + p_begin = p_data; + if (p_pkt->len < AVRC_VENDOR_HDR_SIZE) /* 6 = ctype, subunit*, opcode & CO_ID */ { if (cr == AVCT_CMD) reject = TRUE; @@ -697,117 +687,144 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr, drop = TRUE; break; } + p_data += AVRC_AVC_HDR_SIZE; /* skip the first 3 bytes: ctype, subunit*, opcode */ + AVRC_BE_STREAM_TO_CO_ID(p_msg->company_id, p_data); + p_msg->p_vendor_data = p_data; + p_msg->vendor_len = p_pkt->len - (p_data - p_begin); - /* Check+handle fragmented messages */ +#if (AVRC_METADATA_INCLUDED == TRUE) + UINT8 drop_code = 0; drop_code = avrc_proc_far_msg(handle, label, cr, &p_pkt, p_msg); if (drop_code > 0) drop = TRUE; - } - if (drop_code > 0) - { - if (drop_code != 4) - do_free = FALSE; -#if (BT_USE_TRACES == TRUE) - switch (drop_code) + if (drop_code > 0) { - case 1: - p_drop_msg = "sent_frag"; - break; - case 2: - p_drop_msg = "req_cont"; - break; - case 3: - p_drop_msg = "sent_frag3"; - break; - case 4: - p_drop_msg = "sent_frag_free"; - break; - default: - p_drop_msg = "sent_fragd"; - } + if (drop_code != 4) + do_free = FALSE; +#if (BT_USE_TRACES == TRUE) + switch (drop_code) + { + case 1: + p_drop_msg = "sent_frag"; + break; + case 2: + p_drop_msg = "req_cont"; + break; + case 3: + p_drop_msg = "sent_frag3"; + break; + case 4: + p_drop_msg = "sent_frag_free"; + break; + default: + p_drop_msg = "sent_fragd"; + } #endif - } + } #endif /* (AVRC_METADATA_INCLUDED == TRUE) */ - break; + break; - case AVRC_OP_PASS_THRU: - if (p_pkt->len < 5) /* 3 bytes: ctype, subunit*, opcode & op_id & len */ - { - if (cr == AVCT_CMD) - reject = TRUE; + case AVRC_OP_PASS_THRU: + if (p_pkt->len < 5) /* 3 bytes: ctype, subunit*, opcode & op_id & len */ + { + if (cr == AVCT_CMD) + reject = TRUE; + else + drop = TRUE; + break; + } + p_data += AVRC_AVC_HDR_SIZE; /* skip the first 3 bytes: ctype, subunit*, opcode */ + msg.pass.op_id = (AVRC_PASS_OP_ID_MASK & *p_data); + if (AVRC_PASS_STATE_MASK & *p_data) + msg.pass.state = TRUE; else - drop = TRUE; + msg.pass.state = FALSE; + p_data++; + msg.pass.pass_len = *p_data++; + if (msg.pass.pass_len != p_pkt->len - 5) + msg.pass.pass_len = p_pkt->len - 5; + if (msg.pass.pass_len) + msg.pass.p_pass_data = p_data; + else + msg.pass.p_pass_data = NULL; break; - } - p_data += AVRC_AVC_HDR_SIZE; /* skip the first 3 bytes: ctype, subunit*, opcode */ - msg.pass.op_id = (AVRC_PASS_OP_ID_MASK & *p_data); - if (AVRC_PASS_STATE_MASK & *p_data) - msg.pass.state = TRUE; - else - msg.pass.state = FALSE; - p_data++; - msg.pass.pass_len = *p_data++; - if (msg.pass.pass_len != p_pkt->len - 5) - msg.pass.pass_len = p_pkt->len - 5; - if (msg.pass.pass_len) - msg.pass.p_pass_data = p_data; - else - msg.pass.p_pass_data = NULL; - break; - default: - if ((avrc_cb.ccb[handle].control & AVRC_CT_TARGET) && (cr == AVCT_CMD)) - { - /* reject unsupported opcode */ - reject = TRUE; + default: + if ((avrc_cb.ccb[handle].control & AVRC_CT_TARGET) && (cr == AVCT_CMD)) + { + /* reject unsupported opcode */ + reject = TRUE; + } + drop = TRUE; + break; } + } + else /* drop the event */ + { drop = TRUE; - break; } - } - else /* drop the event */ - { + + if (reject) + { + /* reject unsupported opcode */ + p_rsp = avrc_copy_packet(p_pkt, AVRC_OP_REJ_MSG_LEN); + p_rsp_data = avrc_get_data_ptr(p_rsp); + *p_rsp_data = AVRC_RSP_REJ; +#if (BT_USE_TRACES == TRUE) + p_drop_msg = "rejected"; +#endif + cr = AVCT_RSP; drop = TRUE; - } + } - if (reject) - { - /* reject unsupported opcode */ - p_rsp = avrc_copy_packet(p_pkt, AVRC_OP_REJ_MSG_LEN); - p_rsp_data = avrc_get_data_ptr(p_rsp); - *p_rsp_data = AVRC_RSP_REJ; + if (p_rsp) + { + /* set to send response right away */ + AVCT_MsgReq( handle, label, cr, p_rsp); + drop = TRUE; + } + + if (drop == FALSE) + { + msg.hdr.opcode = opcode; + (*avrc_cb.ccb[handle].p_msg_cback)(handle, label, opcode, &msg); + } #if (BT_USE_TRACES == TRUE) - p_drop_msg = "rejected"; + else + { + AVRC_TRACE_WARNING("avrc_msg_cback %s msg handle:%d, control:%d, cr:%d, opcode:x%x", + p_drop_msg, + handle, avrc_cb.ccb[handle].control, cr, opcode); + } #endif - cr = AVCT_RSP; - drop = TRUE; - } - if (p_rsp) - { - /* set to send response right away */ - AVCT_MsgReq( handle, label, cr, p_rsp); - drop = TRUE; - } - if (drop == FALSE) - { - msg.hdr.opcode = opcode; - (*avrc_cb.ccb[handle].p_msg_cback)(handle, label, opcode, &msg); + if (do_free) + GKI_freebuf(p_pkt); } -#if (BT_USE_TRACES == TRUE) else { - AVRC_TRACE_WARNING("avrc_msg_cback %s msg handle:%d, control:%d, cr:%d, opcode:x%x", - p_drop_msg, - handle, avrc_cb.ccb[handle].control, cr, opcode); + opcode = p_data[0]; + AVRC_TRACE_DEBUG("opcode:%x, length:%x",opcode, p_pkt->len); + /*Do sanity Check here*/ + if (cr == AVCT_CMD) + { + opcode = AVRC_OP_BROWSE; + msg.browse.browse_len = p_pkt->len; + AVRC_TRACE_DEBUG("Browsing length %x",msg.browse.browse_len); + /* Browse data remains same */ + msg.browse.p_browse_data = (UINT8 *)(p_pkt+1) + p_pkt->offset; + (*avrc_cb.ccb[handle].p_msg_cback)(handle, label, opcode, &msg); + } + else + { + AVRC_TRACE_ERROR("### expect AVCT_CMD"); + } + /*Free the packet as the same already got copied in BTA*/ + GKI_freebuf(p_pkt); } -#endif - - if (do_free) - GKI_freebuf(p_pkt); } @@ -1076,7 +1093,7 @@ UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt) } else { - AVRC_TRACE_ERROR ("AVRC_MsgReq no buffers for fragmentation" ); + AVRC_TRACE_ERROR("AVRC_MsgReq no buffers for fragmentation" ); GKI_freebuf(p_pkt); return AVRC_NO_RESOURCES; } |